Integrate Context.dev's Parse API in your app
Prerequisites
-
A Context.dev API key. Sign up at context.dev/signup, copy the key from the dashboard (prefix
ctxt_secret_), and export it:
curl.
Convert a file to Markdown
Send the file itself as the request body.--data-binary keeps curl from changing the bytes:
cURL
Request parameters
The request body is required and can contain up to 25 MiB. Send the file’s actualContent-Type header when you know it, especially for text that uses a character encoding other than UTF-8.
All parsing options are query parameters:
Because a parsed file has no source URL, relative links and image paths remain relative in the output.
Response
Some extensions share a normalized response type. For example,
.xlsm reports xlsx, .ppsx reports pptx, and .jpeg reports jpg.
Read PDFs and images with OCR
OCR is off by default. Without OCR, PDFs are converted from their selectable text layer. A scanned PDF with no selectable text returns a 400 response unless you setocr=true.
With ocr=true, Context.dev can read scanned PDF pages and text inside embedded images such as charts, screenshots, and stamps. Use the nested pdf page range to convert only the pages you need:
cURL
pdf%5Bstart%5D and pdf%5Bend%5D are the URL-encoded forms of pdf[start] and pdf[end]. You can also send pdf as a URL-encoded JSON object such as {"start":1,"end":5}.
The same ocr=true parameter works for raster images. Without it, an image returns Markdown containing its format and dimensions. With it, the response adds an ## Extracted text section containing text transcribed from the image. Image OCR is text-only — visual content that isn’t text is not described.
Requests with
ocr=true require at least 5 available credits. A successful request costs 5 credits only when OCR contributes text; otherwise it costs 1 credit. Failed parsing and validation requests consume 0 credits. Check key_metadata.credits_consumed for the actual charge.Convert a spreadsheet or document
Point--data-binary at any supported file and pass its extension when useful. Excel workbooks become one Markdown table per non-empty sheet. DOCX files preserve headings, lists, and tables, while legacy DOC files return paragraph text.
cURL
Handle errors
Error responses include anerror_code that distinguishes invalid input from files with no extractable content.
Use cases
- Let users upload a PDF, Word document, or spreadsheet and send the resulting Markdown to an LLM.
- Normalize a folder of mixed documents, decks, spreadsheets, and images before adding them to a RAG index.
- Extract text from scanned contracts and invoices without operating a separate OCR service.
- Turn uploaded images and screenshots into searchable text and descriptions.
Next steps
Scrape Websites
Have a URL instead of a file? Turn any page into clean Markdown.
Extract Structured Data
Pull schema-shaped data out of websites and linked documents.
Best Practices
Caching, error handling, and key hygiene.
Handle Rate Limits
Backoff strategies and pacing for high-volume jobs.