This post will be a bit different. I recently started using Meta Threads, and I saw someone complaining that Meta should create a widget for certain stats. I replied, saying it should be possible using the Scriptable app. Long story short, I decided to dive into this rabbit hole and create some widgets for Meta Threads. I’ll be creating two widgets—one for follower counts and profile visitors for today and yesterday, and a second widget to display view counts for the latest post. I’ll be using the Scriptable app to make these, which you can download for free from the iOS App Store.

Diagram

Step 1: Set Up the Meta App

The first thing to do is go to Meta for Developers and create an app.

Once you’re there, the setup process is mostly “next-next-next.”

Select “I don’t want to connect a business portfolio yet.”

Diagram

Then, choose “Access the Threads API”.

Diagram

Enter your app name and email:

Diagram

Click “Go to Dashboard”.

Diagram

In the dashboard settings, continue with more “next-next-next.”

Diagram

First, go to “Access the Threads API” and select “threads_basic” and “threads_manage_insights”—these are the bare minimum permissions needed for this project. If you want to do more, adjust your permissions accordingly.

Diagram

Then, click “Test Use Cases” (it should automatically show a green tick).

Diagram

Finally, click “Finish Customization”.

Diagram

Step 2: Add Roles

Now, go to “App Roles” and then to “Roles”.

Diagram

Click “Add People” and select “Threads Tester.” Below that, add your own user, as shown in the screenshot:

Diagram

Now, open the Threads app with that user. Go to Settings > Account > Website Permissions > Invites and accept the invite.

Diagram

Step 3: Get an Access Token

Now, we need to get a token. Go to the Facebook Developer Explorer.

Select “threads.net” and click “Generate Threads Access Token”.

Diagram

When the Threads pop-up appears, just click “Continue.”

Diagram

You’ll now see your token in the “Access Token” field.

Diagram

Validate that your token works by using the “Access Token Debugger”:

Access Token Debugger

If it shows something similar to the screenshot below, then you’re good to go.

Diagram

Step 4: Exchange for a Long-Lived Token

Now we need to exchange this short-lived token (which expires in 60 minutes) for a long-lived token that will last two months. Details are here: Long-Lived Tokens.

Run this command:

curl -s -X GET "https://graph.threads.net/access_token?grant_type=th_exchange_token&client_secret=<THREADS_APP_SECRET>&access_token=<SHORT_LIVED_ACCESS_TOKEN>"

Since we’re missing THREADS_APP_SECRET, go to Facebook Apps, select your app, and go to “App Settings” > “Basic”. You’ll see a screen like this:

Diagram

Click “Show” next to “App Secret”.

Now use this in the curl command above to get your long-lived token.

Once you have the long-lived token, recheck it using the Access Token Debugger.

Step 5: Start Building the Widgets

The idea is to have two widgets—a “main” widget for followers + visitors and a “secondary” widget for the last post’s view count.

  • The main widget will display stats and handle token refresh, saving it in iCloud under the same filename you initially used.
  • The secondary widget will use the same token from iCloud but won’t handle token refreshes (assuming the token remains valid). This means you can’t use the secondary widget independently without adjusting the code. You can, however, copy the token refresh code from the main widget to the secondary if needed.

Step 6: Save the Long-Lived Token to iCloud

To store the token, use this one-time Scriptable app code during your initial setup. The main widget code will handle future token refreshes and updates:

Token Storage Script

Once the token is in iCloud, we’re ready to build the main widget.

Building the Widgets

Documentation from Meta used for the main widget:

Meta Threads Insights Documentation

For the main widget, I’m using the following endpoints for followers and profile visitors:

Followers:

https://graph.threads.net/v1.0/me/threads_insights?metric=followers_count&access_token=zzz

Profile Visitors:

https://graph.threads.net/v1.0/me/threads_insights?metric=views&access_token=zzz

You can find the full code for the main widget here:

Main Widget Code

The secondary widget checks the latest post, and if a post exists with stats (since reposts have no views), it displays the view count and a snippet of the post. For reposts, it’ll just show 0.

Documentation from Meta for this part is here:

Meta Threads Documentation

To fetch the latest threads:

https://graph.threads.net/v1.0/me/threads?fields=id,text,views&access_token=zzz

Then, retrieve stats for the latest thread:

https://graph.threads.net/v1.0/${postId}/insights?metric=likes,replies,views&access_token=zzz

Here’s the full code for the secondary widget:

Secondary Widget Code

And that’s it! After following these steps, you should have a working Threads widget.