Token导航 LogoToken导航

Agent Skill · 开发规范

social-media-api-best-practices(social media API 最佳实践)

用于辅助 API 设计、接口文档、请求响应结构和服务集成说明。它适合让 Agent 梳理 endpoint、生成 OpenAPI 草稿、检查字段命名、整理错误码或辅助前后端联调。使用时需要确认真实业务语义、鉴权方式、分页和错误处理规则;涉及生成接口文档时,应避免凭空补字段,最好从现有代码、schema 或接口样例中提取事实。

social-media-api-best-practices 是开发规范类 Agent Skill,可用宿主为 Codex、Claude、Cursor、Gemini CLI,通过GitHub 仓库获取,权限为接触敏感数据;许可证为 MIT,暂无第三方扫描结果,按安装量在开发规范类的 1,265 个 Skill 里排第 1,253。

总安装 119周安装 5GitHub Stars 公开资料未说明下载 42核验 2026-05-01

安装说明

本站只整理中文说明,不托管安装包,也不代用户安装。
GitHub
许可证
MIT

安装方式

通过对话安装

复制提示词发给支持本地命令或 Skills 的 AI 助手,先确认命令和权限,再让它执行。

请帮我安装这个 Agent Skill:social-media-api-best-practices(social media API 最佳实践)
来源仓库:https://github.com/mikipalet/social-media-api-best-practices
仓库路径:skills/social-media-api-best-practices
安装命令:
npx skills add mikipalet/social-media-api-best-practices --skill "social-media-api-best-practices"
安装前请先检查当前环境是否支持对应 CLI,并向我确认将要执行的命令、安装目录、联网范围和文件读写权限;确认后再执行。

命令行安装

复制命令到本机终端执行。该命令会通过 npx skills 从第三方来源获取 Skill;本站只展示命令,不托管安装包,也不自动执行。

AgentSkills.tonpx skills
npx skills add mikipalet/social-media-api-best-practices --skill "social-media-api-best-practices"

这个 Skill 是做什么的

开发规范类 Skill 用来统一代码风格、目录结构和评审口径,产出多为检查清单或改写建议。

用于辅助 API 设计、接口文档、请求响应结构和服务集成说明。适用于社交媒体 API 的设计与开发,帮助梳理 endpoint、生成 OpenAPI 草稿、检查字段命名、整理错误码或辅助前后端联调。

通过 npx skills add mikipalet/social-media-api-best-practices --skill "social-media-api-best-practices" 命令安装。

使用时需要确认真实业务语义、鉴权方式、分页和错误处理规则;涉及生成接口文档时,应避免凭空补字段,最好从现有代码、schema 或接口样例中提取事实。适用宿主包括 Codex、Claude、Cursor、Gemini CLI,接入前应确认版本、权限和运行环境要求。

来源仓库内路径:skills/social-media-api-best-practices

上手步骤

4 步
  1. 1

    确认自己的宿主工具

    公开资料标注支持 Codex、Claude、Cursor、Gemini CLI;先确认自己用的是其中之一,再按对应工具的 Skills 目录放置。

  2. 2

    拿到安装命令

    可以直接复制的命令是 npx skills add mikipalet/social-media-api-best-practices --skill "social-media-a…;命令里的占位符换成自己的路径或密钥再执行。

  3. 3

    安装后重启宿主

    命令执行完要完全退出宿主工具再打开,让新装的 Skill 被重新扫描到,否则列表里可能看不到。

  4. 4

    按最小权限试用

    它需要接触敏感数据,先在测试目录或测试账号里跑,确认没问题再放到正式项目。

常见问题

6 条

social-media-api-best-practices 怎么安装?

在终端执行 npx skills add mikipalet/social-media-api-best-practices --skill "social-media-api-best-pr…。装完完全退出宿主工具再打开,让它重新扫描本地 Skill。

social-media-api-best-practices 支持哪些 AI 工具?

公开资料标注支持 Codex、Claude、Cursor、Gemini CLI。其他工具只要能读取本地 Skill 目录,一般也能手动放进去,但要自己确认触发方式是否一致。

social-media-api-best-practices 需要什么权限?

权限级别是接触敏感数据。该 Skill 可能接触密钥、Token、环境变量或敏感配置,应进入高风险复核队列,默认不自动发布。

