{"id":17122030,"url":"https://github.com/solojungle/threads-ts","last_synced_at":"2026-06-17T07:30:17.277Z","repository":{"id":257790926,"uuid":"861382910","full_name":"solojungle/threads-ts","owner":"solojungle","description":"Threads API \u0026 SDK in TypeScript: Post, Reply, Analyze API","archived":false,"fork":false,"pushed_at":"2024-10-29T03:56:30.000Z","size":59,"stargazers_count":9,"open_issues_count":0,"forks_count":0,"subscribers_count":3,"default_branch":"main","last_synced_at":"2025-02-05T12:41:04.272Z","etag":null,"topics":["api","facebook","instagram","javascript","meta","meta-api","meta-threads","nodejs","rest-api","sdk","social","social-integration","social-media","socialmedia","threads","threads-api","threads-sdk","ts","typescript","typescript-sdk"],"latest_commit_sha":null,"homepage":"https://www.feedfrenzy.co","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/solojungle.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,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2024-09-22T18:38:26.000Z","updated_at":"2024-12-20T14:05:56.000Z","dependencies_parsed_at":null,"dependency_job_id":"0cb1d0dc-371c-4cdf-84f2-223e089c2fd0","html_url":"https://github.com/solojungle/threads-ts","commit_stats":null,"previous_names":["solojungle/threads-ts"],"tags_count":5,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/solojungle%2Fthreads-ts","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/solojungle%2Fthreads-ts/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/solojungle%2Fthreads-ts/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/solojungle%2Fthreads-ts/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/solojungle","download_url":"https://codeload.github.com/solojungle/threads-ts/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":240027815,"owners_count":19736281,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","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","facebook","instagram","javascript","meta","meta-api","meta-threads","nodejs","rest-api","sdk","social","social-integration","social-media","socialmedia","threads","threads-api","threads-sdk","ts","typescript","typescript-sdk"],"created_at":"2024-10-14T18:06:14.269Z","updated_at":"2026-06-17T07:30:17.229Z","avatar_url":"https://github.com/solojungle.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# threads-ts\n\nA TypeScript SDK for the Threads API, making it easy to interact with Threads in your TypeScript/JavaScript projects.\n\n[![npm version](https://badge.fury.io/js/threads-ts.svg)](https://badge.fury.io/js/threads-ts)\n[![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)\n\n## Official Threads Documentation:\nhttps://developers.facebook.com/docs/threads\n\n## Table of Contents\n\n- [Installation](#installation)\n- [Usage](#usage)\n- [API Reference](#api-reference)\n- [Contributing](#contributing)\n- [License](#license)\n\n## Installation\n\nInstall the package using npm:\n\n```bash\nnpm install threads-ts\n```\n\nOr using yarn:\n\n```bash\nyarn add threads-ts\n```\n\n## Usage\n\nFirst, import and initialize the ThreadsAPI class:\n\n```typescript\nimport { ThreadsAPI, ThreadsAPIConfig } from \"threads-ts\";\n\nimport { env } from \"@/env.mjs\";\n\nconst config: ThreadsAPIConfig = {\n\tclientId: env.THREADS_APP_ID,\n\tclientSecret: env.THREADS_APP_SECRET,\n\tredirectUri: env.CALLBACK_URL,\n\tscope: [\n\t\t\"threads_basic\",\n\t\t\"threads_content_publish\",\n\t\t\"threads_manage_replies\",\n\t\t\"threads_read_replies\",\n\t\t\"threads_manage_insights\",\n\t],\n};\n\nexport const threads = new ThreadsAPI(config);\n```\n\n### Authentication\n\nGenerate an authorization URL:\n\n```typescript\nconst authUrl = threadsAPI.getAuthorizationUrl();\nconsole.log('Authorize your app:', authUrl);\n```\n\nExchange the authorization code for an access token:\n\n```typescript\nconst code = 'AUTHORIZATION_CODE';\n\n// Get the short lived token\nconst { access_token: shortLivedToken } = await threads.getAccessToken(code);\n// Convert the short lived token to a long term access token\nconst { access_token: accessToken, expires_in: expiresIn } = await threads.getLongLivedToken(shortLivedToken);\n\n// Store the access token in your db\n\n// Now we can do stuff like get the User profile\nconst profile = await threads.getUserProfile({\n\tuserId: \"me\",\n\tfields: [\"id\", \"username\", \"name\", \"threads_profile_picture_url\"],\n});\n```\n\n### Creating and Publishing a Thread\n\n```typescript\nconst userId = 'USER_ID';\n\n// Create a media container\nconst creationId = await threadsAPI.createMediaContainer({\n  userId,\n  mediaType: 'TEXT',\n  text: 'Hello, Threads!'\n});\n\n// Publish the media container\nconst threadId = await threadsAPI.publishMediaContainer({\n  userId,\n  creationId\n});\n\nconsole.log('Published Thread ID:', threadId);\n```\n\n### Retrieving User Threads\n\n```typescript\nconst userId = 'USER_ID';\nconst fields = ['id', 'text', 'username', 'timestamp'];\n\nconst userThreads = await threadsAPI.getUserThreads({\n  userId,\n  fields,\n  options: { limit: 10 }\n});\n\nconsole.log('User Threads:', userThreads);\n```\n\n### Retrieving User Profile\n\n```typescript\nconst userId = 'USER_ID';\nconst fields = ['id', 'username', 'name', 'threads_profile_picture_url'];\n\nconst userProfile = await threadsAPI.getUserProfile({\n  userId,\n  fields\n});\n\nconsole.log('User Profile:', userProfile);\n```\n\n### Retrieving Replies to a Thread\n\n```typescript\nconst mediaId = 'THREAD_ID';\nconst fields = ['id', 'text', 'username', 'timestamp'];\n\nconst replies = await threadsAPI.getReplies({\n  mediaId,\n  fields\n});\n\nconsole.log('Replies:', replies);\n```\n\n### Responding to a Reply\n\n```typescript\nconst userId = 'USER_ID';\nconst replyToId = 'THREAD_ID_TO_REPLY_TO';\n\nconst replyId = await threadsAPI.respondToReply({\n  userId,\n  mediaType: 'TEXT',\n  text: 'This is my response!',\n  replyToId\n});\n\nconsole.log('Reply ID:', replyId);\n```\n\n### Retrieving Media Insights\n\n```typescript\nconst mediaId = 'THREAD_ID';\nconst metrics = ['engagement', 'impressions', 'reach'];\n\nconst insights = await threadsAPI.getMediaInsights({\n  mediaId,\n  metrics\n});\n\nconsole.log('Media Insights:', insights);\n```\n\n## API Reference\n\nFor a complete list of available methods and their parameters, please refer to the [API documentation](https://github.com/solojungle/threads-ts/blob/main/API.md).\n\n## Contributing\n\nWe welcome contributions to the threads-ts SDK! Here's how you can help:\n\n1. Fork the repository\n2. Create your feature branch (`git checkout -b feature/AmazingFeature`)\n3. Commit your changes (`git commit -m 'Add some AmazingFeature'`)\n4. Push to the branch (`git push origin feature/AmazingFeature`)\n5. Open a Pull Request\n\nPlease make sure to update tests as appropriate and adhere to the existing coding style.\n\n## License\n\nThis project is licensed under the MIT License - see the [LICENSE](LICENSE) file for details.\n\n## Support\n\nIf you encounter any issues or have questions, please [open an issue](https://github.com/solojungle/threads-ts/issues) on GitHub.\n\n## Acknowledgements\n\n- Thanks to the Threads team for providing the API\n- All the contributors who have helped improve this SDK\n\n---\n\nMade with ❤️ by [solojungle](https://github.com/solojungle)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsolojungle%2Fthreads-ts","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsolojungle%2Fthreads-ts","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsolojungle%2Fthreads-ts/lists"}