Set:
BASE_URL=https://api.rsi-data.comAPI_KEY=...curl -s "$BASE_URL/v1/ping"
Request:
curl -X POST "$BASE_URL/v1/research/ask" \
-H "Authorization: Bearer $API_KEY" \
-H "Content-Type: application/json" \
-H "Idempotency-Key: msg-12345" \
-d '{
"query": "What is the recent inflation trend in India?",
"chat_id": null,
"user_id": null,
"source": "govt_news",
"advanced_config": {
"search_depth": "advanced",
"recency_window": "last_12m",
"include_inline_citations": true,
"format_style": "markdown_report"
}
}'
Success response (shape):
{
"response": "string",
"chat_id": "string|null",
"web_searched_data": [{ "url": "...", "title": "...", "content": "...", "trust_score": 0 }],
"indian_data": { "...": "..." },
"indian_documents": { "...": "..." }
}
Basic cURL stream:
curl -N -X POST "$BASE_URL/v1/research/stream" \
-H "Authorization: Bearer $API_KEY" \
-H "Content-Type: application/json" \
-H "Accept: text/event-stream" \
-d '{
"query": "Summarize current macro indicators in India.",
"chat_id": "chat-abc",
"source": "govt",
"advanced_config": { "search_depth": "advanced", "recency_window": "last_12m" }
}'
Output consists of lines like:
data: {"type":"generation_id","data":"<job_id>"}
data: {"type":"status","data":{...}}
data: {"type":"token","data":"...partial text..."}
...
data: {"type":"final","data":{"response":"...","chat_id":"...","research":[...],"internal_data":{...},"internal_document":{...}}}
Node (fetch) SSE example:
import fetch from 'node-fetch';
const res = await fetch(`${process.env.BASE_URL}/v1/research/stream`, {
method: 'POST',
headers: {
'Authorization': `Bearer ${process.env.API_KEY}`,
'Content-Type': 'application/json',
'Accept': 'text/event-stream',
},
body: JSON.stringify({
query: 'FX outlook for the next year in India',
chat_id: 'chat-xyz',
source: 'govt_news',
advanced_config: { recency_window: 'last_12m', format_style: 'bullet_summary' }
}),
});
for await (const chunk of res.body) {
const text = chunk.toString();
text.split('\n').forEach(line => {
if (line.startsWith('data: ')) {
const payload = JSON.parse(line.slice(6));
if (payload.type === 'token') process.stdout.write(payload.data);
if (payload.type === 'final') console.log('\nFINAL:', payload.data.response);
}
});
}
Poll a job (resume UI after disconnect):
JOB_ID="<from X-Quickpulse-Job-Id header or first generation_id event>"
curl "$BASE_URL/v1/research/jobs/$JOB_ID" \
-H "Authorization: Bearer $API_KEY"
curl -X POST "$BASE_URL/v1/conversation" \
-H "Authorization: Bearer $API_KEY" \
-H "Content-Type: application/json" \
-d '{
"message": "Hi! Summarize today’s major economic themes for India.",
"chat_id": "chat-1",
"user_id": "user-1"
}'
Response (shape):
{
"response": "string",
"chat_id": "string|null",
"should_generate_report": false,
"report_topic": null
}
curl -X POST "$BASE_URL/v1/clarify" \
-H "Authorization: Bearer $API_KEY" \
-H "Content-Type: application/json" \
-d '{
"topic": "Impact of a recent policy on trade balances",
"reason": "Need a concise scope and timeline before deep dive",
"chat_id": null,
"user_id": null
}'
Response (shape):
{
"need_clarification": true,
"clarification_text": "string"
}
Create a key:
curl -X POST "$BASE_URL/admin/api-keys" \
-H "X-Admin-Secret: $ADMIN_API_SECRET" \
-H "Content-Type: application/json" \
-d '{
"user_id": "user-1",
"name": "My Service Key",
"scopes": ["research"],
"quota": {"requests_per_min": 60, "concurrent": 5},
"credits": {"remaining": 10000},
"advanced_config": { "source_mode": "government_only" }
}'
Rotate / Revoke:
curl -X POST "$BASE_URL/admin/api-keys/{key_id}/rotate" -H "X-Admin-Secret: $ADMIN_API_SECRET"
curl -X POST "$BASE_URL/admin/api-keys/{key_id}/revoke" -H "X-Admin-Secret: $ADMIN_API_SECRET"