Ecommerce: Categories
GET /shops/{shopId}/categories
Sending GET request to this url, returns collection of CATEGORIES resources that belong to given shop.
You can narrow down list of resources by passing proper query parameters (list of which you can find below in request params section). You can basically search by:
- name
- createdOn
- parentId
`name` fields can be a pattern and we will try to match this phrase.
`parentId` will search for sub-categories of given parent category
You can specify which page of results you want and how many results per page should be there. You can also specify sort-order using one or more of allowed fields (listed below in request params section).
Last but not least you can even specify which fields from resource you want to get. If you pass param `fields` with list of fields (separated by comma [,]) we will return list of resources with only those fields (we will always add resource id to ensure that you can use that data later on)
Returns status code
200
Request url
/shops/p/categories?query[name]=foo&query[parentId]=k&query[createdOn][from]=2010-10-13&query[createdOn][to]=2020-03-15
Request params
Field name | Field type | Field description | |||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
query | hash | Used to search only resources that meets criteria. You can specify multiple parameters, then it uses AND logic.
| |||||||||||||||
fields | string | List of fields that should be returned. Id is always returned. Fields should be separated by comma | |||||||||||||||
sort | hash | Enable sorting using specified field (set as a key) and order (set as a value). You can specify multiple fields to sort by.
| |||||||||||||||
perPage | int | Number results on page | |||||||||||||||
page | int | Page number |
Example Response
[
{
"categoryId": "p",
"parentId": null,
"externalId": null,
"href": "https://api.getresponse.com/v3/shops/p/categories/p",
"name": "category-58da4383b8af6",
"url": null,
"createdOn": "2017-03-28T11:05:38+0000",
"updatedOn": "2017-03-28T11:05:38+0000"
},
{
"categoryId": "Vt",
"parentId": null,
"externalId": "myExtID",
"href": "https://api.getresponse.com/v3/shops/p/categories/Vt",
"name": "category-58da4383b8b0c",
"url": null,
"createdOn": "2017-03-28T11:05:38+0000",
"updatedOn": "2017-03-28T11:05:38+0000"
}
]
Possible Errors
POST /shops/{shopId}/categories
Create shop category. You can pass "parentId" parameter to create sub-category of given parent. Unlike most POST methods this call is idempotent, that is: sending same request 10 times will not create 10 new categories, only one will be created
Returns status code
201
Example Request Body
{
"name": "foo",
"parentId": "ldsf",
"externalId": "extID-333",
"url": "http://someurl.com"
}
Body params
Field name | Field type | Field description |
---|---|---|
name (required) | string | Name of the category |
parentId | string | Id of parent category |
externalId | string | External Id of category |
url | string | External url of the category |
Example Response
{
"categoryId": "Bd",
"parentId": "ldsf",
"externalId": "extID-333",
"href": "https://api.getresponse.com/v3/shops/p/categories/Bd",
"name": "foo",
"url": "http://someurl.com",
"createdOn": "2017-03-28T13:16:50+0000",
"updatedOn": "2017-03-28T13:16:50+0000"
}
Possible Errors
POST /shops/{shopId}/categories/{categoryId}
Update properties of shops category. You can specify parentId to assign category as sub-category of existing category. You should send only those fields that need to be changed. The rest of properties will stay the same.
Returns status code
200
Example Request Body
{
"name": "foo",
"parentId": "ldsf",
"externalId": "ID123",
"url": "http://someurl.com"
}
Body params
Field name | Field type | Field description |
---|---|---|
name (required) | string | Name of the category |
parentId | string | Id of parent category |
externalId | string | External Id of category |
url | string | External url of the category |
Example Response
{
"categoryId": "Bd",
"parentId": "ldsf",
"externalId": "ID123",
"href": "https://api.getresponse.com/v3/shops/p/categories/Bd",
"name": "bar",
"url": "http://someurl.com",
"createdOn": "2017-03-28T13:16:50+0000",
"updatedOn": "2017-03-28T13:16:50+0000"
}
Possible Errors
GET /shops/{shopId}/categories/{categoryId}
Method returns category according to given categoryId
Returns status code
200
Request url
/shops/V/categories/p?fields=name
Request params
Field name | Field type | Field description |
---|---|---|
fields | string | List of fields that should be returned. Id is always returned. Fields should be separated by comma |
Example Response
{
"categoryId": "p",
"parentId": null,
"externalId": null,
"href": "https://api.getresponse.com/v3/shops/p/categories/p",
"name": "category-58da4383b8af6",
"url": null,
"createdOn": "2017-03-28T11:05:38+0000",
"updatedOn": "2017-03-28T11:05:38+0000"
}