{"id":29878245,"url":"https://github.com/tirthpatell/threads-go","last_synced_at":"2026-03-14T00:56:14.942Z","repository":{"id":306861291,"uuid":"1027400017","full_name":"tirthpatell/threads-go","owner":"tirthpatell","description":"Go client for Meta's Threads - OAuth 2.0, rate limiting, full API coverage, production-ready","archived":false,"fork":false,"pushed_at":"2026-02-11T03:18:34.000Z","size":152,"stargazers_count":4,"open_issues_count":0,"forks_count":2,"subscribers_count":0,"default_branch":"main","last_synced_at":"2026-02-11T08:34:26.591Z","etag":null,"topics":["api-client","client","go","golang","golang-sdk","meta-api","meta-threads","oauth2","social-media-api","threads","threads-api","threads-go"],"latest_commit_sha":null,"homepage":"","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/tirthpatell.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2025-07-28T00:12:47.000Z","updated_at":"2026-02-11T03:17:37.000Z","dependencies_parsed_at":"2025-08-19T04:17:29.790Z","dependency_job_id":"98c0b3a0-be9a-4a6b-b8fa-e5c54692e73d","html_url":"https://github.com/tirthpatell/threads-go","commit_stats":null,"previous_names":["tirthpatell/threads-go"],"tags_count":9,"template":false,"template_full_name":null,"purl":"pkg:github/tirthpatell/threads-go","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tirthpatell%2Fthreads-go","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tirthpatell%2Fthreads-go/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tirthpatell%2Fthreads-go/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tirthpatell%2Fthreads-go/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/tirthpatell","download_url":"https://codeload.github.com/tirthpatell/threads-go/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tirthpatell%2Fthreads-go/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":29499815,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-02-16T03:57:51.541Z","status":"ssl_error","status_checked_at":"2026-02-16T03:55:59.854Z","response_time":115,"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":["api-client","client","go","golang","golang-sdk","meta-api","meta-threads","oauth2","social-media-api","threads","threads-api","threads-go"],"created_at":"2025-07-31T07:01:31.718Z","updated_at":"2026-03-14T00:56:14.936Z","avatar_url":"https://github.com/tirthpatell.png","language":"Go","funding_links":[],"categories":["Third-party APIs"],"sub_categories":["Utility/Miscellaneous"],"readme":"# Threads API Go Client\n\n[![Go Reference](https://pkg.go.dev/badge/github.com/tirthpatell/threads-go.svg)](https://pkg.go.dev/github.com/tirthpatell/threads-go)\n[![Go Report Card](https://goreportcard.com/badge/github.com/tirthpatell/threads-go)](https://goreportcard.com/report/github.com/tirthpatell/threads-go)\n[![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)\n[![Coverage](https://img.shields.io/endpoint?url=https://gist.githubusercontent.com/tirthpatell/2c608589294aed9aa900256daeec0fd4/raw/coverage.json)](https://github.com/tirthpatell/threads-go/actions)\n\nUnofficial, production-ready Go client for the [Threads API](https://developers.facebook.com/docs/threads) with complete endpoint coverage, OAuth 2.0 authentication, rate limiting, and comprehensive error handling. Not affiliated with or endorsed by Meta.\n\nRequires Go 1.21+. Tested on Go 1.21-1.24.\n\n## Features\n\n- Complete API coverage (posts, users, replies, insights, locations, search)\n- GIF attachments (GIPHY), ghost posts, and reply approvals\n- Fluent `ContainerBuilder` for advanced post creation\n- OAuth 2.0 flow and existing token support\n- Intelligent rate limiting with exponential backoff\n- Type-safe error handling with transient error detection\n- Thread-safe concurrent usage\n- Comprehensive test coverage\n\n## Installation\n\n```bash\ngo get github.com/tirthpatell/threads-go\n```\n\n## Quick Start\n\n### With Existing Token\n\n```go\nclient, err := threads.NewClientWithToken(\"your-access-token\", \u0026threads.Config{\n    ClientID:     \"your-client-id\",\n    ClientSecret: \"your-client-secret\",\n    RedirectURI:  \"your-redirect-uri\",\n})\n\n// Create a post\npost, err := client.CreateTextPost(context.Background(), \u0026threads.TextPostContent{\n    Text: \"Hello Threads!\",\n})\n```\n\n### OAuth Flow\n\n```go\nconfig := \u0026threads.Config{\n    ClientID:     \"your-client-id\",\n    ClientSecret: \"your-client-secret\", \n    RedirectURI:  \"your-redirect-uri\",\n    Scopes:       []string{\"threads_basic\", \"threads_content_publish\"},\n}\n\nclient, err := threads.NewClient(config)\n\n// Get authorization URL\nauthURL := client.GetAuthURL(config.Scopes)\n// Redirect user to authURL\n\n// Exchange authorization code for token\nctx := context.Background()\nerr = client.ExchangeCodeForToken(ctx, \"auth-code-from-callback\")\nerr = client.GetLongLivedToken(ctx) // Convert to long-lived token\n```\n\n### Environment Variables\n\n```bash\nexport THREADS_CLIENT_ID=\"your-client-id\"\nexport THREADS_CLIENT_SECRET=\"your-client-secret\"\nexport THREADS_REDIRECT_URI=\"your-redirect-uri\"\nexport THREADS_ACCESS_TOKEN=\"your-access-token\"  # optional\n```\n\n```go\nclient, err := threads.NewClientFromEnv()\n```\n\n## Available Scopes\n\n- `threads_basic` - Basic profile access\n- `threads_content_publish` - Create and publish posts  \n- `threads_manage_insights` - Access analytics data\n- `threads_manage_replies` - Manage replies and conversations\n- `threads_read_replies` - Read replies to posts\n- `threads_keyword_search` - Search functionality\n- `threads_delete` - Delete posts\n- `threads_location_tagging` - Location services\n\n## API Usage\n\n### Posts\n\n```go\n// Create different post types\ntextPost, err := client.CreateTextPost(ctx, \u0026threads.TextPostContent{\n    Text: \"Hello Threads!\",\n})\n\nimagePost, err := client.CreateImagePost(ctx, \u0026threads.ImagePostContent{\n    Text: \"Check this out!\",\n    ImageURL: \"https://example.com/image.jpg\",\n})\n\n// Get posts\npost, err := client.GetPost(ctx, threads.PostID(\"123\"))\nposts, err := client.GetUserPosts(ctx, threads.UserID(\"456\"), \u0026threads.PaginationOptions{Limit: 25})\n\n// Delete post\nerr = client.DeletePost(ctx, threads.PostID(\"123\"))\n```\n\n### Users \u0026 Profiles\n\n```go\n// Get user info\nme, err := client.GetMe(ctx)\nuser, err := client.GetUser(ctx, threads.UserID(\"123\"))\n\n// Public profiles\npublicUser, err := client.LookupPublicProfile(ctx, \"@username\")\nposts, err := client.GetPublicProfilePosts(ctx, \"username\", nil)\n```\n\n### Replies \u0026 Conversations\n\n```go\n// Reply to posts\nreply, err := client.ReplyToPost(ctx, threads.PostID(\"123\"), \u0026threads.PostContent{\n    Text: \"Great post!\",\n})\n\n// Get replies\nreplies, err := client.GetReplies(ctx, threads.PostID(\"123\"), \u0026threads.RepliesOptions{Limit: 50})\n\n// Manage visibility\nerr = client.HideReply(ctx, threads.PostID(\"456\"))\n```\n\n### Insights \u0026 Analytics\n\n```go\n// Post insights\ninsights, err := client.GetPostInsights(ctx, threads.PostID(\"123\"), []string{\"views\", \"likes\"})\n\n// Account insights  \ninsights, err := client.GetAccountInsights(ctx, threads.UserID(\"456\"), []string{\"views\"}, \"lifetime\")\n```\n\n### Search \u0026 Locations\n\n```go\n// Search posts by keyword\nresults, err := client.KeywordSearch(ctx, \"golang\", \u0026threads.SearchOptions{Limit: 25})\n\n// Search posts filtered by media type\nimageResults, err := client.KeywordSearch(ctx, \"nature\", \u0026threads.SearchOptions{\n    MediaType: threads.MediaTypeImage,  // Filter for IMAGE posts only (TEXT, IMAGE, or VIDEO)\n    Limit: 25,\n})\n\n// Search posts by topic tag\ntagResults, err := client.KeywordSearch(ctx, \"#technology\", \u0026threads.SearchOptions{\n    SearchMode: threads.SearchModeTag,\n    Limit: 25,\n})\n\n// Location search\nlocations, err := client.SearchLocations(ctx, \"New York\", nil, nil)\n```\n\n### GIF Posts\n\n```go\n// Create a post with a GIF attachment (GIPHY)\ngifPost, err := client.CreateTextPost(ctx, \u0026threads.TextPostContent{\n    Text: \"Check out this GIF!\",\n    GIFAttachment: \u0026threads.GIFAttachment{\n        GIFID:    \"giphy-gif-id\",\n        Provider: threads.GIFProviderGiphy,\n    },\n})\n```\n\n\u003e Note: Tenor support is deprecated and will be sunset on March 31, 2026. Use GIPHY instead.\n\n### Ghost Posts\n\n```go\n// Create a ghost post (auto-expiring)\nghost, err := client.CreateTextPost(ctx, \u0026threads.TextPostContent{\n    Text:        \"This will disappear!\",\n    IsGhostPost: true,\n})\n\n// Retrieve a user's ghost posts\nghosts, err := client.GetUserGhostPosts(ctx, userID, nil)\n```\n\n### Reply Approvals\n\n```go\n// Approve or ignore pending replies\nerr = client.ApprovePendingReply(ctx, threads.PostID(\"reply-id\"))\nerr = client.IgnorePendingReply(ctx, threads.PostID(\"reply-id\"))\n```\n\n### Container Builder\n\nFor advanced post creation, use the fluent `ContainerBuilder`:\n\n```go\nbuilder := threads.NewContainerBuilder().\n    SetMediaType(\"TEXT\").\n    SetText(\"Hello from the builder!\").\n    SetReplyControl(threads.ReplyControlFollowersOnly).\n    SetTopicTag(\"golang\").\n    SetLocationID(\"location-id\")\nparams := builder.Build()\n```\n\n### Pagination \u0026 Iterators\n\nFor large datasets, use iterators to automatically handle pagination:\n\n```go\n// Posts iterator\nuserID := threads.ConvertToUserID(\"user_id\")\niterator := threads.NewPostIterator(client, userID, \u0026threads.PostsOptions{\n    Limit: 25,\n})\n\nfor iterator.HasNext() {\n    response, err := iterator.Next(ctx)\n    if err != nil {\n        log.Fatal(err)\n    }\n    \n    for _, post := range response.Data {\n        fmt.Printf(\"Post: %s\\n\", post.Text)\n    }\n}\n\n// Replies iterator\nreplyIterator := threads.NewReplyIterator(client, threads.PostID(\"123\"), \u0026threads.RepliesOptions{\n    Limit: 50,\n})\n\n// Search iterator\nsearchIterator := threads.NewSearchIterator(client, \"golang\", \"keyword\", \u0026threads.SearchOptions{\n    Limit: 25,\n})\n\n// Collect all results at once\nallPosts, err := iterator.Collect(ctx)\n```\n\n## Configuration\n\n```go\nconfig := \u0026threads.Config{\n    ClientID:     \"your-client-id\",\n    ClientSecret: \"your-client-secret\",\n    RedirectURI:  \"https://yourapp.com/callback\",\n    Scopes:       []string{\"threads_basic\", \"threads_content_publish\"},\n    HTTPTimeout:  30 * time.Second,\n    Debug:        false,\n}\n```\n\nFor advanced configuration including retry logic, custom logging, and token storage, see the [GoDoc documentation](https://pkg.go.dev/github.com/tirthpatell/threads-go).\n\n## Error Handling\n\nThe client provides typed errors for different scenarios:\n\n```go\nswitch {\ncase threads.IsAuthenticationError(err):\n    // Handle authentication issues\ncase threads.IsRateLimitError(err):\n    rateLimitErr := err.(*threads.RateLimitError)\n    time.Sleep(rateLimitErr.RetryAfter)\ncase threads.IsValidationError(err):\n    validationErr := err.(*threads.ValidationError)\n    log.Printf(\"Invalid %s: %s\", validationErr.Field, err.Error())\ncase threads.IsTransientError(err):\n    // Safe to retry — transient API error\n}\n```\n\nError types: `AuthenticationError`, `RateLimitError`, `ValidationError`, `NetworkError`, `APIError`\n\n## Testing\n\n```bash\n# Unit tests\ngo test ./...\n\n# Integration tests (requires valid credentials)\nexport THREADS_ACCESS_TOKEN=\"your-token\"\ngo test ./tests/integration/...\n```\n\n## Contributing\n\nSee [CONTRIBUTING.md](CONTRIBUTING.md) for guidelines.\n\n## Official Documentation\n\n- [Meta Threads API Documentation](https://developers.facebook.com/docs/threads)\n- [Threads API Reference](https://developers.facebook.com/docs/threads/reference)\n- [Authentication Guide](https://developers.facebook.com/docs/threads/getting-started)\n\n## License\n\nMIT License - see [LICENSE](LICENSE) file for details.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftirthpatell%2Fthreads-go","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ftirthpatell%2Fthreads-go","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftirthpatell%2Fthreads-go/lists"}