How to write a professional http status code for our own API?

HTTPstatus codes that start with the number four are also tangible for non -technical users as the most famous status code belongs to this family, 404, is known to many users! In addition, there are other codes in the group that can be used in the API design, including the Too Many Requests Code, which can be used when the number can be used. The ricoists received from a particular client should be over -permitted, which ultimately leads to the rejection of the request by the server.HTTP status codes that start with the number five are all related to the server side problems and have nothing to do with the client at all, and unlike the 4xx family codes, these codes are used when the API is implemented on the server. There is a problem and the server is incapable of applying the client, one of which is the SERVICE Unavailable Status Code, which is used when the service is not available.A good status code not only informs the client in the process of doing the work, but also shows the client reason or the reasons for the occurrence of a particular event. In general, we can say when we have a good status code to the client that has the following three features:– contain the status code (eg 200) and also summarize (eg OK). – contain additional descriptions and more details about the process. – Contains a conceptual text for users that summarize the code, status, details, relevant reasons, and the suggested solution to the problem.To better understand how to write a good status code, we will explain the above features:– Standard Status Codes: Using the standard status codes we have examined above in five different groups can be a good starting point for writing professional status codes. In fact, when you use the family of 4xx or 5xx status codes, the user will quickly realize that there is a problem, whether from the client or on the server side.– Provide details: If we provide the client with a status code such as Bad Request, although such a code indicates a problem with the user, it does not provide the user with sufficient and practical information so that they can take appropriate action. Consider. In this regard, we need to provide more details to the user because the phrase Bad Request has a general concept and the bad word is completely relative and it is necessary to get it out of relative state and make the concept perfectly illustrated. Let’s make.– Understanding for users: Although the numerical status codes are well visible for the system (for example, we can check with conditional commands that if the status code was 400, such a job is done), providing understandable details to humans as well. Helping to make the situation more professional.In fact, the above status code contains keys under the titles of CodeMessage, Code, and Errordetails, which contains useful information for the doloper that uses the API that constitutes the three characteristics of a principled situation. In the interpretation of the above status code, we should say that code 429 and the standard Too Many Requests message indicate that the number of requests sent to the server was overly permissible, but what is more than anything for the Doloperi that received this error message, The message is related to the ERRRRORDETIPISS key, which states that “the number of requests sent is too much and you need to upgrade your plan to Unlimited (without restriction) to fix this problem.” That simply provides the solution to Dolopper to fix the problem.In general, the status codes we use in various projects are completely project -oriented, and no structure that is answered for an API can be used exactly the same way in other projects. In a nutshell, the purpose of providing the status codes in API design is to not only provide information about the type of problem, but also provide a solution to the problem to fix the problem to work with our API experience. They get.