API reference

Four endpoints under /api/v1, all bearer-auth. Mint a token in the quickstart.

StableAvailable since v0.3.0Bearer auth required
POST/api/v1/analyses10 / min / token

Submit an ad URL

Synchronous URL validation, then a 1-credit charge and a worker job. The response carries the new analysis id straight away. If the same normalized URL has been analyzed before, you get a cache hit with status='done' in the same response.

Request body

urlrequiredstringFull Meta or TikTok Ad Library URL.

Response

iduuidAnalysis id for subsequent GETs.
statusenum`queued` (worker will process), `done` (cache hit).
cachedbooleanPresent and true when status=done from cache.
estimatedSecondsinteger~90 for queued.
links.selfstringPath to GET the analysis.

Status codes

201Queued (new analysis, worker will run)
200Done (cache hit — no worker run)
400invalid_url, missing_url, invalid_body
401unauthorized
402insufficient_credits
429rate_limited

Example

bash
curl -X POST https://adrevila.com/api/v1/analyses \
  -H "Authorization: Bearer $TOKEN" \
  -H "Content-Type: application/json" \
  -d '{"url":"https://www.facebook.com/ads/library/?id=971390442080128"}'
GET/api/v1/analyses60 / min / token

List analyses (paginated)

Returns the token-user's completed analyses, newest first. Failed and in-progress rows are excluded.

Query params

pageintegerDefault 1, max 100000.
pageSizeintegerDefault 25, max 100.

Response

data[].iduuidAnalysis id.
data[].pageNamestring?Page that ran the ad.
data[].adIdstring?Library id.
data[].sourceenum`web` or `api`.
data[].scoreobject?`{ value: 0–100, grade: "A+"…"F" }` when present.
data[].summarystring?First-paragraph summary.
data[].completedAtiso8601When the worker finished.
pagination.totalintegerTotal matching analyses.
pagination.totalPagesintegerDerived from total and pageSize.

Status codes

200OK
401unauthorized
429rate_limited

Example

bash
curl -H "Authorization: Bearer $TOKEN" \
  "https://adrevila.com/api/v1/analyses?page=1&pageSize=10"
GET/api/v1/analyses/{id}120 / min / token

Fetch one analysis

Returns the analysis. Format is negotiated via the Accept header (see below). JSON is the default.

Path params

iduuidReturned from POST submit.

Headers

Accept`application/json` (default), `text/markdown`, or `application/pdf`.

Response

iduuid
statusenum`queued`, `fetching`, `composing`, `done`, `failed`.
sourceenum`web` or `api`.
reportobject?Full report when status=done; null otherwise.
currentStepstring?Human-readable step when not done.
errorMessagestring?When status=failed.

Status codes

200OK
400not_acceptable (unsupported Accept)
401unauthorized
403forbidden (different user owns this id)
404not_found
429rate_limited

Example

bash
# JSON
curl -H "Authorization: Bearer $TOKEN" https://adrevila.com/api/v1/analyses/$ID

# Markdown
curl -H "Authorization: Bearer $TOKEN" -H "Accept: text/markdown" \
  https://adrevila.com/api/v1/analyses/$ID

# PDF
curl -H "Authorization: Bearer $TOKEN" -H "Accept: application/pdf" \
  https://adrevila.com/api/v1/analyses/$ID -o report.pdf
GET/api/v1/credits120 / min / token

Get credit balance

Returns the current credit balance and the lifetime total purchased. Cheap and safe to poll — agents typically call it before a submit to warn the user about an incoming 402.

Response

balanceintegerCurrent credit balance.
lifetimePurchasedintegerSum of all positive refill deltas across the account.

Status codes

200OK
401unauthorized
429rate_limited

Example

bash
curl -H "Authorization: Bearer $TOKEN" https://adrevila.com/api/v1/credits
# → { "balance": 12, "lifetimePurchased": 41 }