Skip to main content
POST
/
parse
JavaScript
import ContextDev from 'context.dev';

const client = new ContextDev({
  apiKey: process.env['CONTEXT_DEV_API_KEY'], // This is the default and can be omitted
});

const response = await client.parse.handle(fs.createReadStream('path/to/file'));

console.log(response.markdown);
import os
from context.dev import ContextDev

client = ContextDev(
api_key=os.environ.get("CONTEXT_DEV_API_KEY"), # This is the default and can be omitted
)
response = client.parse.handle(
body=b"Example data",
)
print(response.markdown)
package main

import (
"bytes"
"context"
"fmt"
"io"

"github.com/context-dot-dev/context-go-sdk"
"github.com/context-dot-dev/context-go-sdk/option"
)

func main() {
client := contextdev.NewClient(
option.WithAPIKey("My API Key"),
)
response, err := client.Parse.Handle(
context.TODO(),
io.Reader(bytes.NewBuffer([]byte("Example data"))),
contextdev.ParseHandleParams{},
)
if err != nil {
panic(err.Error())
}
fmt.Printf("%+v\n", response.Markdown)
}
require "context_dev"

context_dev = ContextDev::Client.new(api_key: "My API Key")

response = context_dev.parse.handle(body: StringIO.new("Example data"))

puts(response)
<?php

require_once dirname(__DIR__) . '/vendor/autoload.php';

use ContextDev\Client;
use ContextDev\Core\FileParam;
use ContextDev\Core\Exceptions\APIException;

$client = new Client(apiKey: getenv('CONTEXT_DEV_API_KEY') ?: 'My API Key');

try {
$response = $client->parse->handle(
FileParam::fromString('Example data', filename: uniqid('file-upload-', true)),
);

var_dump($response);
} catch (APIException $e) {
echo $e->getMessage();
}
context-dev parse handle \
--api-key 'My API Key' \
--body 'Example data'
curl --request POST \
--url https://api.context.dev/v1/parse \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/octet-stream' \
--data '"<string>"'
HttpResponse<String> response = Unirest.post("https://api.context.dev/v1/parse")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/octet-stream")
.body("\"<string>\"")
.asString();
{
  "success": true,
  "markdown": "<string>",
  "key_metadata": {
    "credits_consumed": 123,
    "credits_remaining": 123
  }
}
{
"message": "<string>",
"key_metadata": {
"credits_consumed": 123,
"credits_remaining": 123
}
}
{
"message": "<string>",
"error_code": "INPUT_VALIDATION_ERROR"
}
{
"message": "<string>",
"error_code": "UNSUPPORTED_CONTENT",
"key_metadata": {
"credits_consumed": 123,
"credits_remaining": 123
}
}
{
"message": "<string>",
"error_code": "INTERNAL_ERROR",
"key_metadata": {
"credits_consumed": 123,
"credits_remaining": 123
}
}
1 Credit OCR: 5 Credits

Authorizations

Authorization
string
header
required

Bearer authentication header of the form Bearer <token>, where <token> is your auth token.

Query Parameters

extension
enum<string>

Optional file extension hint. Case-insensitive; a leading dot is accepted (e.g. ".pdf").

Available options:
txt,
text,
md,
markdown,
html,
htm,
xhtml,
xml,
rss,
atom,
csv,
tsv,
yaml,
yml,
py,
java,
js,
jsx,
mjs,
cjs,
json,
jsonl,
ndjson,
php,
sh,
bash,
zsh,
fish,
rb,
ts,
tsx,
rtf,
srt,
css,
scss,
less,
styl,
sass,
svg,
pdf,
docx,
doc,
xlsx,
xlsm,
xlsb,
xltx,
xltm,
xls,
pptx,
pptm,
ppsx,
ppsm,
potx,
potm,
ppt,
pps,
pot,
jpg,
jpeg,
jpe,
png,
gif,
bmp,
tiff,
tif,
webp,
ppm,
pbm,
pgm,
pnm

Preserve hyperlinks in Markdown output

includeImages
boolean
default:false

Include image references in Markdown output

shortenBase64Images
boolean
default:true

Shorten base64-encoded image data in the Markdown output

useMainContentOnly
boolean
default:false

Extract only the main content from HTML-like inputs

ocr
boolean
default:false

Gates all OCR. When true, PDFs get embedded-image OCR (recognized text inserted at each image's position in page reading order, preserving the text layer; pdf.start/pdf.end limit the page range), scanned PDFs with no text layer get full-document OCR, and raster images get their visible text transcribed. When false, no OCR runs: scanned PDFs may yield no content and images return only format/dimension metadata. Calls where OCR actually runs cost 5 credits instead of 1.

pdf
object

PDF page-range controls. Use start/end to limit parsing (and OCR when ocr=true) to an inclusive 1-based page range.

tags
string[]

Optional comma-separated caller-defined tags for tracking this request. Tags are recorded on the request's usage log and can be used to filter usage on the dashboard usage page. Up to 20 tags, each 1-50 characters. Optional caller-defined tags for tracking this request. Tags are recorded on the request's usage log and can be used to filter usage on the dashboard usage page. Up to 20 tags, each 1-50 characters.

Maximum array length: 20
Required string length: 1 - 50
Example:
["production", "team-alpha"]

Body

Raw file bytes. The request body must not exceed 25 MiB.

The body is of type file.

Response

Successful response

success
enum<boolean>
required

Indicates success

Available options:
true
markdown
string
required

Input bytes converted to GitHub Flavored Markdown

type
enum<string>
required

Detected content type used for parsing

Available options:
html,
xml,
json,
jsonl,
text,
csv,
tsv,
markdown,
yaml,
python,
java,
javascript,
php,
shell,
ruby,
typescript,
rtf,
srt,
css,
scss,
less,
stylus,
sass,
svg,
pdf,
docx,
doc,
xlsx,
xls,
pptx,
ppt,
jpg,
png,
gif,
bmp,
tiff,
webp,
ppm,
pbm,
pgm,
pnm
key_metadata
object

Metadata about the API key used for the request. Included in every response whenever a valid API key is provided, even when the response status is not 200.