Skip to content

A simple Go wrapper for Twitter API v2 ✨ 🍰 ✨

License

Notifications You must be signed in to change notification settings

sns-sdks/go-twitter

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

go-twitter

A simple Go wrapper for Twitter API v2 ✨ 🍰 ✨

Test Status Test Coverage Go Report Card Go Reference

Installation

# Go Modules
require github.com/sns-sdks/go-twitter

Usage

App with OAuth 2.0

Construct a new client with bearer token, then use the api.

cli := twitter.NewBearerClient("your bearer token")
u, err := cli.Tweets.LookupByID("tweet id", twitter.TweetOpts{})
fmt.Println(u, err)

OAuth 2.0 has released with beta.

So you can do OAuth2.0 with twitter. More see the Example for OAuth2.0

Authentication

Some apis need OAuth 1.0a User context, You can use initial a client with user access token.

app := twitter.NewAuthorizationAPP(
	twitter.AuthorizationAPP{
		ConsumerKey:       "consumer key",
		ConsumerSecret:    "consumer secret",
		AccessTokenKey:    "user access token key",
		AccessTokenSecret: "user access toke secret",
    })
cli := app.GetUserClient()
bu, err := cli.Users.GetBlocking(uid, twitter.UserBlockingOpts{})
fmt.Println(bu, err)

Or you can handle authentication contact with twitter. See the Example for OAuth 1.0a

Features

Tweets:

  • Tweets lookup
  • Manage Tweets
  • Timelines
  • search Tweets
  • Tweet counts
  • Retweets
  • Likes
  • Hide replies

Users:

  • Users lookup
  • Follows
  • Blocks
  • Mutes

Spaces:

  • Lookup
  • Search

Lists:

  • List lookup
  • Manage lists
  • List Tweets lookup
  • List members
  • List follows
  • Pinned Lists

Compliance:

  • Batch compliance

Direct Message:

  • Direct Messages lookup
  • Manage Direct Messages