The Banyan API provides a general-purpose response for all requests. When you make a request to our REST API, you will always receive two parts in each response: an array of data elements and an array of errors (the latter being empty in when a request was successful).

Data

When a successful request is made where a single item is expected, the general form of the response will be this:

{
    "data": [<ELEMENT>],
    "errors": []
}

Where the data you requested will be present as a JSON object (replacing the <ELEMENT> above).

The data is easily extracted by simply pulling out the first (and only, in this case) element of the array associated with "data".

The general form remains the same when a response contains multiple values:

{
    "data": [<ELEMENT 1>, <ELEMENT 2>, ...],
    "errors": []
}

Again, the data is easily extracted by iterating over the elements in the "data" array.

Errors

In the event that a request was not successful, the payload will attempt to clarify the reasons for whatever problem was encountered by providing one or more errors in the payload:

{
    "data": [],
    "errors": [<ERROR 1>, <ERROR 2>, ...]
}

To understand even more how responses look, including errors, please visit our API Reference.