Skip to content
A Go package to interact with the Bitly API
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Type Name Latest commit message Commit time
Failed to load latest commit information.



If you'd like to use Bitly to shorten, brand, share, or retrieve data from links using Go, this is the right module you're looking for. This lib is a wrapper on top of the v4 Bitly API.

Why build this?

I think Bitly is an awesome service, but to interact with it using the API, and marshaling and unmarshalling the data every time was a bit of a mess. Because there wasn't a good Go module available yet, I decided to build my own.


To use the Bitly module, you'll need to create a Generic Access Token. That access token can be used to create the bitly client.

import (


func main() {
	bitly := client.NewClient().WithAccessToken("<myAccessToken>")

Depending on which type of resource you want to access, you'll need to import one of the services

import (
    "" // If you want to use the bitlinks resource
    "" // If you want to use the bsds resource
    "" // If you want to use the groups resource
    "" // If you want to use the organizations
    "" // If you want to use the users resource

For example, getting the details of the user would be

package main

import (


func main() {
	// Generate a new Bitly client
	bitly := client.NewClient().WithAccessToken("<myAccessToken>")
	// Create a new users service
	usersSvc := users.New(bitly)
	// Get the details of your user
	me, err := usersSvc.RetrieveUser()
	if err != nil {
    fmt.Printf("User details: %+v\n", me)
    // Result
    // User details: {Created:2018-08-05T22:08:53+0000 Modified:2018-08-05T22:29:42+0000 Login:myOrganization IsActive:true Is2FaEnabled:false Name:John Doe Emails:[{ IsPrimary:true IsVerified:true}] IsSsoUser:false DefaultGroupGUID:myGuid}


If something is missing, or if you'd like to suggest new features feel free to create an issue or a PR! The code is structured as

├── client
│   ├── bitlinks       <-- Bitlinks service
│   │   ├── api.go     <-- The types and helper methods for the service
│   │   └── service.go <-- The methods that can be used with this module
│   ├── bsds           <-- BSDs service
│   │   ├── api.go
│   │   └── service.go
│   ├── groups         <-- Groups service
│   │   ├── api.go
│   │   └── service.go
│   ├── http.go
│   ├── organizations  <-- Organizations service
│   │   ├── api.go
│   │   └── service.go
│   └── users          <-- Users service
│       ├── api.go
│       └── service.go
└── go.mod


See the LICENSE file in the repository


A most sincere thanks to the team of Bitly, for building such an awesome service that I enjoy every day!

This package is not endorsed by Bitly

You can’t perform that action at this time.