Skip to content

vniche/twitter-go

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

15 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

twitter-go

GoDoc

twitter-go is a Go client library for accessing the Twitter API v2.

Usage

First we have to go to Twitter Developer platform and register to get hands on a bearer token to use on our requests to the API, since all endpoints require one.

Installing

import "github.com/vniche/twitter-go"

Construct a new Twitter client, then use the various services on the client to access different parts of the Twitter API. For example:

// Fetching an user by ID

import (
    twitter "github.com/vniche/twitter-go"
)

client := twitter.WithBearerToken("mybearertoken123", nil)

// custom parameters for query
params := make(map[string][]string)
params["user.fields"] = []string{
    "public_metrics",
}

// fetch user by id
user, err := client.LookupUserByID(userID, params)
if err != nil {
    log.Panicf("unable to fetch user by id: %+v", err)
}

fmt.Printf("user: %+v\n", user)

Contributing

I would like to cover the entire Twitter API and contributions are of course always welcome. The calling pattern is pretty well established, so adding new methods is relatively straightforward.

TODO: Contribution doc.

License

This library is distributed under the MIT license found in the LICENSE file.

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages