コンテンツにスキップ

API クイックスタート

ANKK パブリック API は、単一のブランドスコープの API キー (spk_...) を使用して、プログラムからマルチチャネルのソーシャルメディア運用を管理できるようにする RESTful API です。


  • ベース URL: https://api.ankk.app
  • Swagger / インタラクティブドキュメント: https://api.ankk.app/v1/docs
  • OpenAPI JSON 仕様: https://api.ankk.app/v1/openapi.json

ヘルスチェックエンドポイントには認証ヘッダーは不要です。

Terminal window
curl https://api.ankk.app/v1/health
{
"service": "api-public",
"status": "ok"
}

2. API キーの取得とエクスポート

Section titled “2. API キーの取得とエクスポート”

Web アプリ (https://app.ankk.app) で ブランド設定 → API キー に移動してキーを生成し、それをエクスポートします。

Terminal window
export ANKK_API_KEY='spk_live_xxxxxxxxxxxxxxxx'

ブランドのステータスを確認し、接続されている SNS アカウントを一覧表示して、対象となる connection_id を取得します。

Terminal window
# 1. Inspect brand details
curl https://api.ankk.app/v1/brand \
-H "Authorization: Bearer $ANKK_API_KEY"
# 2. List connected SNS accounts
curl https://api.ankk.app/v1/brand/connections \
-H "Authorization: Bearer $ANKK_API_KEY"
const API_KEY = process.env.ANKK_API_KEY!;
const BASE_URL = 'https://api.ankk.app/v1';
const res = await fetch(`${BASE_URL}/brand/connections`, {
headers: {
'Authorization': `Bearer ${API_KEY}`,
},
});
const { items: connections } = await res.json();
console.log('Connected accounts:', connections);
const targetConnectionId = connections[0]?.id;
import os
import requests
API_KEY = os.environ['ANKK_API_KEY']
BASE_URL = 'https://api.ankk.app/v1'
headers = {'Authorization': f'Bearer {API_KEY}'}
response = requests.get(f'{BASE_URL}/brand/connections', headers=headers)
connections = response.json().get('items', [])
print(f'Connected accounts: {connections}')
target_connection_id = connections[0]['id']

重複実行を避けるために、クライアントで生成した idempotency_key を指定して公開リクエストを送信します。

Terminal window
curl -X POST "https://api.ankk.app/v1/brand/contents" \
-H "Authorization: Bearer $ANKK_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"connection_id": "conn_01jm8x9k2example",
"idempotency_key": "my-first-post-001",
"text": "Hello World from ANKK Public API! 🚀"
}'
const publishRes = await fetch(`${BASE_URL}/brand/contents`, {
method: 'POST',
headers: {
'Authorization': `Bearer ${API_KEY}`,
'Content-Type': 'application/json',
},
body: JSON.stringify({
connection_id: targetConnectionId,
idempotency_key: `post-${Date.now()}`,
text: 'Hello World from TypeScript! 🚀',
}),
});
const result = await publishRes.json();
console.log('Publish accepted (HTTP 202):', result);
import time
payload = {
'connection_id': target_connection_id,
'idempotency_key': f'post-{int(time.time())}',
'text': 'Hello World from Python! 🚀',
}
publish_res = requests.post(
f'{BASE_URL}/brand/contents',
headers={**headers, 'Content-Type': 'application/json'},
json=payload,
)
print('Publish outcome:', publish_res.json())

リクエストが成功すると HTTP 202 Acceptedcontent_id が返されます。配信ステータスは以下で確認してください。

Terminal window
curl https://api.ankk.app/v1/brand/contents/<content_id> \
-H "Authorization: Bearer $ANKK_API_KEY"