Interact programmatically with The Marketplace Company using direct HTTP requests.
The Marketplace Company API is organized around REST. Our API has predictable resource-oriented URLs, returns JSON-encoded responses, and uses standard HTTP response codes, authentication, and verbs.
Access Tokens are required to authenticate and use the The Marketplace Company API.
Access Tokens can be created and managed from inside your account settings at Settings > Security.
Our API is exposed as an HTTP/1 and HTTP/2 service over SSL. In general, 5 types of request methods are available in most resources, those some might have few or more. We support HTTP versions 1, 1.1, and 2, although HTTP/2 is preferred.
POST - For creating new object for a resourcePUT - For full update of a resource. Requires all attributes to be provided,
and if any value is not present in the request, the attribute will be
considered as empty value.PATCH - Recommended approach for partial updatesGET - Get requests comes into two forms, one for querying a list of
attributes and the other for fetching details of a specific item. Each support
different kind of query parameters. You see more details in
Query Parameters SectionDELETE - Deletes an item using the id. (Please note that we do only
soft-delete, but still this action is irreversible)All requests must be encoded as JSON with the Content-Type: application/json
header. If not otherwise specified, responses from the our API, including
errors, are encoded exclusively as JSON as well.
Responses are returned with relevent HTTP statusCodes in the response header
(see the list of status codes), and a body which is always in
the json format. Response body may contain a success reponse or error
response. In case of error response, it contains an Error object as mentioned
in the document.
Successful response contains a json object which has two attributes in case of
GET requests- data[ ] which is always an array of records of the request
resource, and metadata which contains the information required for pagination.
For requests like POST, PUT, PATCH and DELETE (content modification
requests), the response object contains the id of the resource which was
actioned.
Below is an example response structure of the GET request for list of
records:
{
"metadata": {
"total": 200,
"hasMore": false
},
"data": [
{
//....attributes
}
]
}
All API endpoints contain a code and message within the error responses, though some API endpoints extend the error object to contain other information. Each endpoint that does this will be documented in their appropriate section.
Whenever a request is unsuccessful, the API will return an error response with an error type and message. You can use this information to understand better what has gone wrong and how to fix it. Most of the error messages are pretty helpful and actionable.
We follow a standard REST API Error format. An Error Object is defined below,
with all properties. Response from an errored API request, will be having a
valid error HTTP Response code, and an error object. Here is a list of the error
types supported by the API.
The HTTP response code of the error. Its only available on top-level error object, not on child errors (nested in a top-level error, as seen in below example section)
The error code that occurred. This is a number that can be used to identify the error.
The type of error that occurred. This is a string that can be used to identify the error.
A message to be shown to the end user, if the error is not handled by the client.
A developer friendly message, which is not meant to be shown to the end user.
"error": {
"status": 401,
"code": 01002,
"type": "authenticationFailure",
"userMessage": "Please login to continue",
"message": "request is not authenticated with a valid auth token",
},
"metadata": {
"hasData": false,
"total": 0,,
"hasMore": false,
},
"statusCode": 401,
"data": {},
Here is a list of the different categories of status codes returned by the API. Use these to understand if a request was successful.
The request was successful.
The resource was successfully created.
Bad request - ensure you have the right format for the request attributes.
Your API key is invalid or the Authentication is invalid/expired.
The authenticated user or API Key may not have permission for the resource or operation.
The resource does not exist.
A validation error occurred - check mandatory fields and other validation.
The rate limit was exceeded. Ensure you are not sending too many requests.
An error occurred with our API in one of its layers. We are alerted, and we'll be fixing it.
All the GET requests support certain query parameters. There are two kinds of
GET requets:
GET for retrieving a list of Recrods. Eg: GET api//?GET request for retrieving details of a specific record, by ID
Eg: GET api///?Below is a table of common query parameters, which are supported across entities, with the operations they are supported in, and the common use-cases.
| QueryParam Use-Case | How-To | Example |
|---|---|---|
sort To sort the records by multiple attributes | Specify the comma seperated list of sort parameters, using the sort order as prefix, specified using asc operand for ascending and desc operand for descending | api/v1/listings?sort=asc:name,desc:createdAt Returns the records sorted by name first, and by createdAt if people with same name exist |
limit For pagination. To limit the number of records in the response | Specify the number of records to be returned in an API response | api/v1/listings?limit=20 returns first 20 records |
offset For pagination. Offsets the records from the begin, based on what sort condition is applied | Specify the number of records to be be offset | api/v1/listings?offset=100&limit=20&sort=+name returns 20 records from the 101th position based on ascending sorting of name |
fields For limiting the amount of information returned | Specify a comma seperated list of fields to be returned in the response, using the query parameter fields | api/v1/listings?fields=name,description,createdAt,marketplace&limit=20 returns 20 listings with only the specified fields which are name, description, createdAt and marketplace |
| Operator | Operation | Left Column Type | Example |
|---|---|---|---|
eq | Equal To (Also the default operator, if none specified) | Any Single-Value column | /api/something?age=23 or /api/something?age=eq:23 or /api/something?name=eq:Ryan |
ne | Not Equal To | Any Single-Value column | /api/something?name=ne:Ryan |
gt | Greater Than | Any Single-Value column, but recommended for number or date | /api/something?basePrice=gt:250 |
gte | Greater Than or Equal To | Any Single-Value column, but recommended for number or date | /api/something?basePrice=gte:250 |
lt | Less Than | Any Single-Value column, but recommended for number or date | /api/something?startDate=lt:2020-05-20 |
lte | Less Than or Equal To | Any Single-Value column, but recommended for number or date | /api/something?basePrice=lte:250 |
in | Single Value on left present in any of Given Values on right | Any Single-Value column | /api/something?type=in:donatation,experience,somethingelse |
nin | Single Value on left NOT present in any of Given Values on right | Any Single-Value column | /api/something?type=nin:donatation,experience,somethingelse |
between | Only for range operator like date or number | Any Single-Value column, but recommended for number or date | /api/something?basePrice=between:100,500 (only two values, seperates by comma) |
nbetween | Only for range operator like date or number | Any Single-Value column, but recommended for number or date | /api/something?startDate=between:2020-05-20,2020-05-25 (only two values, seperates by comma) |
containsAll | multi-value column on left contains all elements of the array on right | Only Array Type columns | /api/something?tags=containsAll:tag1,tag2,tag3 |
containsAny | multi-value column on left contains atleast one element of the array on right | Only Array Type columns | /api/something?categorization.amenties=containsAny:shower,toilet,parking |
contained | multi-value column on left is a sub-set of given values on right | Only Array Type columns | /api/something?categorization.amenties=contained:shower,toilet,parking (Returns rows which has only the given amenities. If a record has one extra amentiy which is not in the provided values, that record won't be retrieved) |
withInRadius | Checks if the entity falls within given radius from given location | Only on geoLocation field, and listing entity | /api/listings?geoLocation=withInRadius:12km,20.20303444,-74.5584444 The distance comes first argument with km as unit, then latitude, followed by longitude. The order is important |
withInBounds | Checks if the entity falls within given bounding box | Only on geoLocation field, and listing entity | /api/listings?geoLocation=withInBounds:42.555,-72.666,40.040,-74.284 Bounding box is defined by Top-Left LatLng, and BottomRight-LatLng. The arguments comes in that particular order. |
keyword | Search for a keyword |
Rate Limits We limit the number of calls you can make over a certain period of time. Rate limits are tracked by IP for public endpoints, and by API key for authenticated endpoints. If you exceed the rate limits, you'll get a 429 Too Many Requests response for subsequent requests. Check the Retry-After header to see how many seconds to wait before retrying the request.
Rate limits vary and are specified by the following header in all responses:
| Header | Description |
|---|---|
| X-RateLimit-Limit | The maximum number of requests that the consumer is permitted to make. |
| X-RateLimit-Remaining | The number of requests remaining in the current rate limit window. |
| X-RateLimit-Reset | The time at which the current rate limit window resets in UTC epoch seconds. |
Rate limits are hard limits that apply to the platform when performing actions that require a response from our API.
All endpoints and examples are designated with a specific version. Versions vary per endpoint and are not global.
The response shape of a certain endpoint is not guaranteed to be fixed over time. In particular, we might add new keys to responses without bumping a version endpoint, which will be noted in the changelog.
To ensure the security and correctness of your application, make sure to only read the keys from the response that your application needs. Don't proxy entire responses to third-parties without validation.
Old versions of each endpoint are supported for as long as possible. When we intend to deprecate, we will notify users in the changelog section.
Endpoint versions follow the base URL and come before the endpoint. For example:
https:///api/v3/listings