social-media-api-best-practices 是免费的吗?

来源标注的许可证是 MIT。本站不代收任何费用,也不托管安装包;能否商用、要不要署名,以许可证原文为准。

social-media-api-best-practices 用的人多吗?

公开数据是累计安装 119 次,近一周安装 5 次,下载 42 次。这些数字来自第三方目录统计,只能当作热度参考,不代表质量或安全性。

social-media-api-best-practices 安全吗?

没有查到第三方扫描结果,安全性无法从公开资料判断,安装前请自行审查源码、依赖和命令行为。

值得选的地方和要先想清楚的地方

值得选的地方

  • 同时适配 4 种工具,换客户端不用重新找替代品。
  • 许可证明确为 MIT,商用和分发边界好判断。

先想清楚的地方

  • 需要接触敏感数据,装到常用环境前要先评估影响面。
  • 没有第三方扫描结果,安全性只能靠自己读源码判断。
  • 第三方目录整理,版本更新和行为细节以来源仓库为准。

适不适合你

更适合

  • 已经在用 Codex,想直接扩展它能力的人。
  • 需要处理开发规范类任务、又不想每次都手写提示词的人。

不太适合

  • 环境里有大量密钥、凭证,不方便给第三方 Skill 读取的人。
  • 要求有安全扫描结论才肯安装的团队。
  • 需要厂商级技术支持和 SLA 的生产系统。

开发规范类 Skill 对比

6 个同类
Skill总安装GitHub 星权限许可证扫描
vercel-react-best-practices

Vercel React 最佳实践 · Codex、Claude

8,490,72025,918操作浏览器MIT通过
web-design-guidelines

网页设计指南 · Codex、Claude

6,686,01625,885需要联网MIT有提醒
remotion-best-practices

Remotion 最佳实践 · Codex、Claude

6,505,6323,027操作浏览器MIT有提醒
supabase-postgres-best-practices

Supabase Postgres 最佳实践 · Codex、Claude

3,175,5232,030需要联网MIT通过
next-best-practices

Next.js 最佳实践 · Codex、Claude

1,848,240841操作浏览器MIT通过
social-media-api-best-practices

social media API 最佳实践 · 本页

119—接触敏感数据MIT未收录

按安装量取同分类前几名;数字来自第三方目录统计,只作热度参考,不代表质量结论。

SKILL.md 原文

Social Media API Best Practices

Battle-tested patterns from scheduling 1M+ posts across 13 platforms.


1. Authentication Patterns

OAuth 2.0 Platforms

Instagram (Meta Graph API)

  • Two-step token exchange: short-lived (1 hour) → long-lived (60 days)
  • Use auth_type: 'rerequest' to force permission re-prompts
  • Exchange endpoint: ig_exchange_token grant type
  • Scopes: instagram_business_basic, instagram_business_content_publish, instagram_business_manage_messages

Twitter/X (PKCE Required)

  • PKCE with S256 code challenge is mandatory
  • Embed code verifier in state: ${state}-cv_${codeVerifier}
  • Scopes: tweet.read, tweet.write, users.read, offline.access, media.write
  • Access token: 2 hours, refresh token: long-lived
function generateCodeVerifier(): string {
  return crypto.randomBytes(32).toString('base64url');
}

function generateCodeChallenge(verifier: string): string {
  return crypto.createHash('sha256').update(verifier).digest('base64url');
}

function extractCodeVerifierFromState(state: string): string {
  const match = state.match(/-cv_(.+)$/);
  return match ? match[1] : '';
}

TikTok

  • Full UX compliance required for API audit approval
  • Must show: privacy_level selector, comment/duet/stitch toggles
  • Commercial content disclosure mandatory
  • Scopes: user.info.basic, video.publish, video.upload

LinkedIn

  • Always include header: X-RestLi-Protocol-Version: 2.0.0
  • API version header: LinkedIn-Version: 202511
  • Access token: 60 days, refresh token: 365 days
  • Supports both personal (urn:li:person:) and organization (urn:li:organization:) posts

YouTube

  • Requires access_type=offline AND prompt=consent for refresh tokens
  • Supports both user channels and brand accounts
  • Scopes: youtube.upload, youtube, yt-analytics.readonly

Facebook

  • Page access tokens are separate from user tokens
  • Exchange user token for page token via /me/accounts
  • Supports scheduled publishing via scheduled_publish_time

