API 빠른 시작
앙크 Public API는 단일 API 키(spk_...)로 브랜드 자산과 6대 SNS 채널을 통합 제어할 수 있는 RESTful API입니다.
📌 기본 엔드포인트 정보
섹션 제목: “📌 기본 엔드포인트 정보”- Base URL:
https://api.ankk.app - Swagger / API Docs:
https://api.ankk.app/v1/docs - OpenAPI JSON Spec:
https://api.ankk.app/v1/openapi.json
1. 서비스 상태 확인 (Health Check)
섹션 제목: “1. 서비스 상태 확인 (Health Check)”상태 확인 경로는 별도의 인증 헤더 없이 누구나 호출할 수 있습니다.
curl https://api.ankk.app/v1/health{ "service": "api-public", "status": "ok"}2. API 키 발급 및 설정
섹션 제목: “2. API 키 발급 및 설정”웹 앱(https://app.ankk.app)의 브랜드 설정 → API 키 탭에서 Public API 키를 발급받아 환경 변수로 설정합니다:
export ANKK_API_KEY='spk_live_xxxxxxxxxxxxxxxx'3. 브랜드 및 SNS 연결 조회
섹션 제목: “3. 브랜드 및 SNS 연결 조회”발급된 API 키가 바인딩된 브랜드 정보와 발행 대상이 될 SNS 연결 계정 목록을 조회합니다.
cURL
섹션 제목: “cURL”# 1. 브랜드 정보 확인curl https://api.ankk.app/v1/brand \ -H "Authorization: Bearer $ANKK_API_KEY"
# 2. 연동된 SNS 연결 목록 조회curl https://api.ankk.app/v1/brand/connections \ -H "Authorization: Bearer $ANKK_API_KEY"TypeScript / JavaScript
섹션 제목: “TypeScript / JavaScript”const API_KEY = process.env.ANKK_API_KEY;if (!API_KEY) throw new Error('Set ANKK_API_KEY');const BASE_URL = 'https://api.ankk.app/v1';
// SNS 연결 목록 조회const res = await fetch(`${BASE_URL}/brand/connections`, { headers: { Authorization: `Bearer ${API_KEY}` }});if (!res.ok) throw new Error(`Connections request failed: ${res.status}`);const { items: connections } = await res.json();console.log('연결된 SNS 목록:', connections);const targetConnectionId = connections[0]?.connection_id;if (!targetConnectionId) throw new Error('Connect an SNS account first');Python
섹션 제목: “Python”import osimport requests
API_KEY = os.environ['ANKK_API_KEY']BASE_URL = 'https://api.ankk.app/v1'
headers = {'Authorization': f'Bearer {API_KEY}'}
# SNS 연결 목록 조회response = requests.get(f'{BASE_URL}/brand/connections', headers=headers)response.raise_for_status()connections = response.json().get('items', [])print(f'연결된 SNS: {connections}')target_connection_id = connections[0]['connection_id'] if connections else Noneif not target_connection_id: raise RuntimeError('Connect an SNS account first')4. 첫 콘텐츠 발행 요청
섹션 제목: “4. 첫 콘텐츠 발행 요청”조회한 connection_id를 지정하여 첫 콘텐츠를 발행합니다. 중복 실행을 방지하기 위해 클라이언트 고유의 idempotency_key를 반드시 지정하세요.
cURL
섹션 제목: “cURL”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! 🚀" }'TypeScript / JavaScript
섹션 제목: “TypeScript / JavaScript”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: 'my-first-post-001', text: 'Hello World from ANKK TypeScript SDK! 🚀' })});
if (publishRes.status !== 202) throw new Error(`Publish request failed: ${publishRes.status}`);const result = await publishRes.json();console.log('발행 접수 완료 (HTTP 202):', result);Python
섹션 제목: “Python”publish_payload = { 'connection_id': target_connection_id, 'idempotency_key': 'my-first-post-001', 'text': 'Hello World from ANKK Python Client! 🚀',}
publish_res = requests.post( f'{BASE_URL}/brand/contents', headers={**headers, 'Content-Type': 'application/json'}, json=publish_payload,)publish_res.raise_for_status()print('발행 접수 결과:', publish_res.json())5. 게시 결과 확인
섹션 제목: “5. 게시 결과 확인”발행 요청이 성공하면 HTTP 202 Accepted와 함께 content_id가 반환됩니다. 실제 SNS 등록 여부는 콘텐츠 상세 조회로 확인합니다:
curl "https://api.ankk.app/v1/brand/contents/$CONTENT_ID" \ -H "Authorization: Bearer $ANKK_API_KEY"