Lokasi ngalangkungan proxy:   [ UP ]  
[Ngawartoskeun bug]   [Panyetelan cookie]                
Skip to content

About

This repository contains a sample app for developers who are interested in integrating with the Threads API.

Topics

Resources

Code of conduct

Contributing

Security policy

Stars

293 stars

Watchers

13 watching

Forks

Repository files navigation

Threads API Sample App

Use this sample app to try the Threads API. We update the app over time, so it may not cover the latest features. See the Developer Documentation Changelog for the latest API updates.

Features

  • Login and Account: Sign in with Threads. View your profile details or sign out.
  • Publishing: Publish text, image, video, and carousel posts.
  • Publishing Options: Add topic tags, link attachments, alt text, and polls. Set the reply audience, add spoilers, or create ghost posts.
  • Replies, Quotes, and Reposts: Reply to, quote, or repost an existing post.
  • Post Browsing: Browse your posts, your replies, and posts that mention you. View post details and conversations.
  • Reply Management: Hide or unhide replies in the direct-replies view.
  • Search: Search by keyword or topic tag. Choose Top or Recent results. Filter by date, media type, and author. See the Search Guide for parameters and limits.
  • Public Profiles: Look up a public profile. Browse its posts.
  • Post Insights: View post metrics. Filter by date.
  • User Insights: View account metrics. Filter by date.
  • Quotas: View API usage. Refresh the reported counts.
  • Token Debugging: Inspect an access token's permissions and expiration date.
  • Post and Profile Embeds: Preview public Threads post or profile embeds in light or dark mode.
  • Deletion: Delete a post you own from the posts list or post details page. Confirm the warning to continue. Deletion cannot be undone. Use a test app and test user. See Delete Posts for permissions and limits.
  • Postman Collection: Use the public Threads Postman Collection or import postman/threads-api.postman_collection.json into Postman.

Required Software

Use Node.js 18 or later. You also need mkcert to generate a local HTTPS certificate. If you use the included devcontainer, make sure your IDE supports devcontainers. Enable them before starting.

Run the Sample App

  1. Install Node.js and mkcert. On macOS with Homebrew, run brew install node. Then run brew install mkcert. If you use the included devcontainer, skip to step 2.

  2. Run npm install in the sample app directory.

  3. Create a new file called .env and copy/paste all the environment variables from .env.template. Replace the placeholder values. Set APP_ID and API_SECRET to the Threads app ID and secret from your app dashboard. These differ from the regular app ID and secret. Add the full REDIRECT_URI, such as https://threads-sample.meta:8000/callback, to your app’s redirect callback URLs.

  4. Map your local domain to 127.0.0.1. Threads apps do not accept localhost in redirect URLs. On Linux or macOS, add this entry to /etc/hosts:

    127.0.0.1   threads-sample.meta
    

    Use the same domain for HOST in .env. If you use a different domain or port, update HOST or PORT as needed. Make sure REDIRECT_URI and the registered callback URL match.

  5. Run mkcert threads-sample.meta from the sample app directory. OAuth redirects require HTTPS. The command creates threads-sample.meta.pem and threads-sample.meta-key.pem. If you chose a different domain, use it in the command instead.

  6. Run npm start. Open https://threads-sample.meta:8000 once the app starts. If you chose a different domain or port, use those values in the URL.

Checks

Run lint, formatting, and tests before opening a pull request:

npm install --ignore-scripts --no-audit --no-fund --package-lock=false
npm run lint
npm run format:check
npm test

Tests use mocked API responses. They do not call the Threads API.

GitHub Actions runs these checks for pull requests. It also runs them for pushes to main. Both Node.js 24 and 26 are covered.

License

See LICENSE for the software license and the platform policy that applies to its use.

About

This repository contains a sample app for developers who are interested in integrating with the Threads API.

Topics

Resources

Code of conduct

Contributing

Security policy

Stars

293 stars

Watchers

13 watching

Forks

Releases

Packages

Used by

Contributors

Languages