Threads

  • Similar to Instagram (Meta), 2-step token exchange
  • Use th_exchange_token grant type
  • Scopes: threads_basic, threads_content_publish, threads_manage_replies

Pinterest

  • Basic auth with base64 encoding
  • Scopes: pins:read, pins:write, boards:read, boards:write

Google Business Profile

  • Google OAuth with business.manage scope
  • Uses My Business v4 API (deprecated but functional)

Reddit

  • OAuth with duration=permanent for long-lived tokens
  • Strict user-agent requirement - Reddit enforces descriptive user agents
  • Scopes: identity, submit, read, mysubreddits, privatemessages
const headers = {
  'User-Agent': 'YourApp/1.0 by /u/YourUsername'
};

Non-OAuth Platforms

Bluesky (AT Protocol)

  • No traditional OAuth - uses DIDs (Decentralized Identifiers)
  • Authentication via accessJwt + refreshJwt from AT Protocol
  • PDS (Personal Data Server) resolution required
  • Auto-refresh on ExpiredToken error
// Bluesky authentication
const session = await agent.login({
  identifier: 'user.bsky.social',
  password: 'app-password'
});
// session contains: accessJwt, refreshJwt, did, handle

Snapchat

  • Basic auth, allowlist-only (requires Snapchat dev team approval)
  • Limited public API - profile API focus

Telegram

  • Bot token only - no OAuth flow
  • Token format: BOT_ID:SECRET
  • No user authentication, bot must be added to chat/channel

2. Rate Limiting Strategies

Platform-Specific Limits

PlatformKey LimitStrategy
Instagram100 posts/day per accountQueue and spread
TikTok5 pending uploads/24hWait for processing
Twitter3-tier limits (app + user + endpoint)Check all three
LinkedInGenerous general, strict bulkBatch carefully
YouTubeDaily upload quota per channelMonitor quota
Reddit60 requests/minuteRespect headers
ThreadsAggressive rate limitingFails fast

Twitter's Three-Tier Rate Limits

Twitter has THREE levels of limits - check all:

  1. App-level 24-hour limit (most restrictive)
  2. User-level 24-hour limit
  3. Endpoint-specific rate limit
function parseRateLimitHeaders(headers: Headers) {
  return {
    // Endpoint limits
    remaining: parseInt(headers.get('x-rate-limit-remaining') || '0'),
    reset: parseInt(headers.get('x-rate-limit-reset') || '0'),
    // App-level 24h limits
    appRemaining: parseInt(headers.get('x-app-limit-24hour-remaining') || '0'),
    appReset: parseInt(headers.get('x-app-limit-24hour-reset') || '0'),
    // User-level 24h limits
    userRemaining: parseInt(headers.get('x-user-limit-24hour-remaining') || '0'),
    userReset: parseInt(headers.get('x-user-limit-24hour-reset') || '0'),
  };
}

Exponential Backoff Pattern

async function withRetry<T>(
  fn: () => Promise<T>,
  maxRetries = 3,
  baseDelay = 5000
): Promise<T> {
  for (let attempt = 0; attempt <= maxRetries; attempt++) {
    try {
      return await fn();
    } catch (error) {
      if (!isRetryableError(error) || attempt === maxRetries) throw error;
      const delay = Math.min(baseDelay * Math.pow(2, attempt), 30000);
      await sleep(delay);
    }
  }
  throw new Error('Max retries exceeded');
}

function isRetryableError(error: any): boolean {
  const status = error.status || error.statusCode;
  return [429, 500, 502, 503].includes(status);
}

3. Media Requirements

Complete Platform Limits

PlatformMax ImageMax VideoAspect RatioSpecial
Instagram8MB100MB stories, 300MB reels4:5 to 1.91:1 feed, 9:16 stories10 carousel items
TikTok50MB4GB, 3s-10min9:16 strict35 photo carousel
Twitter5MB512MB, 2min 20sFlexible1-4 images
LinkedIn8MB5GBFlexible20 image carousel
YouTube2MB thumbnail256GB16:9 preferredResumable upload
Facebook10MB4GBFlexible10 multi-image
Threads8MB1GB, 5min9:16 vertical10 carousel
Pinterest32MB2GBFlexibleRequires cover image
Bluesky1MB50MB, 3minFlexibleAT Protocol
Snapchat20MB500MB9:16AES encryption
Google Business5MBN/AFlexibleImages only
Reddit20MBN/AFlexibleVia URL
Telegram10MB50MBFlexible4096 char limit

