Dealing with errors

What if things go wrong?

Sometimes your API call will fail, and you might not know why. You did everything right, you followed the documentation or you used an existing example, and yet ... there is no milk (or rather, no data!). There's just an error message.

Error 404: "milk" not found

By far the most common error is 404. It simply means 'we can't find what you're asking for'. Either it doesn't exist, or it's not where you told your computer to look. This is the API server's response, telling you what the result of your question is. The response is usually a code or a generic message that doesn't help you much by itself. But there are ways of identifying and translating the error codes so you can try to work out what went wrong.

401, 402 and 403 are variations on 'you're not allowed to look at what you're asking for', for instance you're trying to access a section that needs authentication or login credentials.
Responses in the 500 range cover things like the API server being down, the network being down and other problems that are at the server's end and are nothing to do with whatever you did.

100: Here is some information
200: Success!
300: We need to redirect you
400: You did something wrong
500: We did something wrong