by philnash

philnash / bitly

A Ruby wrapper for the API

433 Stars 133 Forks Last release: Not found MIT License 257 Commits 19 Releases

Available items

No Items, yet!

The developer of this repository has not created any items for sale yet. Need a bug fixed? Help with integration? A different license? Create a request here:


A Ruby gem for using the version 4 Bitly API to shorten links, expand short links and view metrics across users, links and organizations.

Gem Version Build Status Maintainability Inline docs


Add this line to your application's Gemfile:

gem 'bitly'

And then execute:

$ bundle install

Or install it yourself as:

$ gem install bitly



All API endpoints require authentication with an OAuth token. You can get your own OAuth token from the Bitly console. Click on the account drop down menu, then Profile Settings then Generic Access Token. Fill in your password and you can generate an OAuth access token.

For other methods to generate access tokens for users via OAuth flows, see the Authentication documentation.

Once you have an access token you can use all the API methods.

Creating an API client

All API methods are available through the

. Initialise the client with the access token like so:
client = token)

You can then use the client to perform actions with the API

Shorten a link

With an authenticated client you can shorten a link like so:

bitlink = client.shorten(long_url: "")
# =>

Expand a link

With an authorised you can expand any Bitlink.

bitlink = client.expand(bitlink: "")
# =>

Available API Endpoints

This gem supports the following active v4 API endpoints for theBitly API.


Groups documentation


Organizations documentation


Users documentation


Bitlinks documentation

Custom Bitlinks


BSDs (Branded Short Domains)

Branded Short Domains documentation

OAuth Apps

OAuth Apps documentation


After checking out the repo, run

to install dependencies. Then, run
rake spec
to run the tests. You can also run
for an interactive prompt that will allow you to experiment.

To install this gem onto your local machine, run

bundle exec rake install
. To release a new version, update the version number in
, and then run
bundle exec rake release
, which will create a git tag for the version, push git commits and tags, and push the
file to


Bug reports and pull requests are welcome on GitHub at This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the Contributor Covenant code of conduct.


The gem is available as open source under the terms of the MIT License.

Code of Conduct

Everyone interacting in the Bitly project’s codebases, issue trackers, chat rooms and mailing lists is expected to follow the code of conduct.

We use cookies. If you continue to browse the site, you agree to the use of cookies. For more information on our use of cookies please see our Privacy Policy.