Overview

Fafa API uses advanced AI to transform unstructured text into structured JSON objects based on your specified schema. Perfect for extracting structured data from any text content.

Go to playground

Endpoint

POSThttps://fafa.ucokman.web.id/api/v1/json

Request Body

ParameterTypeDescription
data
string
The unstructured text to parse.
format
object
JSON schema defining the expected output structure.

Examples

Below are practical examples demonstrating how to use the API endpoint. The examples show request formatting and expected response structure.

cURL Request

Shell

Copy and paste this command into your terminal to test the API endpoint.

curl -X POST https://fafa.ucokman.web.id/api/v1/json \
  -H "Content-Type: application/json" \
  -d '{"data":"Project Alpha final report: The initiative, led by manager Sarah Chen, is now complete. The core development team included Tom, the lead dev, and an intern, Ben.","format":{"projectName":{"type":"string"},"isCompleted":{"type":"boolean"},"manager":{"name":{"type":"string","context":"Full name of the project leader."},"email":{"type":"string"}},"team":[{"name":{"type":"string"},"role":{"type":"string","context":"e.g., lead dev, intern"}}]}}'

Request Body

JSON

The request body should contain the unstructured data and the desired output format schema.

{
  "data": "Project Alpha's final report: The initiative, led by manager Sarah Chen, is now complete. The core development team included Tom, the lead dev, and an intern, Ben.",
  "format": {
    "projectName": { "type": "string" },
    "isCompleted": { "type": "boolean" },
    "manager": {
      "name": {
        "type": "string",
        "context": "Full name of the project leader."
      },
      "email": { "type": "string" }
    },
    "team": [
      {
        "name": { "type": "string" },
        "role": { "type": "string", "context": "e.g., lead dev, intern" }
      }
    ]
  }
}

Response

200
JSON

The API returns the extracted and structured data matching your specified format.

{
  "result": {
    "projectName": "Project Alpha",
    "isCompleted": true,
    "manager": {
      "name": "Sarah Chen",
      "email": null
    },
    "team": [
      {
        "name": "Tom",
        "role": "lead dev"
      },
      {
        "name": "Ben",
        "role": "intern"
      }
    ]
  }
}

Error Codes

StatusCodeDescriptionExample
400SYNTAX_ERRORInvalid JSON in request body
Malformed JSON
422INVALID_JSON_FORMATInvalid request parameters
Missing required fields
500INTERNAL_SERVERServer error
Processing failed

Error Response Format

{
  "code": "INVALID_JSON_FORMAT",
  "message": "format field must be valid object and required"
}

Schema Format

The format parameter defines the structure and data types for the expected JSON output. Each field or an item in array requires a type and can optionally include a context for more specific instructions. If the requested data cannot be retrieved, the value will be null or an empty array.

Supported Types

Primitive Types

  • string - Text values
  • number - Numeric values
  • boolean - True/false values

Complex Types

  • object - Nested objects
  • array - Lists of items
  • null - Missing values

Schema Example

// 01. Schema defintion must be wrapped in an object.
{
  // ...
}

--------------------------------------------------------------------------------------

// 02. To define a value for a field of object or item of array, 
// use `type` and optional `context` field wrapped in an object.

{"type": /* any primitive type */, "context": "optional context for better understanding"}

--------------------------------------------------------------------------------------

// 03. Minimal basic example.
// You can omit `context` if the fieldname already representative.

{"name": {"type": "string"} 

--------------------------------------------------------------------------------------

// 04. Example nested object.

{
  "outerfield": {"type": "string", "context": "..."},
  "section": {
    "nestedField": {"type": "number"}
  }
}

--------------------------------------------------------------------------------------

// 05. Example basic array.
// This will output [ "item1", "item2" ];

{
  "items": [{"type":"string", "context": "the age of cat"}]
}

--------------------------------------------------------------------------------------

// 06. Example nested array.
// This will output: [ ["items1"], ["items2"] ]

{
  "items": [
    [{"type":"number", "context": "the age of cat"}],
  ]
}

--------------------------------------------------------------------------------------

// 07. Example array of an object

{
  "field": {
    "items": [{
      "name": {"type":"string"},
      // ... other field
    }]
  }
}