Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

Paste code macro
languagehttp
themeSunburst
titleBasic Form
#latest version
https://api.machbasecloud.com/

#specific version 1
https://api.machbasecloud.com/v1/

Headers

paste-code-macro
languagehtmlhttp
themeSunburst
Content-Type: application/json; charset=utf8
x-api-key: {API Key}

Basic response format

The response of all requests must follow the format below, and the response in the description of each API describes only the value of the "data" key.

code
Paste code macro
languagejson
themeSunburst
{
    "status" : "success" or "fail" or "error",
    "data" : {
        ....
    }
}
{
    "status" : "success" or "fail" or "error",
    "data" : {
        ....
    }
}

When setting up a JSON API, you'll have all kinds of different types of calls and responses. JSend separates responses into some basic types, and defines required and optional keys for each type:

Type

Description

Required Keys

Optional Keys

Success

All went well, and (usually) some data was returned.

status, data

Fail

There was a problem with the data submitted, or some pre-condition of the API call wasn't satisfied

status, data

Error

An error occurred in processing the request, i.e. an exception was thrown

status, data

code, data

Example response type

  • success

paste-code-macro
languagejson
themeSunburst
{
    status : "success",
    data : {
        "tag_1" : [ .... ],
        "tag_2" : [ .... ]
    }
}

{
    status : "success",
    data : { "id" : 2, "title" : "Another blog post", "body" : "More content" }
}

{
    status : "success",
    data : null
}
  • fail : When an API call is rejected due to invalid data or call conditions.

...