-
Notifications
You must be signed in to change notification settings - Fork 97
API Development JSON Output guide
Ashwin Date edited this page Mar 3, 2017
·
1 revision
To ensure all APIs have a consistent output format, the below JSON structure is proposed. This also makes it easier to build services and apps, since all of the APIs will have consistent output.
{
"err_code" : "", // Send an appropriate application error code when a non-200 HTTP status
"err_message" : "", // Send an appropriate application error message when a non-200 HTTP status
"data" : {} // API developers are free to define their data structure here
}
{
"err_code" : "",
"err_message" : "",
"data" : {
"results": [
{
"name": "Category1",
"identifier": "1",
"children": [
{
"name": "Windows",
"identifier": "2",
"children": []
},
{
"name": "Windows Mobile",
"identifier": "3",
"children": []
}
]
},
{
"name": "Category2",
"identifier": "4",
"children": [
{
"name": "SubCategory 1",
"identifier": "5",
"children": [
{
"name": "Nexus 4",
"identifier": "6",
"children": []
}
]
},
{
"name": "SubCategory 2",
"identifier": "8",
"children": [
{
"name": "ipod",
"identifier": "9",
"children": []
}
]
}
]
}
],
"empty_message":"" // Message to show when the list is empty
}
{
"err_code" : "",
"err_message" : "",
"data" : {
"results": {
"name" : "",
"bio" : "",
"avatar" : "",
"email" : ""
}
}
{
"err_code" : "VAL001",
"err_message" : "Invalid Email",
"data" : {}
}