Golden Rule: Stream Large Files

Never load entire files into memory:

// BAD - loads entire file into memory
const buffer = await fetch(url).then(r => r.arrayBuffer());

// GOOD - streams directly
const response = await fetch(url);
await uploadToPlatform(response.body); // Pass the stream

Problematic Media Sources

These hosts return HTML or timeout instead of direct media:

const PROBLEMATIC_HOSTS = [
  'drive.google.com',
  'docs.google.com',
  'dropbox.com',
  'onedrive.live.com',
  '1drv.ms'
];

// Solution: Re-host to your own storage first
if (PROBLEMATIC_HOSTS.some(h => url.includes(h))) {
  url = await reHostToStorage(url);
}

Dropbox URL Fix

function fixDropboxUrl(url: string): string {
  if (url.includes('dropbox.com') && url.includes('dl=0')) {
    return url.replace('dl=0', 'dl=1');
  }
  return url;
}

4. Video Upload Patterns

Chunked Upload (Twitter)

async function chunkedUpload(videoBuffer: Buffer, mediaType: string) {
  const CHUNK_SIZE = 4 * 1024 * 1024; // 4MB chunks

  // INIT
  const initRes = await api.post('/media/upload', {
    command: 'INIT',
    total_bytes: videoBuffer.length,
    media_type: mediaType
  });
  const mediaId = initRes.media_id_string;

  // APPEND chunks
  for (let i = 0; i < Math.ceil(videoBuffer.length / CHUNK_SIZE); i++) {
    const chunk = videoBuffer.slice(i * CHUNK_SIZE, (i + 1) * CHUNK_SIZE);
    await api.post('/media/upload', {
      command: 'APPEND',
      media_id: mediaId,
      media: chunk.toString('base64'),
      segment_index: i
    });
  }

  // FINALIZE
  await api.post('/media/upload', {
    command: 'FINALIZE',
    media_id: mediaId
  });

  // Poll for processing
  await pollProcessingStatus(mediaId);

  return mediaId;
}

Resumable Upload (YouTube)

YouTube supports resumable uploads for reliability with large files. Use the youtube-chunked-upload module or implement the resumable upload protocol.

Processing Status Polling

async function pollProcessingStatus(mediaId: string, maxWaitMs = 300000) {
  const startTime = Date.now();

  while (Date.now() - startTime < maxWaitMs) {
    const status = await api.get(`/media/upload?command=STATUS&media_id=${mediaId}`);

    if (status.processing_info?.state === 'succeeded') return;
    if (status.processing_info?.state === 'failed') {
      throw new Error(status.processing_info.error?.message || 'Processing failed');
    }

    const checkAfter = (status.processing_info?.check_after_secs || 5) * 1000;
    await sleep(checkAfter);
  }

  throw new Error('Processing timeout');
}

5. Error Handling

Error Categorization

type ErrorType = 'refresh-token' | 'retry' | 'user-error';

function categorizeError(platform: string, error: any): ErrorType {
  if (isTokenError(error)) return 'refresh-token';
  if (isTemporaryError(error)) return 'retry';
  return 'user-error';
}

Instagram Error Codes

CodeMeaningAction
2207001Spam detectedUser error
2207003Media download timeoutRetry
2207004Image too large (>8MB)Compress
2207006Media not foundUser error
2207026Unsupported video formatRe-encode
2207042100 posts/day exceededWait 24h
2207050User restrictedUser error
2207051Blocked (but may have posted!)Verify
2207052Media fetch failedUse direct URLs

The Instagram 2207051 Edge Case

Instagram's anti-spam sometimes returns "blocked" but actually publishes:

async function handleInstagram2207051(accountId: string) {
  await sleep(5000);

  const recentMedia = await getRecentMedia(accountId);
  const justPosted = recentMedia.find(m =>
    Date.now() - new Date(m.timestamp).getTime() < 60000
  );

  if (justPosted) {
    return { success: true, postId: justPosted.id };
  }
  throw new Error('Post actually failed');
}

TikTok Error Codes

