API API success status code definition

different platforms and service providers use different interface status codes

but the common success status code is used by some people: 0, 1, 1, 100, 200, etc.

which is more in line with the specification and which is more general?

I usually use 1 for success. Welcome to discuss it.

Mar.28,2021

0 indicates success, and all exceptions greater than 0 are exceptions. Depending on the numerical value, the exception is different (custom), and it is simple and clear


.

there is no standard for this.
tell me about mine.

< H2 > StatusCode < / H2 >
  • all exceptions thrown by non-business use standard HTTP status codes.
  • 200 status codes are used for all businesses to throw exceptions.
< H2 > response body < / H2 >
  • unsuccessful response
{
    "errmsg":"",
    "errcode":1,// exceptioncode1errcode0
}
  • successful response
{
"user_id":1
}

[
{
"user_id":1
}
]

the data part is clean, and there are no flag fields such as succeed

MySQL Query : SELECT * FROM `codeshelper`.`v9_news` WHERE status=99 AND catid='6' ORDER BY rand() LIMIT 5
MySQL Error : Disk full (/tmp/#sql-temptable-64f5-1eb6dbd-2606.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
MySQL Errno : 1021
Message : Disk full (/tmp/#sql-temptable-64f5-1eb6dbd-2606.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
Need Help?