Home United States USA — software How to Use the Bitly API in Ruby

How to Use the Bitly API in Ruby

1696
0
SHARE

Bitly has an API so that you can shorten, expand and get metrics on links all in your app. This is how to use that Bitly API in Ruby.
Join the DZone community and get the full member experience.
Link shortening has been around for a long time, and Bitly is arguably the king of link shorteners. It has support for shortening long URLs as well as custom short links, custom domains, and metrics to track how each link is performing.
For those of us with the power of code at our fingertips, Bitly also has an API. With the Bitly API, you can build all of the functionality of Bitly into your own applications and expose it to your users. In this post, you’ll learn how to use the Bitly Ruby gem to use the Bitly API in your Ruby applications.
To start shortening or expanding links with the Bitly gem, you’ll need Ruby installed and a Bitly account.
To make API requests against the Bitly API you will need an access token. Log in to your Bitly account and head to the API settings. Here you can enter your account password and generate a new token. This token will only be shown once, so copy it now.
Open a terminal and install the Bitly gem:
Let’s explore the gem in the terminal.

Continue reading...