Skip to content
An objective-c implementation using SBJSON and ASI
Find file
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Failed to load latest commit information.


BRBitly provides an Objective C wrapper class for accessing the free URL shortening services at from iOS 4.0 or newer.


BRBitly was rather brazenly copied and adapted from ILBitly. I wanted to use ILBitly directly, but the existing project was already built around ASI and SBJson rather than AFNetwork and JSONkit, so I adapted it to my needs.


  • ASI HTTP Request - Used for the underlying network access
  • SBJson - Needed for parsing the response from
  • You will also need an account at including an API key

Example Usage

Shortening an URL

BRBitly *bitly = [[BRBitly alloc] initWithLogin:login apiKey:apiKey];
[bitly shorten:@"" result:^(NSString *shortURLString) {
    NSLog(@"The shortened URL: %@", shortURLString);
} error:^(NSError *err) {
    NSLog(@"An error occurred %@", err);
[bitly release];

Expanding an URL

[bitly expand:@"" result:^(NSString *longURLString) {
    NSLog(@"The expanded URL: %@", longURLString);
} error:^(NSError *err) {
    NSLog(@"An error occurred %@", err);

Getting statistics on number of clicks

[bitly clicks:@"" result:^(NSInteger userClicks, NSInteger globalClicks) {
    NSLog(@"This link has been clicked %d times out of %d clicks globally: %d", userClicks, globalClicks);
} error:^(NSError *err) {
    NSLog(@"An error occurred %@", err);

See more examples in the attached sample project.

Building Xcode Documentation

BRBitly is documented in the header files using the appledoc syntax. The sample app contains a target called "Documentation" which will build the documentation and install it for use inside Xcode as a searchable and browsable docset. In order to be able to build it you will need to install appledoc on your own computer. You can get appledoc from GitHub. For more information about how to setup and build the documentation you can read this short tutorial.

Feel free to add enhanchements, bug fixes, changes and provide them back to the community!


Reid van Melle

Something went wrong with that request. Please try again.