{"id":13631201,"url":"https://github.com/m1guelpf/threads-re","last_synced_at":"2025-04-07T10:26:37.909Z","repository":{"id":179577412,"uuid":"663727385","full_name":"m1guelpf/threads-re","owner":"m1guelpf","description":"Reverse-engineering Instagram's Threads private APIs.","archived":false,"fork":false,"pushed_at":"2023-07-09T21:42:17.000Z","size":17,"stargazers_count":337,"open_issues_count":11,"forks_count":18,"subscribers_count":6,"default_branch":"main","last_synced_at":"2025-03-30T21:44:19.032Z","etag":null,"topics":["reverse-engineering","threads","threads-api","threads-net"],"latest_commit_sha":null,"homepage":"https://www.threads.net/t/Cua2iFqorJa/","language":null,"has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/m1guelpf.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null}},"created_at":"2023-07-08T00:54:49.000Z","updated_at":"2025-03-26T03:49:17.000Z","dependencies_parsed_at":"2024-01-13T15:37:14.299Z","dependency_job_id":"a22e4549-cf7c-437c-abca-55ab746c7463","html_url":"https://github.com/m1guelpf/threads-re","commit_stats":null,"previous_names":["m1guelpf/threads-re"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/m1guelpf%2Fthreads-re","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/m1guelpf%2Fthreads-re/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/m1guelpf%2Fthreads-re/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/m1guelpf%2Fthreads-re/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/m1guelpf","download_url":"https://codeload.github.com/m1guelpf/threads-re/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247634238,"owners_count":20970491,"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":["reverse-engineering","threads","threads-api","threads-net"],"created_at":"2024-08-01T22:02:15.144Z","updated_at":"2025-04-07T10:26:37.879Z","avatar_url":"https://github.com/m1guelpf.png","language":null,"funding_links":[],"categories":["Others"],"sub_categories":[],"readme":"# How Threads Works\n\nThis repository contains my notes and discoveries while reverse-engineering Threads app. Feel free to PR if you've found something new, or to build clients with this info (with credit ofc 😉).\n\n## Web (threads.net)\n\nThe web version of Threads is currently read-only, so not much can be learned about authentication or posting. It uses Meta's [Relay GraphQL Client](https://relay.dev) to talk to the backend (`threads.net/api/graphql`), which seems to be configured to disallow arbitrary queries. This leaves us limited to the existing queries found in the frontend's source:\n\n\u003e **Note**\n\u003e When querying the GraphQL backend, make sure to set an user-agent (seems like anything works here) and set the `x-ig-app-id` header to `238260118697367`.\n\n### Get profile data\n\n\u003e Doc ID: `23996318473300828`\n\u003e \n\u003e Variables: `userID` (the user's ID)\n\n```bash\ncurl --request POST \\\n  --url https://www.threads.net/api/graphql \\\n  --header 'user-agent: threads-client' \\\n  --header 'x-ig-app-id: 238260118697367' \\\n  --header 'content-type: application/x-www-form-urlencoded' \\\n  --data 'variables={\"userID\":\"314216\"}' \\\n  --data doc_id=23996318473300828\n```\n\n### Get profile posts\n\n\u003e Doc ID: `6232751443445612`\n\u003e \n\u003e Variables: `userID` (the user's ID)\n\n```bash\ncurl --request POST \\\n  --url https://www.threads.net/api/graphql \\\n  --header 'user-agent: threads-client' \\\n  --header 'x-ig-app-id: 238260118697367' \\\n  --header 'content-type: application/x-www-form-urlencoded' \\\n  --data 'variables={\"userID\":\"314216\"}' \\\n  --data doc_id=6232751443445612\n```\n\n### Get profile replies\n\n\u003e Doc ID: `6307072669391286`\n\u003e \n\u003e Variables: `userID` (the user's ID)\n\n```bash\ncurl --request POST \\\n  --url https://www.threads.net/api/graphql \\\n  --header 'user-agent: threads-client' \\\n  --header 'x-ig-app-id: 238260118697367' \\\n  --header 'content-type: application/x-www-form-urlencoded' \\\n  --data 'variables={\"userID\":\"314216\"}' \\\n  --data doc_id=6307072669391286\n```\n\n### Get a post\n\n\u003e Doc ID: `5587632691339264`\n\u003e \n\u003e Variables: `postID` (the post's ID)\n\n```bash\ncurl --request POST \\\n  --url https://www.threads.net/api/graphql \\\n  --header 'user-agent: threads-client' \\\n  --header 'x-ig-app-id: 238260118697367' \\\n  --header 'content-type: application/x-www-form-urlencoded' \\\n  --data 'variables={\"postID\":\"3138977881796614961\"}' \\\n  --data doc_id=5587632691339264\n```\n\n### Get a list of users who liked a post\n\n\u003e Doc ID: `9360915773983802`\n\u003e \n\u003e Variables: `mediaID` (the post's ID)\n\n```bash\ncurl --request POST \\\n  --url https://www.threads.net/api/graphql \\\n  --header 'user-agent: threads-client' \\\n  --header 'x-ig-app-id: 238260118697367' \\\n  --header 'content-type: application/x-www-form-urlencoded' \\\n  --data 'variables={\"mediaID\":\"3138977881796614961\"}' \\\n  --data doc_id=9360915773983802\n```\n\n## Mobile Apps\n\n### Authentication\n\n\u003e **Warning**\n\u003e This endpoint currently only works for accounts without 2FA enabled.\n\nThe mobile apps use Meta's Bloks framework ([originally built for Instagram Lite](https://thenewstack.io/instagram-lite-is-no-longer-a-progressive-web-app-now-a-native-app-built-with-bloks/)) for authentication.\n\nThe bloks versioning ID for threads is `00ba6fa565c3c707243ad976fa30a071a625f2a3d158d9412091176fe35027d8`. Bloks also requires you to provide a device id (of shape `ios-RANDOM` | `android-RANDOM`, `RANDOM` being a random set of 13 chars).\n\n```bash\ncurl --request POST \\\n  --url 'https://i.instagram.com/api/v1/bloks/apps/com.bloks.www.bloks.caa.login.async.send_login_request/' \\\n  --header 'user-agent: Barcelona 289.0.0.77.109 Android' \\\n  --header 'sec-fetch-site: same-origin' \\\n  --header 'content-type: application/x-www-form-urlencoded; charset=UTF-8' \\\n  --data 'params={\"client_input_params\":{\"password\":\"$PASSWORD\",\"contact_point\":\"$USERNAME\",\"device_id\":\"$DEVICE_ID\"},\"server_params\":{\"credential_type\":\"password\",\"device_id\":\"$DEVICE_ID\"}}' \\\n  --data 'bloks_versioning_id=00ba6fa565c3c707243ad976fa30a071a625f2a3d158d9412091176fe35027d8'\n```\n\nThis request returns a big JSON payload. Your token will be immediately after the string `Bearer IGT:2:`, and should be 160 characters long.\n\n### Creating a text post\n\n```bash\ncurl --request POST \\\n  --url 'https://i.instagram.com/api/v1/media/configure_text_only_post/' \\\n  --header 'content-type: application/x-www-form-urlencoded; charset=UTF-8' \\\n  --header 'user-agent: Barcelona 289.0.0.77.109 Android' \\\n  --header 'authorization: Bearer IGT:2:$TOKEN' \\\n  --header 'sec-fetch-site: same-origin' \\\n  --data 'signed_body=SIGNATURE.{\"publish_mode\":\"text_post\",\"text_post_app_info\":\"{\\\"reply_control\\\":0}\",\"timezone_offset\":\"0\",\"source_type\":\"4\",\"_uid\":\"$USER_ID\",\"device_id\":\"$DEVICE_ID\",\"caption\":\"$POST_TEXT\",\"device\":{\"manufacturer\":\"OnePlus\",\"model\":\"ONEPLUS+A3003\",\"android_version\":26,\"android_release\":\"8.1.0\"}}'\n```\n\n## Misc\n\n### How to get a profile's id from their username?\n\nThreads uses the same ID system used by Instagram. The best approach to convert from username to id seems to be requesting the user's instagram page (`instagram.com/:username`) and manually parsing the response HTML. For other methods, see [this StackOverflow question](https://stackoverflow.com/questions/11796349/instagram-how-to-get-my-user-id-from-username).\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fm1guelpf%2Fthreads-re","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fm1guelpf%2Fthreads-re","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fm1guelpf%2Fthreads-re/lists"}