Hello,
I’m implementing jsonapi spec in our API and i want make sure that i understand everything correctly.
Here’s full nested resource url: /v1/countries/1/states/42
I will give response output by going through all resources. Maybe something should or can be improved here?
Endpoint: /v1/countries
{
"data": [
{
"type": "country",
"id": "4",
"attributes": {
"country": "American Samoa",
"calling_code": {
"0": 1684
}
}
}
]
}
Endpoint: /v1/countries/4
{
"data": {
"type": "country",
"id": "4",
"attributes": {
"country": "American Samoa",
"calling_code": {
"0": 1684
}
},
"relationships": {
"states": {
"data": [
{
"type": "state",
"id": "164"
}
]
}
}
},
"included": [
{
"type": "state",
"id": "164",
"attributes": {
"state": "Eastern"
}
}
]
}
Endpoint: /v1/countries/4/states
{
"data": [
{
"type": "state",
"id": "164",
"attributes": {
"state": "Eastern"
}
},
{
"type": "state",
"id": "165",
"attributes": {
"state": "Manu'a"
}
}
]
}
Endpoint: /v1/countries/4/states/164
{
"data": {
"type": "state",
"id": "164",
"attributes": {
"state": "Eastern"
},
"relationships": {
"cities": {
"data": [
{
"type": "city",
"id": "6414"
},
{
"type": "city",
"id": "6415"
}
]
}
},
"included": [
{
"type": "city",
"id": "6414",
"attributes": {
"city": "Afono"
}
},
{
"type": "city",
"id": "6415",
"attributes": {
"city": "Alao"
}
}
]
}
}
Thanks!