Response Format

All endpoints that return non binary data will return JSON. The format of the JSON content will depend on the HTTP response. Successful responses are structured as follows:

{
    "data": {
        // resource data
    },
    "links": {
        // Any links related to the resource(s)
    },
    "meta": {

    }
}

The data key is always present and represents the data of the requested resource. The links and meta keys are only present when additional information needs to be provided to nativagate the requested resource, i.e: paginated responses.

Paginated Responses

When making a request for more than one resource, the API will usually respond with a paginated list of resources. The paginated response will be formatted as follows:

{
    "data": [],
    "links": {
        "first": "https://...",
        "last": "https://...",
        "prev": "https://...",
        "next": "https://..."
    },
    "meta": {
        "current_page": 1,
        "from": 1,
        "last_page": 20,
    "links": [
    {
        "url": null,
        "label": "« Previous",
        "active": false
    },
    {
        "url": "https://...",
        "label": "1",
        "active": true
    },
    {
        "url": "https://...",
        "label": "2",
        "active": false
    },

    // ...

    {
        "url": "https://...",
        "label": "Next »",
        "active": false
    }
    ],
    "path": "https://...",
    "per_page": 20,
    "to": 20,
    "total": 120
    },
}

When a response is paginated, the data key will contain an array of objects instead of a single resource object.

Error responses

If an error is returned, a the JSON returned won't include data key. Instead the error response will be structured as follows:

{
    "message": "Error message"
}

In the case of a 422 error, additional validation error messages are provided through an errors key:

{
    "message": "The given data is invalid.",
    "errors": {
        "category": "The category slug does not exist."
    }
}

Note that the JSON object does not include any error codes. Instead the API relies on HTTP response codes to replay specific information. Do not rely on the error messages as they may change over time.

HTTP Response Codes

The MotorPress API always responds with predictable HTTP response codes. The following table provides details on the response code you can expect:

CodeDescription
200Response is all good!
204No content. The request was accepted, but the response is empty.
301The endpoint is no longer here and has been moved permanently.
304Not modified. Used almost exclusively for image data meaning the image returned is cached.
400Bad request. Means your request is badly formatted. The request should not be repeated.
401Unauthorized. The API token is either missing or invalid.
403Access to the resource is forbideen or the signature on the URL has expired.
404The requested resource is not available. Either it's been removed or never existed.
405The wrong method was used. Only GET requests are currently permitted.
422Validation error. The request is either missing some data or the data is incorrectly formatted.
429The rate limit has been reached and no additional requests can currently be made.
500This one is on us. It means we made a mistake and need to look at it.
Last Updated:
Contributors: warrick