Coder Social home page Coder Social logo

bitly's Introduction

Bitly

Godoc

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.

Usage

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 (
	"fmt"

	"github.com/retgits/bitly/client"
)

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

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

import (
    "github.com/retgits/bitly/client/bitlinks" // If you want to use the bitlinks resource
    "github.com/retgits/bitly/client/bsds" // If you want to use the bsds resource
    "github.com/retgits/bitly/client/groups" // If you want to use the groups resource
    "github.com/retgits/bitly/client/organizations" // If you want to use the organizations
    "github.com/retgits/bitly/client/users" // If you want to use the users resource
)

For example, getting the details of the user would be

package main

import (
	"fmt"

	"github.com/retgits/bitly/client"
	"github.com/retgits/bitly/client/users"
)

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.Println(err.Error())
	}
    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:[{Email:[email protected] IsPrimary:true IsVerified:true}] IsSsoUser:false DefaultGroupGUID:myGuid}
}

Contributing

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

├── LICENSE
├── README.md
├── 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

License

See the LICENSE file in the repository

Acknowledgements

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

bitly's People

Contributors

retgits avatar

Stargazers

 avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.