CodeMeaningAction
access_token_invalidToken expiredRefresh
scope_not_authorizedMissing permissionReconnect
rate_limit_exceededToo many requestsRetry
spam_risk_*Content flaggedUser error
file_format_check_failedInvalid formatUser error
unaudited_client_can_only_post_to_privateDev modePrivate only

Twitter/X Error Codes

CodeMeaningAction
invalid_grantToken revokedReconnect
usage-cappedRate limitedRetry
duplicateSame content existsUser error
186Tweet too longUser error

Bluesky Error Codes

CodeMeaningAction
ExpiredTokenJWT expiredAuto-refresh
InvalidTokenBad tokenReconnect
XRPCNotSupportedApp password lacks DMUse full auth

Reddit Error Codes

CodeMeaningAction
invalid tokenExpiredRefresh
not allowed to submitSubreddit restrictionUser error
RATELIMITToo fastRetry with delay
NO_LINKSLinks not allowedUser error

Telegram Error Codes

CodeMeaningAction
message too long>4096 charsTruncate
chat not foundInvalid chat IDUser error
bot was blockedUser blocked botUser error

6. Platform Quirks

JavaScript Large Integer IDs (Instagram/Facebook)

Instagram IDs exceed MAX_SAFE_INTEGER (17+ digits):

function safeJsonParse(text: string) {
  // Wrap large integers in quotes before parsing
  const safe = text.replace(/"id"\s*:\s*(\d{15,})/g, '"id":"$1"');
  return JSON.parse(safe);
}

Twitter Character Counting

function countTwitterCharacters(text: string): number {
  let count = 0;

  // URLs always count as 23 characters
  const urlRegex = /https?:\/\/[^\s]+/g;
  const urls = text.match(urlRegex) || [];
  const textWithoutUrls = text.replace(urlRegex, '');

  count += urls.length * 23;

  // Emojis and CJK count as 2
  for (const char of textWithoutUrls) {
    count += char.match(/[\u{1F600}-\u{1F64F}]|[\u4e00-\u9fff]/u) ? 2 : 1;
  }

  return count;
}

Twitter Character Limits by Tier

TierLimit
Free280
Premium4,000
Premium+25,000

LinkedIn Text Escaping

Reserved characters: | {} @ [] () < > # \ * _ ~

