Different applications and integrations expect responses in different formats.
Modern apps usually work with JSON, while configuration driven systems may prefer YAML, and legacy or enterprise systems often rely on XML.
With API Maker, you don't need to manually transform your API outputs.
Any response, whether from autogenerated APIs, a custom APIs you build, or any third-party APIs can be returned in the exact format you want using a single request header.
This makes APIs created with API Maker universally consumable across all environments without writing extra conversion logic.
How It Works
Controlling the output format in API Maker is done through a single HTTP header.
To specify the desired format, include the following header in your request:
x-am-content-type-response: json | yaml | xml
- json → Returns the response in standard JSON format
- yaml → Converts the response into YAML format
- xml → Converts the response into XML format
This works for:
- Autogenerated APIs (from your connected databases)
- Custom APIs (functions you write in API Maker)
- Third-party APIs (integrated through API Maker)
No extra libraries or code are required, API Maker handles the transformation automatically before sending the response.
Supported Output Formats
API Maker can return responses in JSON, YAML, or XML, depending on the header you set.
Below are examples of the same response rendered in each format.
JSON
{
"success": true,
"statusCode": 200,
"data": [
{
"_id": "5b794fb02fe51f2ead6919da",
"active": 1,
"updatedAt": "2018-08-19T11:08:32.5822",
"createdAt": "2018-08-19T11:08:32.5822",
"company_name": "prayosha",
"company_type": "PRODUCTION",
"__v": 0
}
]
}
XML
<?xml version="1.0" encoding="UTF-8"?>
<root>
<success>true</success>
<statusCode>200</statusCode>
<data>
<_el>
<_id>5b794fb02fe51f2ead6919da</_id>
<active>1</active>
<updatedAt>2018-08-19T11:08:32.5822</updatedAt>
<createdAt>2018-08-19T11:08:32.5822</createdAt>
<company_name>prayosha</company_name>
<company_type>PRODUCTION</company_type>
<__v>0</__v>
</_el>
</data>
</root>
YAML
success: true
statusCode: 200
data:
- _id: 5b794fb02fe51f2ead6919da
active: 1
updatedAt: "2018-08-19T11:08:32.5822"
createdAt: "2018-08-19T11:08:32.5822"
company_name: prayosha
company_type: PRODUCTION
__v: 0
Advanced Controls
In addition to choosing the output format, API Maker gives you fine-grained control over the structure and naming of your API responses.
1. Flattening Nested Responses
Some databases or client applications cannot handle deeply nested JSON or XML structures.
With the header:
x-am-response-object-type: flat
API Maker automatically flattens nested objects into single-level key paths.
Default (nested):
{
"success": true,
"statusCode": 200,
"data": {
"hello": "world",
"level1": {
"level3": {
"level3": {
"name": "API Maker"
}
}
}
}
}
Flattened:
{
"success": true,
"statusCode": 200,
"data": {
"hello": "world",
"level1_level2_level3_name": "API Maker"
}
}
This is especially useful when storing responses in SQL databases that don't support nested fields.
2. Changing Key Case
Different clients or integrations may require response keys in a specific case style.
API Maker can automatically reformat keys using the x-am-response-case header.
Supported styles include:
camelCase
PascalCase
snake_case
CONSTANT_CASE
capitalCase
dot.case
header-case
no case
param-case
path/case
sentence case
Default JSON Response:
{
"success": true,
"statusCode": 200,
"data": [
{
"_id": "5b794fb02fe51f2ead6919da",
"active": 1,
"updatedAt": "2018-08-19T11:08:32.5822",
"createdAt": "2018-08-19T11:08:32.5822",
"company_name": "prayosha",
"company_type": "PRODUCTION",
"__v": 0
}
]
}
With x-am-response-case: CONSTANT_CASE:
{
"success": true,
"statusCode": 200,
"data": [
{
"_ID": "5b794fb02fe51f2ead6919da",
"ACTIVE": 1,
"UPDATEDAT": "2018-08-19T11:08:32.5822",
"CREATEDAT": "2018-08-19T11:08:32.5822",
"COMPANY_NAME": "prayosha",
"COMPANY_TYPE": "PRODUCTION",
"__V": 0
}
]
}
Other Formats:
The Case transformations apply consistently across JSON, YAML, and XML outputs.
Default XML Example
<?xml version='1.0'?>
<root>
<success>true</success>
<statusCode>200</statusCode>
<data>
<_el>
<_id>5b794fb02fe51f2ead6919da</_id>
<active>1</active>
<updatedAt>2018-08-19T11:08:32.5822</updatedAt>
<createdAt>2018-08-19T11:08:32.5822</createdAt>
<company_name>prayosha</company_name>
<company_type>PRODUCTION</company_type>
<__v>0</__v>
</_el>
</data>
</root>
With x-am-response-case: CONSTANT_CASE:
<?xml version='1.0'?>
<root>
<success>true</success>
<statusCode>200</statusCode>
<data>
<_el>
<_ID>5b794fb02fe51f2ead6919da</_ID>
<ACTIVE>1</ACTIVE>
<UPDATEDAT>2018-08-19T11:08:32.5822</UPDATEDAT>
<CREATEDAT>2018-08-19T11:08:32.5822</CREATEDAT>
<COMPANY_NAME>prayosha</COMPANY_NAME>
<COMPANY_TYPE>PRODUCTION</COMPANY_TYPE>
<__V>0</__V>
</_el>
</data>
</root>
FAQ
What happens if I don't pass the x-am-content-type-response header?
If no header is provided, API Maker defaults to returning responses in JSON format.
Can I request multiple formats at once?
No. Only one output format can be applied per request. If multiple values are passed, API Maker will use the first valid one.
Will response transformations affect API performance?
The transformations (format conversion, flattening, case changes) are lightweight and run inside API Maker's response pipeline. For most use cases, they add negligible overhead, even for large responses.
Is there any difference in data between JSON, YAML, and XML outputs?
No. The underlying data remains identical, the only change is in how the response is structured and serialized.