Yes there are a couple of standards (albeit some liberties on the definition of standard) that have emerged:

  1. JSON API - JSON API covers creating and updating resources as well, not just responses.
  2. JSend - Simple and probably what you are already doing.
  3. OData JSON Protocol - Very complicated.
  4. HAL - Like OData but aiming to be HATEOAS like.

There are also JSON API description formats:

  • Swagger
    • JSON Schema (used by swagger but you could use it stand alone)
  • WADL in JSON
  • RAML
  • HAL because HATEOAS in theory is self describing.
Answer from Adam Gent on Stack Overflow
🌐
Medium
medium.com › @bojanmajed › standard-json-api-response-format-c6c1aabcaa6d
Standard JSON API response format | by MaJeD BoJaN | Medium
March 31, 2020 - Recently one of my friend asked me if there is any standard response we follow for API response, this question asked too much from beginner developers especially those are new in term of API · I was really interested by this question as I have to design a JSON API everyday. I found myself wondering if there is any standard over there. I started searching about standard JSON format but unfortunately there is no standard Not only within JSON itself, but in terms of how to use it for RESTful applications or anything else of the sort.
Discussions

REST API Response Format: Which approach would you suggest?
Since you are not using a peasant weak typed trashy language, you could do better than JSON (for instance, https://msgpack.org/index.html ). There are some working in this sense that you could choose from: a) https://jsonapi.org/ b) https://google.github.io/styleguide/jsoncstyleguide.xml Google format is pretty neat: data: object for success ( https://google.github.io/styleguide/jsoncstyleguide.xml?showone=data#data ), error: error object for failure ( https://google.github.io/styleguide/jsoncstyleguide.xml?showone=error#error ). Although that uses JSON, you don't really need to (i.e.: that can be used in any serialization format you want) More on reddit.com
🌐 r/FlutterDev
4
0
June 11, 2023
api design - Why do so many standards for JSON API response formats contain a "success" property in the response body instead of just using HTTP status codes? - Software Engineering Stack Exchange
I was researching about best practices for standardised JSON response formats for APIs, according to various sources available online general consensus looks something like this: //Successful requ... More on softwareengineering.stackexchange.com
🌐 softwareengineering.stackexchange.com
March 22, 2022
What is best practice for return error codes with a REST API?
Keep in mind, you don't want to give the end user too much information. Over detailed error codes can give malicious users a window into how your application is structured, and therefore give them better ideas for how to dig into it and do bad things. It's a fine line to walk for sure. More on reddit.com
🌐 r/AskProgramming
15
13
April 13, 2022
Is the API response format consistent here? How would you handle sending a success, an error and multiple errors like validation using a common format?
You don't necessarily need to respond back with a status of success or error. The http response code handles that for you already..anything 2xx is good, anything in 4xx is most likely user error and anything in 5xx is server error. So less data down the wire and states for you to handle. More on reddit.com
🌐 r/node
44
126
May 17, 2020
🌐
GitHub
gist.github.com › igorjs › 407ffc3126f6ef2a6fe8f918a0673b59
REST API response format based on some of the best practices · GitHub
REST API response format based ... https://api.example.com/v1/items · https://example.com/api/v1/items · 1- GET - Get single item - HTTP Response Code: 200 ·...
🌐
Reddit
reddit.com › r/flutterdev › rest api response format: which approach would you suggest?
r/FlutterDev on Reddit: REST API Response Format: Which approach would you suggest?
June 11, 2023 -

Hi guys, I'm working on Spring Boot project, also this question can be ask for any backend app. I'm trying to figure out which REST API Response format is better. I have done some research but still, I need the opinion from the community. Which approach would you suggest in terms of best practice, code quality, maintainability and readability?P/s: If you guys have other suggestion, would love to read that.

Option 1:

// Success request with data
{ 
    code: "000", 
    msg: "Successfully logged-in", 
    data: { 
            token: { accessToken: "..." }, 
            user: { id: "1", name: "John" }
    }
}

// Success request with validation
{ 
    code: "001", 
    msg: "Validation error", 
    data: { 
        validation: { 
            name: "The name field is required", 
            email: "The email has been taken"
        }
    } 
}

Option 2:

// Success request with data
{ 
    code: "000", 
    msg: "Successfully logged-in", 
    data: { 
            token: { accessToken: "..." },
            user: { id: "1", name: "John" }
    },
    error: null
}

// Success request with validation 
{
    code: "001", 
    msg: "Validation error", 
    data: null, 
    error: { 
        validation: {
            name: "The name field is required", 
            email: "The email has been taken" 
        } 
    } 
}
🌐
Speakeasy
speakeasy.com › api-design › responses
Responses Best Practices in REST API Design | Speakeasy
Other information needs to be added to help with debugging, and to help the API client differentiate between errors. There is a better way: RFC 9457 which defines a standard way to return errors in JSON (or XML).
🌐
Microsoft Learn
learn.microsoft.com › en-us › azure › architecture › best-practices › api-design
Web API Design Best Practices - Azure Architecture Center | Microsoft Learn
For example, a web API that implements simple calculator operations such as add and subtract can provide URIs that expose these operations as pseudo resources and use the query string to specify the required parameters. A GET request to the URI /add?operand1=99&operand2=1 returns a response message with the body containing the value 100. However, you should use these forms of URIs sparingly. RESTful web API methods align with the request methods and media types defined by the HTTP protocol.
Find elsewhere
🌐
JSON:API
jsonapi.org
JSON:API — A specification for building APIs in JSON
Here’s an example response from a blog that implements JSON:API: { "links": { "self": "http://example.com/articles", "next": "http://example.com/articles?page[offset]=2", "last": "http://example.com/articles?page[offset]=10" }, "data": [{ "type": "articles", "id": "1", "attributes": { "title": "JSON:API paints my bikeshed!"
Top answer
1 of 7
58

A few potential reasons why you may wish to do this are:

  1. the fact that some HTTP clients treat anything other than 2xx as an "exception" to be thrown, which can hide differences between transport errors (like no connection, invalid firewall, invalid endpoint/URL, etc.) and actual API errors (bad API key, request validation rules, etc.), which could both end up being thrown as errors, which leads to extra work in determining which it was and extracting the actual API error text

  2. responses that aren't accurately / completely represented by normal status code, or even multi action requests, where you have >1 API action in a single HTTP request and each one may succeed or fail individually, in which case either a 2xx or 4xx would not be accurate

I personally prefer to inspect the JSON for errors instead of hoping that the language I'm using will easily differentiate between different kinds of errors. Java and C# for example would allow me to do multiple different catches of specific exceptions on a single try, but in JavaScript where anything can be an error and each try only allows a single catch, it's messier to separate transport errors from API errors

2 of 7
111

Many people take HTTP status code as “successful communication with the server”.

Now if a customer wants to buy a US$200 item and has only US$100 in their account, the JSON response will be “failure, insufficient funds”. But as far as HTTP is concerned, everything went just fine: It delivered a purchase order, and successfully returned back to the caller that the purchase failed.

So you get a status 200. You would get something in the 400 range if there was actually some communication failure. In that case you have no idea if there is money in the account or not. We didn’t get that far.

Note there are situations where we don’t even get an HTTP status: if the server is down, or if HTTPS negotiation fails, your application didn’t even manage to reach the server.

🌐
Stoplight
infraspeak.stoplight.io › docs › api › ZG9jOjEzNzUwNDAx-request-response-format
Request/Response Format | REST API docs
Both requests and responses work with JSON format. Successful requests will return a 200 OK status. Powered by Stoplight.
🌐
Broadcom
techdocs.broadcom.com › us › en › ca-mainframe-software › performance-and-storage › ca-sysview-performance-management › 17-0 › using-ca-sysview › use-the-rest-api › rest-api-json-response-format.html
REST API JSON Response Format
July 17, 2025 - From ASLIST, type INFOFLDS to see each field in the information area as it is named. This information is returned in the InfoFlds section of the response message to document the offset and row where the fields are found.
🌐
Microsoft Learn
learn.microsoft.com › en-us › aspnet › core › web-api › advanced › formatting
Format response data in ASP.NET Core Web API | Microsoft Learn
The JSON formatter returns a response with a body of null. The XML formatter returns an empty XML element with the attribute xsi:nil="true" set. Clients can request a particular format as part of the URL, for example: In the query string or ...
🌐
LinkedIn
linkedin.com › all › engineering › software testing
What are the best ways to verify the response format of a RESTful API?
October 19, 2023 - One of the first steps to verify the response format of a RESTful API is to validate the schema, which is the structure and definition of the data. The schema can be specified using a standard format, such as JSON Schema or XML Schema, and it ...
🌐
HCL Software
help.hcl-software.com › commerce › 7.0.0 › com.ibm.commerce.webservices.doc › refs › rwvrestxmlformat.html
REST response formats
REST services support JSON and XML formats for input and output data by default. The default format is JSON.
🌐
MS Charhag
mscharhag.com › api-design › rest-error-format
A standardized error format for HTTP responses
August 15, 2022 - RFC 7807 defines a standardized format for a more detailed problem descriptions within the body of an HTTP response. Before coming up with just another custom error response format, it might be a good idea to look at the RFC 7807 problem format. ... I am a Java Web Developer, Stackoverflower ...
🌐
Baeldung
baeldung.com › home › rest › best practices for rest api error handling
Best Practices for REST API Error Handling | Baeldung
May 11, 2024 - curl -X GET -H "Accept: application/json" http://localhost:8082/spring-rest/api/book/1 · If there is no book with an ID of 1, we expect that our controller will throw a BookNotFoundException. Performing a GET on this endpoint, we see that this exception was thrown, and this is the response body: