API Reference

Stable, public endpoints under /api/v1. Hosted at https://www.allnutrition.info. A free API key is required (Authorization: Bearer ank_…, created under Settings → API keys); every account gets the same daily allowance — see Rate limits.

Endpoints at a glance

MethodPathDescription
POST /api/v1/ask Answer a nutrition question with citations.
POST /api/v1/references/search Semantic search of the curated reference library (no LLM).
GET /api/v1/health Liveness probe.
GET /openapi.json Machine-readable OpenAPI 3.1 specification.

POST /api/v1/ask

Answer a nutrition question with peer-reviewed citations.

Request body

FieldTypeDescription
questionstring (1–1000)Required. The question, in plain English.
published_afterISO-8601 datetimeOptional. Only consider sources published on or after this date.
deep_researchboolean (default false)Optional. Run the deep-research pipeline: the question is expanded into multiple targeted sub-queries and the answer is a comprehensive, sectioned research report. Slower (typically 30–90 s).
shareboolean (default false)Optional. Persist the question and answer as a public, read-only Ask session and return its URL in share_url.
save_sessionboolean (default true)Optional. Save the question and answer to your Ask history in the app (badged as an API/MCP session). Set false to skip.

Response (200)

FieldTypeDescription
questionstringEcho of the original question.
answerstring (Markdown)Evidence-grounded answer.
evidence_strengthstrong | moderate | limited | insufficientStrength of the underlying evidence.
consensus_levelhigh | moderate | mixed | lowHow well the cited sources agree.
last_updatedISO-8601 / nullMost recent publication among cited sources.
deep_researchbooleanWhether the answer was produced by the deep-research pipeline.
share_urlstring / nullPublic URL of the shared Ask session. Only present when the request set share: true.
session_idstring / nullID of the Ask session saved to your in-app history. Absent when the request set save_session: false.
sources[]arrayCitations (see Source object).

Example

curl -X POST https://www.allnutrition.info/api/v1/ask \
  -H "Content-Type: application/json" \
  -d '{"question": "Is creatine safe for adolescents who lift weights?"}'

Deep research

Set "deep_research": true to trade latency for depth. Instead of a single retrieval pass, the pipeline expands your question into 3–8 targeted sub-queries (e.g. safety, efficacy, mechanisms), retrieves and merges sources for each, and synthesizes a comprehensive Markdown report with inline citations and a summary section. Expect responses in 30–90 seconds and a much longer answer. A deep-research call counts as one request against the rate limit.

Shareable Ask sessions

Set "share": true to persist the question and answer as a public, read-only Ask session. The response's share_url points to a web page (https://www.allnutrition.info/shared/<slug>) showing the question, the answer, and its citations — useful for handing users a permanent, human-readable link from a chatbot or agent. Notes:

curl -X POST https://www.allnutrition.info/api/v1/ask \
  -H "Content-Type: application/json" \
  -d '{
    "question": "What does the evidence say about intermittent fasting?",
    "deep_research": true,
    "share": true
  }'
# → { ..., "deep_research": true,
#     "share_url": "https://www.allnutrition.info/shared/Ab3dEf9hIj2kLm5n" }

POST /api/v1/references/search

Return ranked sources for a query without generating an answer.

Request body

FieldTypeDescription
querystring (1–1000)Required. Free-text query.
max_resultsinteger (1–20, default 10)Maximum sources to return.
published_afterISO-8601 / nullOptional cutoff.

Response (200)

FieldTypeDescription
querystringEcho of the query.
countintegerNumber of results returned.
results[]arraySources (see Source object), ranked by relevance × trust.

Source object

Both endpoints return sources with the same shape.

FieldTypeDescription
idstring (UUID)Stable AllNutrition reference ID.
titlestringTitle of the paper, guideline, or article.
urlstring / nullCanonical URL (DOI, journal page, guideline URL).
publisherstringIssuing journal, organisation, or guideline body.
publisher_short_namestring / nullShort identifier (e.g. WHO, AHA, NICE).
evidence_levelenumguideline | systematic_review | rct | observational | expert_opinion | review
trust_scorefloat [0, 1]Composite trust: authority × recency × evidence × consensus.
published_atISO-8601 / nullPublication date.
excerptstringVerbatim chunk used as RAG context.
passagestring / nullShort human-readable preview where available.

Errors

StatusMeaning
400Invalid payload (e.g. empty question, query too long).
429Rate limit exceeded — see Rate limits & errors.
500Unexpected server error. Safe to retry with backoff.
503Upstream model temporarily unavailable.

Interactive explorer

Try requests live against the API in the interactive Scalar explorer →

The interactive explorer is rendered from the same OpenAPI spec served at /openapi.json. You can download the spec and use it with Postman, Insomnia, Stoplight, or any OpenAPI-compatible tool.