LLegiScoreSearch API
Get an API key
Get started
IntroductionAuthenticationQuickstartSearch lifecycleErrorsWebhooksCreditsGet an API key
API reference
Credit balancegetCataloggetLookupsgetSearchespost
States
All states
View as Markdownllms-full.txt

Get started

Search lifecycle

A search is asynchronous. You submit it, it runs against the official source, and you read the result when it finishes.

The flow

text
POST /api/v1/search              ->  202  { id, status: "queued" }
GET  /api/v1/search/{id}         ->  status: queued -> running -> succeeded | failed | cancelled
GET  /api/v1/search/{id}/documents/{filename}  ->  302 to a short-lived signed URL

Submit

POST /api/v1/search takes one search, or up to 25 in searches[]. The charge is taken at submit. A request that fails validation returns 422 and charges nothing.

single
{
  "state": "telangana",
  "search_type": "ec",
  "params": { "...": "see the search page for its fields" },
  "label": "Case 8841 EC",
  "callback_url": "https://your-app.example.com/hooks/legiscore"
}
batch (max 25)
{
  "searches": [
    { "state": "andhra", "search_type": "prohibited", "params": { "...": "..." } },
    { "state": "karnataka", "search_type": "ec", "params": { "...": "..." } }
  ],
  "callback_url": "https://your-app.example.com/hooks/legiscore"
}

In a batch, each item is accepted or refused on its own. Refused items come back in rejected[] as { index, code, message, retry_after? } and are not charged.

Statuses

statusMeaningTerminal
queuedAccepted and charged. Waiting for a free slot.No
runningThe source is being queried. progress is an estimate from 0 to 100.No
awaiting_otpThe source asked for a one-time code. See OTP below.No
succeededFinished. found, records and documents are filled in.Yes
failedThe source could not answer. The charge is refunded. error says why.Yes
cancelledYou cancelled it. Refunded when the service confirms.Yes

A search that is still not terminal after 3 hours is failed and refunded automatically. Poll every 5 to 10 seconds, or use a webhook.

Reading the result

FieldMeaning
foundnull until the search finishes. false means the source answered and holds nothing under that query.
records[]The rows the source returned. Their shape depends on the search.
documents[]{ filename, content_type, bytes, withheld }. Download each one with the documents route.
noteA coverage caveat from the source, when there is one.
error{ kind, message } on a failed search.
refundedWhether this search was refunded.
Registers: found:false is not a clear title
Some searches read a register the government publishes as bulk documents. They carry a Register note on their search page. There, found: false means no per-property match was computed, not that the property is clear. Read the documents.

Failure kinds

error.kindRetry?
portal_blockedYes, later. The source refused or was unreachable.
portal_timeoutYes. The source was too slow.
portal_changedNot until we fix it. Report it to us.
captcha_failedYes.
otp_timeoutYes.
invalid_inputNo. Correct the parameters first.
internalYes, then contact us if it repeats.

Documents

GET /api/v1/search/{id}/documents/{filename} answers 302 to a signed URL valid for one hour. Request it again for a fresh link. If a file failed its integrity check we withhold it (410 withheld) rather than hand you bad bytes.

OTP

Some sources verify with a one-time code (searches marked OTP on their page). LegiScore handles the code for you, so the search may sit in awaiting_otp for a short time and then continue. You do not need to do anything. If a search needs a code sent to your registered mobile, send it with:

http
POST /api/v1/search/{id}/otp
{ "otp": "123456" }

The code is 4 to 8 digits. Sending it to a search that is not waiting returns 409 not_waiting.

Cancel

DELETE /api/v1/search/{id} cancels a search that has not finished. On a finished search you get 409 already_finished.

Idempotency and repeats

SituationCostResult
Same Idempotency-Key within 24 hoursFreeOriginal search returned, header Idempotent-Replayed: true, HTTP 200
Same search again by the same person within 24 hoursFreeSame id, replayed: true
Same search by a colleague in the same workspace within 24 hoursChargedServed from the recent result with a new id

Send Idempotency-Key as 1 to 255 printable ASCII characters, no spaces, for example a case id plus the search type. Reusing a key with a different body returns 409 idempotency_key_reused.

List your searches

GET /api/v1/search?limit=50&offset=0&status=succeeded&batch_id=... returns your searches newest first. limit is at most 200.

PreviousQuickstartNextErrors