Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

API Response Restructure #79

Open
sno2 opened this issue Oct 8, 2020 · 8 comments
Open

API Response Restructure #79

sno2 opened this issue Oct 8, 2020 · 8 comments
Assignees
Labels
enhancement New feature or request

Comments

@sno2
Copy link
Contributor

sno2 commented Oct 8, 2020

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.

@lelouchB
Copy link
Owner

lelouchB commented Oct 8, 2020

@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.

@sno2
Copy link
Contributor Author

sno2 commented Oct 8, 2020

Great, I have school right now, but I will have this done by tonight.

@lelouchB
Copy link
Owner

lelouchB commented Oct 8, 2020

No problem
You can take your time.

@lelouchB lelouchB added enhancement New feature or request hacktoberfest labels Oct 8, 2020
@lelouchB
Copy link
Owner

lelouchB commented Nov 1, 2020

Hey @sno2
Any update on this?

@Mayank0255
Copy link
Contributor

@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

@lelouchB
Copy link
Owner

@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.

@Mayank0255
Copy link
Contributor

@lelouchB

Okay I think you are right we should leave that for now.

@lelouchB
Copy link
Owner

@Mayank0255
Sure 👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

3 participants