How I Built an API That Turns Messy Text Into Clean JSON (and You Can Use It Free)

Published: (March 8, 2026 at 12:28 AM EST)
3 min read
Source: Dev.to

Source: Dev.to

Overview

Every developer has dealt with messy, unstructured text—receipts, emails, resumes, and more. The valuable data is hidden in plain text, and traditional regex solutions are brittle while manual parsing is tedious. StructureAI solves this problem with a single API call: feed any text, receive clean, structured JSON.

Example: Receipt Parsing

Input text

Receipt from Whole Foods 03/15/2024
Apples $3.99
Milk $5.49
Bread $4.29
Tax $1.18
Total: $14.95
Card ending 4242

Desired JSON output

{
  "merchant": "Whole Foods",
  "date": "2024-03-15",
  "items": [
    { "name": "Apples", "price": 3.99 },
    { "name": "Milk", "price": 5.49 },
    { "name": "Bread", "price": 4.29 }
  ],
  "tax": 1.18,
  "total": 14.95,
  "payment_method": "Card ending 4242"
}

API Usage

curl -X POST https://api-service-wine.vercel.app/api/extract \
  -H "Content-Type: application/json" \
  -H "X-API-Key: YOUR_KEY" \
  -d '{
    "text": "Receipt from Whole Foods 03/15/2024...",
    "schema": "receipt"
  }'

The API returns structured JSON along with a confidence score. It works for receipts, invoices, emails, resumes, contacts, or any custom schema you define.

Supported Schemas

SchemaExtracted Fields
receiptItems, totals, dates, merchant
invoiceLine items, amounts, due dates
emailSender, subject, body, dates
resumeName, experience, skills
contactName, email, phone, address
customUser‑defined fields

Custom Schema Example: Product Reviews

curl -X POST https://api-service-wine.vercel.app/api/extract \
  -H "Content-Type: application/json" \
  -H "X-API-Key: YOUR_KEY" \
  -d '{
    "text": "Love this laptop! Battery lasts 12 hours. Screen is gorgeous. Only downside is the keyboard feels mushy. 4/5 stars.",
    "schema": "custom",
    "custom_fields": ["product_type", "pros", "cons", "rating", "sentiment"]
  }'

Response

{
  "product_type": "laptop",
  "pros": ["12 hour battery life", "gorgeous screen"],
  "cons": ["mushy keyboard"],
  "rating": "4/5",
  "sentiment": "positive"
}

MCP Server Integration (Claude Desktop / Cursor)

If you use Claude Desktop or Cursor, you can install the MCP server for free requests.

git clone https://github.com/avatrix1/structureai-mcp.git
cd structureai-mcp && npm install && npm run build

Add the server to your Claude Desktop configuration:

{
  "mcpServers": {
    "structureai": {
      "command": "node",
      "args": ["/path/to/structureai-mcp/dist/index.js"]
    }
  }
}

Then simply ask Claude, e.g., “Extract the receipt data from this text: …”.

Pricing

  • Free tier (MCP): 10 requests per month.
  • API key: $2 for 100 requests.

Get your API key at https://api-service-wine.vercel.app.

Contact

Built by Avatrix LLC. For questions, email: support@avatrix.co.

0 views
Back to Blog

Related posts

Read more »