Predicta
Search
Docs
Ctrl KPredicta SearchGet an API key
Get started

Quickstart

Start a search, then read its results as they arrive.
Get your API key

Your key is in your Predicta Search account settings, in the API tab (sign in first). Keep it on your server (why).

Send the query. The answer comes back at once, with the search_id to follow.

curl -X POST https://dev.predictasearch.com/api/v2/search \
  -H "x-api-key: $API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"query": "johndoe", "query_type": "username", "networks": ["all"]}'
202Accepted
{
  "search_id": "3911861a-685d-420f-aae2-0bb2dba36ead",
  "status": "running",
  "total": 1840,
  "networks_rejected": []
}
Read the results as they arrive

Open the stream of that search_id. The connection stays open and events arrive one by one.

curl -N https://dev.predictasearch.com/api/v2/search/$SEARCH_ID \
  -H "x-api-key: $API_KEY" \
  -H "Accept: text/event-stream"
text/event-stream
id: 0
event: result
data: {"network":"github","data":[{"username":"johndoe","platform":"github","link":"https://github.com/johndoe"}]}

id: 1
event: source_error
data: {"network":"hudsonrock","reason":"timeout"}

id: 2
event: progress
data: {"done":94,"total":1840,"found":68,"failed":4}

…

id: 615
event: done
data: {"found":379,"failed":113,"credit_debited":true,"credit_balance":974}
Stop on the last event

done means the search is complete. failed means it was interrupted and its credit refunded. Either one closes the stream.

A production client also resumes the stream when the connection drops. Full client examples do it in Python and JavaScript.