7 تغريدة Apr 13, 2023
Best practices for creating API errors
Thread 🧵👇
📌 Why does good error response matter?
In the case of failed requests, only the status codes are not enough since they simply define the categories of the errors.
While they are beneficial, they are not enough to explain the reason why the request failed.
📌 Best practices
1️⃣ HTTP Status Code
The 4xx and 5xx HTTP Status Codes are used to show the category of the error that occurred.
Including these standard error codes helps the developers understand what the error is and where it occurred.
2️⃣ Human readable messages
Only the status codes are not enough to clarify the error. A clear, human-readable message goes a long way to pinpoint the actual cause of the error.
Here is an example error message
3️⃣ Documentation reference
You can also include a link to a help page in your API documentation referring to the error.
It will allow developers to fix the error quickly, massively improving the Developer Experience of your API.
We have written a detailed guide on API errors that you can find here: rapidapi.com
That’s all for now!
Follow @Rapid_API for more exclusive content. 🐙

جاري تحميل الاقتراحات...