{"id":38368355,"url":"https://github.com/arshamalh/twigo","last_synced_at":"2026-01-17T03:25:37.745Z","repository":{"id":37837507,"uuid":"468076708","full_name":"arshamalh/twigo","owner":"arshamalh","description":"Golang Twitter Library","archived":false,"fork":false,"pushed_at":"2022-06-22T17:25:45.000Z","size":238,"stargazers_count":26,"open_issues_count":0,"forks_count":3,"subscribers_count":1,"default_branch":"main","last_synced_at":"2024-06-19T04:08:00.194Z","etag":null,"topics":["go","golang","twitter","twitter-api","twitter-bot"],"latest_commit_sha":null,"homepage":"https://pkg.go.dev/github.com/arshamalh/twigo","language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/arshamalh.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2022-03-09T20:06:58.000Z","updated_at":"2024-04-22T17:32:13.000Z","dependencies_parsed_at":"2022-08-19T23:10:59.045Z","dependency_job_id":null,"html_url":"https://github.com/arshamalh/twigo","commit_stats":null,"previous_names":[],"tags_count":3,"template":false,"template_full_name":null,"purl":"pkg:github/arshamalh/twigo","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/arshamalh%2Ftwigo","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/arshamalh%2Ftwigo/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/arshamalh%2Ftwigo/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/arshamalh%2Ftwigo/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/arshamalh","download_url":"https://codeload.github.com/arshamalh/twigo/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/arshamalh%2Ftwigo/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":28492894,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-01-17T02:39:23.645Z","status":"ssl_error","status_checked_at":"2026-01-17T02:34:19.649Z","response_time":85,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.6:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["go","golang","twitter","twitter-api","twitter-bot"],"created_at":"2026-01-17T03:25:37.651Z","updated_at":"2026-01-17T03:25:37.718Z","avatar_url":"https://github.com/arshamalh.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"# twigo (Golang Twitter Library)\n\n\u003cp align=\"center\"\u003e\n  \u003cimg src=\"./twigo.png\" alt=\"twigo logo\" width=\"300\"\u003e\n\u003c/p\u003e\n\n### Twigo is a fast and easy to use twitter API library help you write best twitter bots.\n\nCurrently we only support twitter api v2, but version 1.1 will be added soon.\n\nCaution! we are still in Beta phase.\n\n## installation\n\n```bash\ngo get github.com/arshamalh/twigo\n```\n\n# How to use\nEasily make a new client!\n```go\npackage main\n\nimport \"github.com/arshamalh/twigo\"\n\ntwigo.NewClient((\u0026twigo.Config{\n  ConsumerKey:    \"ConsumerKey\",\n  ConsumerSecret: \"ConsumerSecret\",\n  AccessToken:    \"AccessToken\",\n  AccessSecret:   \"AccessTokenSecret\",\n  // Both of \"bearer token\" or \"four other keys (ConsumerKey, ...)\" is not mandatory.\n  // We'll find bearer token automatically if it's not specified.\n  // Also, you can use twigo.utils.BearerFinder() function.\n  BearerToken:    \"BearerToken\",\n}))\n```\n\nAnd use any function you need, for example, get a tweet like this:\n\n```go\nresponse, _ := client.GetTweet(tweet_id, nil)\nfmt.Printf(\"%#v\\n\", response)\ntweet := response.Data\n```\n\nMaking a tweet, as easy as below:\n\n```go\nclient.CreateTweet(\"This is a test tweet\", nil)\n```\n\nRetweeting and Liking a tweet:\n\n```go\nclient.Retweet(\"1516784368601153548\")\nclient.Like(\"1431751228145426438\")\n```\n\nOr Maybe deleting your like and retweet:\n\n```go\nclient.UnRetweet(\"1516784368601153548\")\nclient.Unlike(\"1516784368601153548\")\n```\n\n**Simple, right?**\n\n### Rate limits\nHow many actions can we do?\n\nYou can simpy read RateLimits attribute on the Response!\n```go\n  RateLimits:{\n    Limit:75 // An static number depending on the endpoint that you are calling or your authentication method.\n    Remaining:74 // An dynamic method that decreases after each call, and will reset every once in a while.\n    ResetTimestamp:1650553033 // Reset (charge up) remaining calls in this timestamp.\n  }\n```\n\n### More examples:\n\nPassing some extra fields and params:\n\n```go\nfields := twigo.Map{\"tweet.fields\": []string{\"author_id\", \"created_at\", \"public_metrics\"}}\nresponse, _ := client.GetTweet(tweet_id, fields)\nfmt.Printf(\"%#v\\n\", response)\ntweet := response.Data\n```\n\nIf the tweet doesn't exist or it's from a suspended account, \ntwigo will return an empty struct instead, \nYou should get tweet.ID and see if it's a \"\" or not.\n\n```go\n\u0026twigo.TweetResponse{\n  Data: twigo.Tweet{\n    ID:\"\", \n    Text:\"\", \n    PublicMetrics:map[string]int(nil)\n    // Other fields\n  }, \n  Meta: twigo.MetaEntity{\n    ResultCount:0, \n    NextToken:\"\"\n    // Other fields\n  }, \n  RateLimits: twigo.RateLimits{\n    Limit:300, \n    Remaining:294, \n    ResetTimestamp:1651585436\n  }\n}\n```\n\nYou can get Liking users: (users who liked a tweet)\n\n```go\nresponse, err := client.GetLikingUsers(\n  \"1431751228145426438\", \n  twigo.Map{\n    \"max_results\": 5,\n  })\n\nif err != nil {\n  fmt.Println(err)\n}\n\nfmt.Printf(\"%+v\\n\", response)\n```\n\nAnd result will be a Go struct like this:\n\n```Go\n{\n  Data:[\n    {\n      ID:1506623384850948096 \n      Name:Rhea Baker \n      Username:RheaBak16183941\n      Verified:false\n    } {\n      ID:1506621280098869252 \n      Name:Janice Lane \n      Username:JaniceL44359093\n      Verified:false\n    }\n    // And more...\n  ] \n  Includes: // Some structs, read more on docs...\n  Errors:[] \n  Meta:{\n    ResultCount:5 \n    NextToken:7140dibdnow9c7btw480y5xgmlpwtbsh4fyqnqmwz9k4w\n    // And more...\n  }\n  RateLimits:{\n    Limit:75\n    Remaining:74\n    ResetTimestamp:1650553033\n  }\n}\n```\n\nYou can get some users by their username or by their IDs:\n\n```go\nresponse, err := client.GetUsersByUsernames(\n  []string{\"arshamalh\", \"elonmusk\", \"someone_else\"}, \n  nil, // There is no param in this example.\n)\n```\n\nReturn all tweets a user have written in the last 30 minutes.\n\n```go\nstart_time := time.Now().UTC().Add(-30 * time.Minute)\nparams := twigo.Map{\"max_results\": 5, \"start_time\": start_time}\nuser_tweets, _ := bot.GetUserTweets(user_id, params)\nif len(user_tweets.Data) != 0 {\n  fmt.Printf(\"\u003c\u003cSome tweets found\u003e\u003e\")\n  for _, tweet := range user_tweets.Data {\n\t\tfmt.Printf(\"%#v\\n\", tweet)\n\t}\n}\n```\n\n### How to paginate over results?\nif your method is paginatable, you can paginate using NextPage method attached to the response, like this:\n\n```go\nresponse, _ := client.GetUserTweets(\"1216345203453452289\", nil)\nfor {\n  fmt.Printf(\"%#v\\n\", response)\n  response, err = response.NextPage()  // Here the magic happens! NextPage method attached to response\n\n  if err != nil {  // Break the loop whenever there is no more pages.\n    fmt.Println(err)\n    break\n  }\n}\n```\n\nA little bit more complex example:\n\n```go\nresponse, err := client.GetUserTweets(\"1216345203453452289\", nil)\n\nif err != nil {  // Is there any response at all?\n  fmt.Println(err)\n} else {\n  page_number := 1  // To keep track of page number.\n  for {\n    fmt.Printf(\"Page %d: %#v\\n\", page_number, response)\n    response, err = response.NextPage()\n\n    if err != nil {\n      fmt.Println(err)\n      break\n    }\n\n    // If rate limits exceeds, wait until it charges again, \n    // it's not a good approach, because all of your app will sleep, \n    // it's highly recommended to do it in a goroutine instead.\n    if response.RateLimits.Remaining == 0 {\n      fmt.Println(\"Rate limit reached\")\n      sleeping_duration := time.Until(time.Unix(response.RateLimits.ResetTimestamp, 0))\n      time.Sleep(sleeping_duration)\n\t\t}\n    page_number++\n  }\n}\n```\n\n## Contribution\nFeel free to open an issue, contribute and contact us!\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Farshamalh%2Ftwigo","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Farshamalh%2Ftwigo","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Farshamalh%2Ftwigo/lists"}