API क्विकस्टार्ट (Quickstart)
ANKK पब्लिक API एक RESTful API है जो एक ही ब्रांड-स्कोप्ड API कुंजी (spk_...) का उपयोग करके आपके मल्टी-चैनल सोशल मीडिया संचालन के प्रोग्रामेटिक प्रबंधन की अनुमति देता है।
📌 एंडपॉइंट अवलोकन (Endpoint Overview)
Section titled “📌 एंडपॉइंट अवलोकन (Endpoint Overview)”- बेस URL:
https://api.ankk.app - स्वैगर (Swagger) / इंटरएक्टिव दस्तावेज़:
https://api.ankk.app/v1/docs - OpenAPI JSON स्पेक:
https://api.ankk.app/v1/openapi.json
1. सर्विस हेल्थ की जांच करें
Section titled “1. सर्विस हेल्थ की जांच करें”हेल्थ चेक एंडपॉइंट्स के लिए ऑथेंटिकेशन हेडर की आवश्यकता नहीं होती है।
curl https://api.ankk.app/v1/health{ "service": "api-public", "status": "ok"}2. अपनी API कुंजी प्राप्त और निर्यात करें
Section titled “2. अपनी API कुंजी प्राप्त और निर्यात करें”वेब ऐप (https://app.ankk.app) में, कुंजी उत्पन्न करने के लिए Brand Settings → API Keys पर जाएं, फिर उसे निर्यात करें:
export ANKK_API_KEY='spk_live_xxxxxxxxxxxxxxxx'3. ब्रांड और SNS कनेक्शंस प्राप्त करें
Section titled “3. ब्रांड और SNS कनेक्शंस प्राप्त करें”अपने ब्रांड की स्थिति जांचें और लक्षित connection_id प्राप्त करने के लिए जुड़े SNS खातों को सूचीबद्ध करें।
# 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;if (!API_KEY) throw new Error('Set ANKK_API_KEY');const BASE_URL = 'https://api.ankk.app/v1';
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('Connected accounts:', connections);const targetConnectionId = connections[0]?.connection_id;if (!targetConnectionId) throw new Error('Connect an SNS account first');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)response.raise_for_status()connections = response.json().get('items', [])print(f'Connected accounts: {connections}')target_connection_id = connections[0]['connection_id'] if connections else Noneif not target_connection_id: raise RuntimeError('Connect an SNS account first')4. अपना पहला कंटेंट प्रकाशित करें
Section titled “4. अपना पहला कंटेंट प्रकाशित करें”डुप्लिकेट निष्पादन से बचने के लिए क्लाइंट द्वारा उत्पन्न idempotency_key के साथ प्रकाशन अनुरोध सबमिट करें।
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: 'my-first-post-001', text: 'Hello World from TypeScript! 🚀' })});
if (publishRes.status !== 202) throw new Error(`Publish request failed: ${publishRes.status}`);const result = await publishRes.json();console.log('Publish accepted (HTTP 202):', result);Python
Section titled “Python”payload = { 'connection_id': target_connection_id, 'idempotency_key': 'my-first-post-001', 'text': 'Hello World from Python! 🚀',}
publish_res = requests.post( f'{BASE_URL}/brand/contents', headers={**headers, 'Content-Type': 'application/json'}, json=payload,)publish_res.raise_for_status()print('Publish outcome:', publish_res.json())5. प्रकाशन स्थिति सत्यापित करें
Section titled “5. प्रकाशन स्थिति सत्यापित करें”एक सफल अनुरोध HTTP 202 Accepted और एक content_id लौटाता है। इसके माध्यम से वितरण स्थिति सत्यापित करें:
curl "https://api.ankk.app/v1/brand/contents/$CONTENT_ID" \ -H "Authorization: Bearer $ANKK_API_KEY"