基于 SOC 职业分类
用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
直接命令不会经过审查 Prompt;运行前请先检查来源。
npx skills add https://github.com/nathfavour/threader --skill threads-api命令会保持在同一行。复制前请横向滚动并检查完整内容。
想先保存到本地?可下载 SkillsMP 当前能够提供的文件。
正在显示 SKILL.md
Use when working on anything Ota-specific: creating, refining, reviewing, or explaining Ota contracts (`ota.yaml`), modeling execution governance for humans and AI agents, working through `ota doctor` / `ota up` / `ota run`, handling agent safety surfaces, Ota Studio boundaries, or when deciding whether a problem belongs in the repo contract or in Ota itself.
Guidelines on Meta App Review, Live/Development modes, and resolving keyword search permissions on the Threads Graph API.
| name | threads-api |
| description | Threads API Documentation |
Comprehensive assistance with Meta's Threads API development for building applications that integrate with the Threads social platform.
This skill should be triggered when you are:
// Step 1: Redirect user to authorization endpoint
const authUrl = `https://threads.net/oauth/authorize?client_id=${CLIENT_ID}&redirect_uri=${REDIRECT_URI}&scope=threads_basic,threads_content_publish&response_type=code`;
// Step 2: Exchange authorization code for access token
const response = await fetch('https://graph.threads.net/oauth/access_token', {
method: 'POST',
headers: { 'Content-Type': 'application/x-www-form-urlencoded' },
body: new URLSearchParams({
client_id: CLIENT_ID,
client_secret: CLIENT_SECRET,
grant_type: 'authorization_code',
redirect_uri: REDIRECT_URI,
code: authorizationCode
})
});
const { access_token } = await response.json();
// Create a simple text post
const response = await fetch(`https://graph.threads.net/v1.0/me/threads`, {
method: 'POST',
headers: {
'Content-Type': 'application/json',
'Authorization': `Bearer ${accessToken}`
},
body: JSON.stringify({
media_type: 'TEXT',
text: 'Hello from Threads API! 🎉'
})
});
const data = await response.json();
console.log('Post ID:', data.id);
import requests
# Upload and publish an image
url = "https://graph.threads.net/v1.0/me/threads"
headers = {"Authorization": f"Bearer {access_token}"}
data = {
"media_type": "IMAGE",
"image_url": "https://example.com/image.jpg",
"text": "Check out this image! #API"
}
response = requests.post(url, headers=headers, json=data)
post_id = response.json()["id"]
print(f"Posted image with ID: {post_id}")
// Step 1: Create a video container
const container = await fetch(`https://graph.threads.net/v1.0/me/threads`, {
method: 'POST',
headers: { 'Authorization': `Bearer ${accessToken}` },
body: JSON.stringify({
media_type: 'VIDEO',
video_url: 'https://example.com/video.mp4',
text: 'Check out this video!'
})
});
const { id: containerId } = await container.json();
// Step 2: Publish the container
await fetch(`https://graph.threads.net/v1.0/me/threads_publish`, {
method: 'POST',
headers: { 'Authorization': `Bearer ${accessToken}` },
body: JSON.stringify({ creation_id: containerId })
});
import requests
# Get authenticated user's profile
url = f"https://graph.threads.net/v1.0/me"
headers = {"Authorization": f"Bearer {access_token}"}
params = {
"fields": "id,username,name,threads_profile_picture_url,threads_biography"
}
response = requests.get(url, headers=headers, params=params)
profile = response.json()
print(f"Username: {profile['username']}")
print(f"Bio: {profile['threads_biography']}")
// Get user's recent threads with pagination
const response = await fetch(
`https://graph.threads.net/v1.0/me/threads?fields=id,text,timestamp,media_url&limit=25`,
{
headers: { 'Authorization': `Bearer ${accessToken}` }
}
);
const { data, paging } = await response.json();
data.forEach(thread => {
console.log(`${thread.timestamp}: ${thread.text}`);
});
// Use paging.next for next page
import requests
# Create a carousel with multiple images
url = "https://graph.threads.net/v1.0/me/threads"
headers = {"Authorization": f"Bearer {access_token}"}
data = {
"media_type": "CAROUSEL",
"children": [
{"media_type": "IMAGE", "image_url": "https://example.com/img1.jpg"},
{"media_type": "IMAGE", "image_url": "https://example.com/img2.jpg"},
{"media_type": "IMAGE", "image_url": "https://example.com/img3.jpg"}
],
"text": "Swipe through these images! 📸"
}
response = requests.post(url, headers=headers, json=data)
carousel_id = response.json()["id"]
// Get insights for a specific thread
const threadId = '123456789';
const response = await fetch(
`https://graph.threads.net/v1.0/${threadId}/insights?metric=views,likes,replies,reposts`,
{
headers: { 'Authorization': `Bearer ${accessToken}` }
}
);
const { data } = await response.json();
data.forEach(metric => {
console.log(`${metric.name}: ${metric.values[0].value}`);
});
import requests
def make_threads_request(url, access_token, method='GET', **kwargs):
"""Robust error handling for Threads API requests"""
headers = kwargs.pop('headers', {})
headers['Authorization'] = f"Bearer {access_token}"
try:
response = requests.request(method, url, headers=headers, **kwargs)
response.raise_for_status()
return response.json()
except requests.exceptions.HTTPError as e:
error_data = e.response.json()
error_code = error_data.get('error', {}).get('code')
error_msg = error_data.get('error', {}).get('message')
if error_code == 190:
raise Exception(f"Invalid access token: {error_msg}")
elif error_code == 32:
raise Exception(f"Rate limit exceeded: {error_msg}")
else:
raise Exception(f"API Error {error_code}: {error_msg}")
except requests.exceptions.RequestException as e:
raise Exception(f"Network error: {str(e)}")
threads_basic, threads_content_publish, threads_manage_insights)Threads API rate limits are calculated based on a rolling 24-hour window and are unique to each app-user pair.
4,800 × Number of Impressions.All media must be hosted on a publicly accessible server so Meta's servers can fetch the content during the container creation process.
You can programmatically check a profile's current rate limit status by querying the GET /{threads-user-id}/threads_publishing_limit endpoint. This returns quota_usage and quota_total for the current 24-hour window.
This skill includes comprehensive documentation in references/:
Use the skill's reference files when you need detailed information about specific API endpoints, parameters, or advanced features.
Start by understanding the authentication flow - this is the foundation of all Threads API integrations. Focus on:
Build on the basics by exploring:
Optimize your integration with:
references/other.md for complete API documentationSecurity
Performance
User Experience
Content Publishing
references/other.mdAuthentication Errors (Code 190)
Rate Limit Errors (Code 32)
Media Upload Failures
Webhook Not Receiving Events
To refresh this skill with updated documentation: