final-space-api
final-space-api copied to clipboard
API Response Restructure
Is your feature request related to a problem? Please describe.
Currently, all character and episode endpoints just return the character
/episode
json or an array
of the character
/episodes
that match the request.
Describe the solution you'd like I think that all correct responses should have one of the following formats:
{
"status": 200,
"data": {}
}
or
{
"status": 200,
"results": [],
}
Of course, the response status
should match the correct status of the response. If we changed to doing this, though, then it would allow us to include errors in incorrect responses that doesn't look weird. For example, if I were getting data from a certain character, but I sent the request to /character/9999
, we only get a 502 Bad Gateway message. We should, however, return the following data:
{
"status": 404,
"message": "The character you have requested was not found."
}
Edit: the message
property could be swapped for error
.
Using statuses instead of errors allows an easier debugging process, as the developer can access the message and status that the servers sent.
I will work on a PR if this is deemed as needed by the community.
@CodingCarter This is great, this will be really awesome and helpful.
I will guess I will include this in v2
but go ahead and work on this.
I will assign this to you.
Looking forward to this.
Great, I have school right now, but I will have this done by tonight.
No problem You can take your time.
Hey @sno2 Any update on this?
@lelouchB If @sno2 is not doing it, then can I do this one?
P.S. I know I have said for the quote endpoint too but I would like to start from here and then head to that
@Mayank0255
This is an enhancement issue and its not a priority for me. If you want I can assign this to you and you can start working on it.
But I will most likely include this update in v2 of the API i.e. with GraphQL support.
@lelouchB
Okay I think you are right we should leave that for now.
@Mayank0255 Sure 👍