API Documentation
Schema Documentation
JSON Anything API Documentation
Overview
The JSON Anything API allows you to extract structured data from unstructured text using AI. You can provide text directly or upload a file, along with a JSON schema defining the structure you want to extract.
Authentication
All API requests require authentication using your API key.
Authentication
Note: Always use the x-api-key header as some platforms (like Vercel) strip Authorization headers.
You can find your API key in the Dashboard after signing in. Keep your API key secret and don't share it in client-side code.
Endpoint
Request Format
All requests should be sent as application/json
{ "input": string, // Text or base64 encoded file content "inputType": "text" | "file", "schema": { // JSON Schema defining the structure "type": string, "properties": { "fieldName": { "type": string, "description": string (optional) }, ... }, "required": [string] // Array of required field names }, "options": { // Optional configuration "temperature": number // Controls randomness (0-1, default: 0) } }
Response Format
The API returns structured JSON data based on the provided schema.
{ "data": { // The extracted structured data // Fields matching your schema }, "metadata": { "processingTime": string // Processing time in milliseconds } }
Error Responses
Error responses will return with an appropriate HTTP status code and error message.
{ "error": string // Error message }
Common error codes:
- 401 - Authentication required or invalid API key
- 400 - Invalid request format or parameters
- 500 - Server error during processing
Schema
The schema parameter is a JSON Schema object that defines the structure of the data you want to extract.
{ "type": "object", "properties": { "name": { "type": "string", "description": "The person's full name" }, "age": { "type": "number", "description": "The person's age in years" }, "skills": { "type": "array", "description": "List of skills the person has", "items": { "type": "string" } } }, "required": ["name", "age"] }
The schema can include basic types (string, number, boolean), arrays, nested objects, enums, and more. Each property can have a description that helps the AI understand what information to extract.
Code Examples
fetch('/api/extract', { method: 'POST', headers: { 'Content-Type': 'application/json', 'x-api-key': 'YOUR_API_KEY' }, body: JSON.stringify({ "input": "John Doe is 35 years old and works as a software engineer at Acme Inc.", "inputType": "text", "schema": { "type": "object", "properties": { "name": { "type": "string", "description": "The person's full name" }, "age": { "type": "number", "description": "The person's age" }, "occupation": { "type": "string", "description": "The person's job title" }, "company": { "type": "string", "description": "The company name" } }, "required": ["name", "age"] } }) }) .then(response => response.json()) .then(data => console.log(data));
Response
{ "data": { "name": "John Doe", "age": 35, "occupation": "software engineer", "company": "Acme Inc." }, "metadata": { "processingTime": "350ms" } }