重要前提
安装AI Skills的关键前提是:必须科学上网,且开启TUN模式,这一点至关重要,直接决定安装能否顺利完成,在此郑重提醒三遍:科学上网,科学上网,科学上网。查看完整安装教程 →
threads-api by rawveg/skillsforge-marketplace
npx skills add https://github.com/rawveg/skillsforge-marketplace --skill threads-api为构建与 Threads 社交平台集成的应用程序,提供 Meta Threads API 开发的全面协助。
当您遇到以下情况时,应触发此技能:
// 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();
广告位招租
在这里展示您的产品或服务
触达数万 AI 开发者,精准高效
// 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)X-Business-Use-Case-Usage 标头此技能包含 references/ 目录下的全面文档:
当您需要有关特定 API 端点、参数或高级功能的详细信息时,请使用技能的参考文件。
首先理解身份验证流程 - 这是所有 Threads API 集成的基础。重点关注:
在基础知识的基础上,探索:
通过以下方式优化您的集成:
references/other.md 获取完整的 API 文档references/other.md 中找到身份验证错误(代码 190)
速率限制错误(代码 32)
媒体上传失败
media_type 参数Webhook 未收到事件
要使用更新的文档刷新此技能:
每周安装次数
52
代码仓库
GitHub Stars
28
首次出现
2026年1月24日
安全审计
安装于
codex45
opencode43
gemini-cli41
github-copilot41
cursor39
amp35
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)X-Business-Use-Case-Usage header in responsesThis 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:
Weekly Installs
52
Repository
GitHub Stars
28
First Seen
Jan 24, 2026
Security Audits
Gen Agent Trust HubPassSocketPassSnykWarn
Installed on
codex45
opencode43
gemini-cli41
github-copilot41
cursor39
amp35
agent-browser 浏览器自动化工具 - Vercel Labs 命令行网页操作与测试
172,600 周安装