JSON Anything API Documentation
Getting Started
The JSON Anything API allows you to extract structured data from unstructured text using custom schemas. Here's how to get started:
API Endpoint
https://jsonanything.com/api/json
Authentication
Generate your API key from your dashboard.
Include your API key in the X-API-Key header:
X-API-Key: YOUR_API_KEY
Example cURL Request
curl -X POST https://jsonanything.com/api/json \ -H "Content-Type: application/json" \ -H "X-API-Key: YOUR_API_KEY" \ -d '{ "text": "John is 30 years old", "schema": { "name": { "type": "string", "description": "The person's name" }, "age": { "type": "number", "description": "The person's age" } } }'
Schema Types
The API supports various data types and structures. Here are examples for each:
String
Basic string type with optional formats
{ "name": { "type": "string", "description": "The person's name" }, "email": { "type": "string", "format": "email", "description": "The person's email address" }, "website": { "type": "string", "format": "url", "description": "The person's website" }, "birthdate": { "type": "string", "format": "date", "description": "The person's birth date" } }
Advanced Features
Enums
{ "status": { "type": "string", "enum": ["active", "inactive", "pending"], "description": "The person's account status" } }
Nested Structures in Arrays
{ "contacts": { "type": "array", "items": { "type": "object", "properties": { "name": { "type": "string", "description": "Contact name" }, "relation": { "type": "string", "description": "Relationship to the person" }, "phone": { "type": "string", "description": "Contact phone number" } } }, "description": "List of the person's contacts" } }
Optional and Nullable Fields
{ "middleName": { "type": "string", "optional": true, "description": "The person's middle name (if any)" }, "retirementDate": { "type": "string", "format": "date", "nullable": true, "description": "The person's retirement date (if applicable)" } }
Error Handling
The API returns specific error messages for validation failures. For example:
{ "error": "Age of the person must be at most 120" }