Welcome to Text-to-API 📚
Why Does This Matter?
How Does It Work?
Who Can Benefit?
✅ Finance & Accounting – Automate expense tracking and transaction categorization.
✅ Customer Support – Instantly process and categorize support requests.
✅ Healthcare & Medical – Convert medical notes into structured patient records.
✅ E-Commerce – Analyze product reviews, refund requests, and order issues.
Let's Get Started
"30 USD groceries"
30.00
USD
Groceries
Making Your First API Request
POST
request to the /translations
endpoint, specifying the expected JSON output structure. Here’s how it works:
{
"mapped_object": {
"amount": 30,
"description": "groceries"
}
// other fields that are not important at this point
}
input_text
field. This is where you provide the human-written text that needs to be converted into structured JSON.translation_type
field defines the type of translation you want. In the current API version, we only support object translations, so you must set:"translation_type": "object"
target_object
field specifies the structure of the JSON output. This is where you define the fields you expect in the response."target_object"{
"fields": [] // an array of fields
}
"fields": [
{
"name": "amount",
"description": "The amount of the expense",
"type": "number"
},
{
"name": "description",
"type": "string",
"description": "A brief description of what the expense was for."
}
]
}
name
: This determines the key name in the output JSON.type
: Defines the data type (string
, number
, boolean
, array
, or date
).description
: A short, helpful explanation of the field’s purpose.⚠️ Pro Tip: Descriptions should be concise. Longer requests cost more and take longer to process. Use descriptions only when necessary for clarity.
Let's make it a bit more interesting
fields
array and define its name
, type
, and description
. But what if you want to restrict the possible values that the AI agent can choose from?{
"name": "currency",
"type": "string",
"allowed_values": ["USD", "EUR", "MXN"]
}
"300 Mexican pesos for tacos"
{
"mapped_object": {
"amount": 300,
"currency": "MXN",
"description": "tacos"
}
}
allowed_values
? This is where the description
field becomes useful. You can tell the AI what to do if none of the allowed values match. For example:{
"name": "currency",
"type": "string",
"allowed_values": ["USD", "EUR"],
"description": "Set null if none of the allowed_values is matched"
}
{
"mapped_object": {
"amount": 300,
"currency": null,
"description": "tacos"
}
}
Let's Make It Even More Interesting
fixed-costs
, savings
, investments
, and guilt-free
. We already know how to define this, so we simply add a new field in target_object.fields
like this:{
"name": "category",
"type": "string",
"allowed_values": [
"guilt-free",
"fixed-costs",
"savings",
"investments"
]
}
"60 bucks for Red Dead Redemption 2"
"mapped_object": {
"amount": 60,
"category": "guilt-free",
"currency": "USD",
"description": "Red Dead Redemption 2"
}
Adding Subcategories Based on Category
category
? 🤯sub_category
, specify its type as string
, and tell Text-to-API that this field depends on another field (in this case, category
) using "depends_on": "category"
:{
"name": "sub_category",
"type": "string",
"depends_on": "category"
}
category
, by defining "dependent_allowed_values"
like this:{
"name": "sub_category",
"type": "string",
"depends_on": "category",
"dependent_allowed_values": [
{
"value": "guilt-free",
"allowed_values": ["clothes", "entertainment", "eating_out"]
},
{
"value": "fixed-costs",
"allowed_values": ["food", "rent", "internet", "phone"]
},
{
"value": "savings",
"allowed_values": ["emergency", "travel", "gifts"]
},
{
"value": "investments",
"allowed_values": ["stocks", "bonds", "crypto"]
}
]
}
Testing More Inputs
"30 euros, souvenir for my girlfriend"
"mapped_object": {
"amount": 30,
"category": "guilt-free",
"currency": "EUR",
"description": "souvenir for my girlfriend",
"sub_category": "gifts"
}
"15 bucks at McDonald's"
"mapped_object": {
"amount": 15,
"category": "guilt-free",
"currency": "USD",
"description": "at McDonald's",
"sub_category": "eating_out"
}
"50 USD, Amazon gift card for my nephew"
"mapped_object": {
"amount": 50,
"category": "guilt-free",
"currency": "USD",
"description": "Amazon gift card for my nephew",
"sub_category": "gifts"
}