https://github.com/azhovan/standard-json-response
Standard Json Response
https://github.com/azhovan/standard-json-response
api api-server json json-api response
Last synced: 2 months ago
JSON representation
Standard Json Response
- Host: GitHub
- URL: https://github.com/azhovan/standard-json-response
- Owner: Azhovan
- Created: 2017-10-21T06:14:44.000Z (about 8 years ago)
- Default Branch: master
- Last Pushed: 2017-10-24T06:37:47.000Z (about 8 years ago)
- Last Synced: 2025-02-28T10:39:07.293Z (10 months ago)
- Topics: api, api-server, json, json-api, response
- Homepage:
- Size: 6.84 KB
- Stars: 0
- Watchers: 0
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Standard-Json-Response
This document identify how a standard Json API response should be.
please feel free to contribute !
##### Full structure of response :
```
{
"data": {...},
"errors": {...},
"meta": {...}
}
```
##### Resource Objects:
```
{
"type": "articles",
"id": "1",
"attributes": {
"title": "Rails is Omakase",
"price": 25000
},
"relationships": {
"author": {
"links": {
"self": "/articles/1/relationships/author",
"related": "/articles/1/author"
},
"data": {
"type": "people",
"id": "9"
},
"meta": {}
}
},
"Links": {
"self": "http://example.com/posts",
"related": {
"href": "http://example.com/articles/1/comments",
"meta": {
"count": 10
}
}
},
"meta": {
"copyright": "Copyright 2015 Example Corp.",
"authors": [
"Yehuda Katz",
"Steve Klabnik",
"Dan Gebhardt",
"Tyler Kellen"
]
}
}
```
#### Error Object :
```text
{
"errors": [{
"id": 1,
"links": {
"about": "http://thisis.com/link/about/the/problem"
},
"status": 400,
"code": "application code here",
"title": "title of error",
"details": "",
"source": {
"pointer": "requested uri",
"parameter": "uri query strings"
},
"meta": {}
}]
}
```
##### Relationships Object:
```text
"relationships": {
"author": {
"links": {
"self": "/articles/1/relationships/author",
"related": "/articles/1/author"
},
"data": {
"type": "people",
"id": "9"
},
"meta": {}
}
}
```
#### Links Object :
```text
"Links": {
"self": "http://example.com/posts",
"related": {
"href": "http://example.com/articles/1/comments",
"meta": {
"count": 10
}
}
}
```
#### Meta Object :
```text
"meta": {
"copyright": "Copyright 2015 Example Corp.",
"authors": [
"Yehuda Katz",
"Steve Klabnik",
"Dan Gebhardt",
"Tyler Kellen"
]
}
```
#### useful links
```
https://github.com/Microsoft/api-guidelines/blob/vNext/Guidelines.md
https://geemus.gitbooks.io/http-api-design/content/en/
https://byrondover.github.io/post/restful-api-guidelines/
https://medium.com/@shazow/how-i-design-json-api-responses-71900f00f2db
https://phalt.co/api-response-formats/
http://editor.swagger.io/#/
```