function escapeLinkedInText(text: string): string {
  const reserved = /[|{}@\[\]()<>#\\*_~]/g;

  return text.replace(reserved, (match, offset) => {
    if (isInsideMention(text, offset)) return match;
    if (isInsideHashtag(text, offset)) return match;
    return '\\' + match;
  });
}

TikTok UX Compliance Requirements

TikTok requires full UX compliance for API audit:

  • User must manually select privacy level (no defaults)
  • Must show comment/duet/stitch toggles
  • Commercial content disclosure with user confirmation
  • Content preview before upload
  • Express consent declaration

Reddit User-Agent Requirement

Reddit strictly enforces descriptive user agents:

// BAD - will be blocked
headers['User-Agent'] = 'axios/1.0';

// GOOD - descriptive format
headers['User-Agent'] = 'MyApp/1.0 (by /u/developer_username)';

Telegram HTML Subset

Only these HTML tags are supported:

<b>, <strong>       <!-- bold -->
<i>, <em>           <!-- italic -->
<u>                 <!-- underline -->
<s>, <strike>, <del><!-- strikethrough -->
<code>              <!-- monospace -->
<pre>               <!-- code block -->
<a href="...">      <!-- link -->
<tg-spoiler>        <!-- spoiler -->
<blockquote>        <!-- quote -->

7. Special Protocols

AT Protocol (Bluesky)

Bluesky uses AT Protocol, not OAuth:

Key Concepts:

  • DID (Decentralized Identifier): User's permanent ID (e.g., did:plc:abc123)
  • PDS (Personal Data Server): Where user data lives
  • Handle: Human-readable name (e.g., user.bsky.social)

Rich Text Facets:

Mentions and links use byte-offset positioning:

function createFacets(text: string): Facet[] {
  const facets: Facet[] = [];
  const encoder = new TextEncoder();

  // Find mentions
  const mentionRegex = /@([a-zA-Z0-9.-]+)/g;
  let match;

  while ((match = mentionRegex.exec(text)) !== null) {
    const beforeText = text.slice(0, match.index);
    const byteStart = encoder.encode(beforeText).length;
    const byteEnd = byteStart + encoder.encode(match[0]).length;

    facets.push({
      index: { byteStart, byteEnd },
      features: [{
        $type: 'app.bsky.richtext.facet#mention',
        did: await resolveDid(match[1])
      }]
    });
  }

  return facets;
}

Snapchat AES-256-CBC Encryption

Snapchat requires media encryption before upload:

import crypto from 'crypto';

function encryptForSnapchat(buffer: Buffer): {
  encrypted: Buffer;
  key: string;
  iv: string;
} {
  const key = crypto.randomBytes(32); // 256 bits
  const iv = crypto.randomBytes(16);  // 128 bits

  const cipher = crypto.createCipheriv('aes-256-cbc', key, iv);
  const encrypted = Buffer.concat([
    cipher.update(buffer),
    cipher.final()
  ]);

  return {
    encrypted,
    key: key.toString('base64'),
    iv: iv.toString('base64')
  };
}

8. Quick Debugging Checklist

When a post fails:

  1. Check token validity - Is the access token expired?
  2. Check rate limits - Hit daily/hourly limits?
  3. Check media URL - Can the platform fetch it directly?
  4. Check media specs - Right format, size, dimensions, aspect ratio?
  5. Check the 2207051 case - Did it post despite the error?
  6. Check account status - Is the account restricted?
  7. Check subreddit rules - (Reddit) Links allowed? Flair required?
  8. Check user-agent - (Reddit) Descriptive enough?
  9. Check bot permissions - (Telegram) Bot in chat with send rights?

9. Recommended Architecture

your-app/
├── lib/
│   ├── platforms/
│   │   ├── base.ts           # Abstract base class
│   │   ├── instagram.ts
│   │   ├── tiktok.ts
│   │   ├── twitter.ts
│   │   ├── bluesky.ts        # AT Protocol
│   │   ├── snapchat.ts       # With encryption
│   │   └── ...
│   ├── utils/
│   │   ├── rate-limiter.ts
│   │   ├── media-handler.ts
│   │   ├── error-mapper.ts
│   │   └── encryption.ts     # For Snapchat
│   └── queue/
│       └── scheduler.ts

10. Platform Comparison Matrix

FeatureInstagramTikTokTwitterLinkedInYouTubeFacebookThreadsPinterestBlueskySnapchatGBPRedditTelegram
OAuth2-stepStandardPKCEStandardGoogleStandard2-stepBasicAT ProtoBasicGoogleStandardBot Token
Token Life60d2y+2h+refresh365d refresh1y60d+60dN/AAutoN/A1yPermanentN/A
VideoYesYesYesYesYesYesYesYesYesYesNoNoYes
Carousel1035420No1010No4NoNoGalleryAlbum 10
SchedulingAPIDraftNoAPIAPIAPIAPINoAPINoNoNoNo
DMsYesNoYesYesNoYesNoNoYesYesNoYesYes
AnalyticsYesYesYesYesYesYesYesYesNoNoLimitedNoLimited

About This Guide

This guide is maintained by Late, built from real patterns learned while scheduling 1M+ posts across all 13 platforms.

Every error code, edge case, and quirk documented here comes from production experience. The Instagram 2207051 gotcha? We discovered it after hours of debugging. The Snapchat encryption requirement? Learned the hard way.

Building a social media app? If you'd rather not implement and maintain all these integrations yourself, Late's API handles the complexity for you: OAuth, media processing, rate limits, error handling, and scheduling across all 13 platforms with a single integration.


*Maintained by Late - Social Media Scheduling API for Developers*

平台分布

OpenCode

38%
按下载量换算16

Cursor

26.38%
按下载量换算11

github-copilot

16.2%
按下载量换算7

Claude Code

7.68%
按下载量换算3

安全审计

暂无安全审计结果可展示。

权限和风险

接触敏感数据

该 Skill 可能接触密钥、Token、环境变量或敏感配置,应进入高风险复核队列,默认不自动发布。

安装前确认

本站仅展示第三方公开信息,不托管安装包,不提供自动安装或运行环境。安装前应自行审查源码、依赖和命令行为。目前只有一个公开来源,建议同时核对源仓库。

继续浏览同类 Skills