DEV Community

Alex
Alex

Posted on

Turn Unstructured Text into Clean Data with One API Call

Every app eventually needs to parse unstructured text. A user pastes an address. A customer uploads a receipt photo (OCR'd to text). An email comes in and you need the sender, date, and action items.

You can write regex. You'll spend 3 hours on edge cases. Then a new format appears and it all breaks.

Or you can make one API call and get clean JSON.

The API

StructureAI takes any text and returns structured data. One endpoint, any schema.

curl -X POST https://api-service-wine.vercel.app/api/extract \
  -H "Content-Type: application/json" \
  -H "X-API-Key: YOUR_KEY" \
  -d '{
    "text": "Your unstructured text here",
    "schema": "receipt"
  }'
Enter fullscreen mode Exit fullscreen mode

That's the entire API. Text in, JSON out.

Real-World Use Cases

Parsing Customer Support Emails

Your support inbox gets messages like:

Hi, I ordered the blue widget (order #4521) last Tuesday and it arrived damaged.
The box was crushed and the widget has a crack on the left side. I'd like a
replacement or refund. My account email is sarah@example.com. Thanks, Sarah
Enter fullscreen mode Exit fullscreen mode

Extract it:

curl -X POST https://api-service-wine.vercel.app/api/extract \
  -H "Content-Type: application/json" \
  -H "X-API-Key: YOUR_KEY" \
  -d '{
    "text": "Hi, I ordered the blue widget (order #4521) last Tuesday...",
    "schema": "custom",
    "custom_fields": ["order_number", "issue_type", "product", "damage_description", "requested_action", "customer_email", "customer_name", "urgency"]
  }'
Enter fullscreen mode Exit fullscreen mode

Returns:

{
  "order_number": "4521",
  "issue_type": "damaged_product",
  "product": "blue widget",
  "damage_description": "box crushed, crack on left side",
  "requested_action": "replacement or refund",
  "customer_email": "sarah@example.com",
  "customer_name": "Sarah",
  "urgency": "medium"
}
Enter fullscreen mode Exit fullscreen mode

Feed this into your ticketing system. Auto-route based on issue type. Auto-link to the order. No human triaging needed.

Processing Invoices

INVOICE #INV-2026-0342
From: Acme Corp, 123 Business Ave, Suite 400, Austin TX 78701
To: Your Company LLC
Date: March 1, 2026
Due: March 31, 2026

Web Development Services - February 2026
  Frontend development: 40 hours @ $150/hr     $6,000
  Backend API work: 24 hours @ $175/hr          $4,200
  Code review and QA: 8 hours @ $125/hr         $1,000

Subtotal: $11,200
Tax (8.25%): $924
Total Due: $12,124

Payment: Wire transfer to Acme Corp, Chase Bank, Account ending 8891
Enter fullscreen mode Exit fullscreen mode

Extract with schema invoice:

{
  "invoice_number": "INV-2026-0342",
  "vendor": "Acme Corp",
  "vendor_address": "123 Business Ave, Suite 400, Austin TX 78701",
  "client": "Your Company LLC",
  "date": "2026-03-01",
  "due_date": "2026-03-31",
  "line_items": [
    {"description": "Frontend development", "hours": 40, "rate": 150, "amount": 6000},
    {"description": "Backend API work", "hours": 24, "rate": 175, "amount": 4200},
    {"description": "Code review and QA", "hours": 8, "rate": 125, "amount": 1000}
  ],
  "subtotal": 11200,
  "tax": 924,
  "total": 12124,
  "payment_method": "Wire transfer, Chase Bank, account ending 8891"
}
Enter fullscreen mode Exit fullscreen mode

This replaces manual data entry for accounting teams.

Extracting Contact Info

Users paste contact information in every possible format:

Dr. Maria Chen, PhD
Chief Technology Officer
Quantum Computing Lab, MIT
mchen@mit.edu | (617) 555-0199
LinkedIn: linkedin.com/in/mariachen
Enter fullscreen mode Exit fullscreen mode
curl -X POST https://api-service-wine.vercel.app/api/extract \
  -H "Content-Type: application/json" \
  -H "X-API-Key: YOUR_KEY" \
  -d '{
    "text": "Dr. Maria Chen, PhD\nChief Technology Officer...",
    "schema": "contact"
  }'
Enter fullscreen mode Exit fullscreen mode

Returns normalized, structured contact data every time, regardless of the input format.

Integration Examples

Node.js / TypeScript

import { StructureAI } from './structureai';

const client = new StructureAI(process.env.STRUCTUREAI_KEY!);

// In your API route
app.post('/api/parse-receipt', async (req, res) => {
  const { receiptText } = req.body;

  const data = await client.extract(receiptText, 'receipt');

  // Save structured data to database
  await db.receipts.create({
    merchant: data.merchant,
    total: data.total,
    date: new Date(data.date),
    items: data.items,
  });

  res.json({ success: true, data });
});
Enter fullscreen mode Exit fullscreen mode

A simple wrapper class:

class StructureAI {
  constructor(private apiKey: string) {}

  async extract(text: string, schema: string, customFields?: string[]) {
    const response = await fetch(
      'https://api-service-wine.vercel.app/api/extract',
      {
        method: 'POST',
        headers: {
          'Content-Type': 'application/json',
          'X-API-Key': this.apiKey,
        },
        body: JSON.stringify({
          text,
          schema,
          ...(customFields && { custom_fields: customFields }),
        }),
      }
    );
    const result = await response.json();
    return result.data;
  }
}
Enter fullscreen mode Exit fullscreen mode

Python

import requests

class StructureAI:
    BASE_URL = "https://api-service-wine.vercel.app/api/extract"

    def __init__(self, api_key):
        self.api_key = api_key

    def extract(self, text, schema="custom", fields=None):
        payload = {"text": text, "schema": schema}
        if fields:
            payload["custom_fields"] = fields

        response = requests.post(
            self.BASE_URL,
            json=payload,
            headers={"X-API-Key": self.api_key},
        )
        return response.json()["data"]

# Usage
ai = StructureAI("your-key")
receipt = ai.extract(receipt_text, "receipt")
print(f"Total: ${receipt['total']}")
Enter fullscreen mode Exit fullscreen mode

Pricing and Limits

  • $2 per API key — includes 100 requests
  • No subscriptions, no monthly fees
  • Keys never expire
  • Buy as many as you need

For high-volume users, contact us for bulk pricing.

Free Option: MCP Server

If you use Claude Desktop or Cursor, install the StructureAI MCP server for 10 free requests. No API key needed.

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

When to Use This vs. Building Your Own

Build your own when:

  • You need to process millions of documents (API costs add up)
  • Your schema never changes (regex might be fine)
  • You need sub-100ms latency (AI adds processing time)

Use StructureAI when:

  • Your input formats vary
  • You need to support new schemas quickly
  • You want to skip weeks of regex debugging
  • You're processing hundreds, not millions, of documents

For most startups and indie developers, the API approach saves weeks of development time and handles edge cases that would take months to cover with regex.

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


Built by Avatrix LLC. Questions? support@avatrix.co

Top comments (0)