API overview
One REST API over multi-billion charted documents: scholarly publications, books, patents, encyclopedias, and public discussion. Search, fetch bounded full text, download available originals by ID or canonical URI, cite sources, and recognize your own PDF, EPUB, and DJVU files into structured Markdown.
Ways to connect
- REST API
https://api.machinelibrary.aifor applications and automations. Start below.- MCP server
- Connect Claude, ChatGPT, Cursor, and other agents with OAuth or an API key.
- A2A
- JSON-RPC at
/a2a; discovery at /.well-known/agent-card.json.
Quickstart
- Create a key on API keys. It is shown once, when it is created.
- Send requests to
https://api.machinelibrary.aiwith the key in theX-Api-Keyheader. Other credentials - Search:
curl -X POST https://api.machinelibrary.ai/v2/search/ \
-H "X-Api-Key: YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"query": "machine learning transformers",
"limit": 10
}'Fetch text and originals
Limit a text response by tokens, or stream the original by document ID or a percent-encoded canonical URI. Original files need download access.
# Pricing and access terms: https://machinelibrary.ai/pricing/world
# Return exactly the first 4,096 text tokens
curl -H "X-Api-Key: YOUR_API_KEY" \
"https://api.machinelibrary.ai/v2/documents/31tlqhmn2jmoh3gzlea74trb3?max_tokens=4096"
# Stream a PDF original by document ID
curl -L -H "X-Api-Key: YOUR_API_KEY" \
-o document.pdf \
"https://api.machinelibrary.ai/v2/downloads/31tlqhmn2jmoh3gzlea74trb3.pdf"
# Or resolve the original from a percent-encoded canonical URI
curl -L -H "X-Api-Key: YOUR_API_KEY" \
-o document.pdf \
"https://api.machinelibrary.ai/v2/downloads/by-uri/doi%3A%2F%2F10.1016%2Fj.neulet.2008.10.099?format=pdf"Original files
Search, passages and document text work for every account. Downloading the original PDF, EPUB or DJVU file needs download access:
- It unlocks automatically, with no request to us, once successful payments by your account total more than $100. A credential acting for an organization also qualifies when that organization's payments pass $100. Access stays on after that.
- Each download is charged from your balance: $0.003 per file, or $0.03 for books.
HEADrequests are free. - Only files Machine Library holds can be downloaded; a document without an original returns 404. Use document text for everything else.
Without access, downloads return 403 with missing required feature: raw-document-downloads. See pricing and access terms.
Recognize a document
Upload a PDF, EPUB, or DJVU file, poll the job, then fetch the Markdown and its quality report.
# Submit (billed per document, see /pricing/world; identical resubmissions are free)
curl -X POST https://api.machinelibrary.ai/v1/recognitions \
-H "X-Api-Key: YOUR_API_KEY" \
-F "[email protected]"
# => {"id": "<job_id>", "status": "pending"}
# Poll until completed, then fetch the Markdown and the quality report
curl -H "X-Api-Key: YOUR_API_KEY" \
https://api.machinelibrary.ai/v1/recognitions/<job_id>/resultPython client
pip install machinelibraryfrom machinelibrary import MachineLibrary
ml = MachineLibrary(api_key="YOUR_API_KEY")
for hit in ml.search("machine learning transformers", limit=10):
print(hit.title, hit.source_uri)