⚠️ We will update the sample app over time. Please note that all of the latest features may not be demonstrated in the sample app. Please refer to the developer documentation changelog for the most up-to-date features.
You can use this Sample App to test the Threads API.
- Make sure that you are using the APP ID and Secret defined for the Threads API of your app. These ARE not the same as the regular app ID and app secret.
- Make sure you add your application's redirect URL e.g. https://threads-sample.meta:8000/callback, to your app's redirect callback URLs in the app dashboard.
On the Threads page, use the trash button beside one of your posts to delete it. Eligible post detail pages also show Delete after Quote and Repost. Confirm the warning to continue, or cancel to leave the post unchanged. Deletion cannot be undone.
The app checks the authenticated user and post owner before requesting deletion. It returns to your posts only after the API confirms success. Delete controls are shown on your posts list and eligible post detail pages, not the replies list. Reposts are not supported.
Deletion requires threads_delete. See Delete Posts for permissions and limits. Use a test app and test user when trying this feature.
The deletion route uses express-rate-limit to allow 10 requests per minute per IPv4 address or IPv6 subnet. Limits apply within one running app process. Excess requests show a retry message without calling the API.
Run npm test to check deletion safeguards with mocked API responses. These tests do not call the Threads API.
In order to run the Sample App you will need to install some required software, as follows:
- Node.js 18 or later
Note: If you are using devcontainers, ensure that containers are enabled and supported by your IDE.
-
Install necessary tools
- If you are using a devcontainer, skip to step 2.
- Install nodeJS to run the application. If you're using a Mac, you can install it via Homebrew:
brew install node - Install mkcert to create the OpenSSL Certificate. If you're using a Mac, you can install it via Homebrew:
brew install mkcert
-
Run
npm installin your terminal -
Create a new file called
.envand copy/paste all the environment variables from.env.template. Replace any environnment variables that have placeholders, such as APP_ID. -
Map a domain to your local machine for local development
- Note: Threads apps do not support redirect URLs with using
localhostso you must map a domain to test locally this Sample App. - Map a new entry in your hosts file to the domain that you will use to test the Sample App e.g.
threads-sample.meta. - If you're using a Linux or Mac, this will be your
/etc/hostsfile. - Add an entry like so:
127.0.0.1 threads-sample.meta - This will map threads-sample.meta to localhost, so you may visit https://threads-sample.meta:8000 to see the Threads Sample App.
- This domain must match the one defined in your
.envfile as the value of theHOSTvariable.
- Note: Threads apps do not support redirect URLs with using
-
Create an OpenSSL Cert
- OAuth redirects are only supported over HTTPS so you must create an SSL certificate
mkcert threads-sample.meta- This will create pem files for SSL.- You will see
threads-sample.meta.pemandthreads-sample.meta-key.pemfiles generated. - If you are using a host that is different than
threads-sample.metathen replace it with your specific domain.
-
Run the Sample App
- Run
npm startfrom the command line. - Once the Sample App starts running, go to https://threads-sample.meta:8000 to test the workflow.
- If you are using a different domain or port then replace those values accordingly.
- Run
Search for public posts by keyword with Top or Recent results. Use Next and Previous when available to browse results without changing your query. If a search request fails, the page shows the error and keeps your query.
See Keyword and Topic Tag Search for permissions and limits.
Run npm test to check search pagination with mocked API responses. These tests do not call the Threads API.
Threads API is Meta Platform Policy licensed, as found in the LICENSE file.