Panduan Cepat API
API Publik ANKK adalah API RESTful yang memungkinkan pengelolaan operasi media sosial multi-saluran secara terprogram menggunakan satu kunci API yang dicakupkan ke merek (spk_...).
📌 Ikhtisar Titik Akhir
Section titled “📌 Ikhtisar Titik Akhir”- URL Dasar:
https://api.ankk.app - Swagger / Dokumentasi Interaktif:
https://api.ankk.app/v1/docs - Spek JSON OpenAPI:
https://api.ankk.app/v1/openapi.json
1. Periksa Kesehatan Layanan
Section titled “1. Periksa Kesehatan Layanan”Titik akhir pemeriksaan kesehatan tidak memerlukan header autentikasi.
curl https://api.ankk.app/v1/health{ "service": "api-public", "status": "ok"}2. Dapatkan & Ekspor Kunci API Anda
Section titled “2. Dapatkan & Ekspor Kunci API Anda”Di aplikasi web (https://app.ankk.app), navigasikan ke Brand Settings → API Keys untuk membuat kunci, lalu ekspor kunci tersebut:
export ANKK_API_KEY='spk_live_xxxxxxxxxxxxxxxx'3. Ambil Merek & Koneksi SNS
Section titled “3. Ambil Merek & Koneksi SNS”Periksa status merek Anda dan cantumkan akun SNS yang terhubung untuk mendapatkan connection_id target.
# 1. Inspect brand detailscurl https://api.ankk.app/v1/brand \ -H "Authorization: Bearer $ANKK_API_KEY"
# 2. List connected SNS accountscurl https://api.ankk.app/v1/brand/connections \ -H "Authorization: Bearer $ANKK_API_KEY"TypeScript / JavaScript
Section titled “TypeScript / JavaScript”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;Python
Section titled “Python”import osimport 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']4. Terbitkan Konten Pertama Anda
Section titled “4. Terbitkan Konten Pertama Anda”Kirim permintaan penerbitan dengan idempotency_key yang dihasilkan klien untuk menghindari eksekusi duplikat.
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
Section titled “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: `post-${Date.now()}`, text: 'Hello World from TypeScript! 🚀', }),});
const result = await publishRes.json();console.log('Publish accepted (HTTP 202):', result);Python
Section titled “Python”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())5. Verifikasi Status Publikasi
Section titled “5. Verifikasi Status Publikasi”Permintaan yang berhasil mengembalikan HTTP 202 Accepted dan content_id. Verifikasi status pengiriman melalui:
curl https://api.ankk.app/v1/brand/contents/<content_id> \ -H "Authorization: Bearer $ANKK_API_KEY"