Difference between revisions of "API Collect"
From Spiffy Stores Knowledge Base
(Created page with "The Collect resource connects a product to a standard collection. Collects are used to manage the relationship between products and standard collections. For every product in...") |
|||
(One intermediate revision by the same user not shown) | |||
Line 14: | Line 14: | ||
A unique numeric identifier for the collect. | A unique numeric identifier for the collect. | ||
|- | |- | ||
+ | !collection_id | ||
|<pre>{ "collection_id" : 3244591 }</pre> | |<pre>{ "collection_id" : 3244591 }</pre> | ||
A unique numeric identifier for the collection associated with this collect. | A unique numeric identifier for the collection associated with this collect. | ||
|- | |- | ||
+ | !product_id | ||
|<pre>{ "product_id" : 23123 }</pre> | |<pre>{ "product_id" : 23123 }</pre> | ||
A unique numeric identifier for the product associated with this collect. | A unique numeric identifier for the product associated with this collect. | ||
|- | |- | ||
+ | !position | ||
|<pre>{ "position" : 2 }</pre> | |<pre>{ "position" : 2 }</pre> | ||
The position of this product in a manually sorted collection. The first position is 1. | The position of this product in a manually sorted collection. The first position is 1. | ||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
|} | |} | ||
Latest revision as of 09:53, 22 August 2018
The Collect resource connects a product to a standard collection.
Collects are used to manage the relationship between products and standard collections. For every product in a standard collection there is a collect that tracks the ID of both the product and the standard collection. A product can be in more than one collection, and will have a collect connecting it to each collection. Unlike many Spiffy Stores resources, collects aren't directly visible to store owners.
You can only use collects to manage the products in a standard collection. Super collections use rules to determine which products are in the collection. However, you are able to get a list of all products in a super collection using the collects for that collection.
For more information on standard collections, see the StandardCollection resource.
Contents
Collect Properties
id | { "id" : 191 } A unique numeric identifier for the collect. |
---|---|
collection_id | { "collection_id" : 3244591 } A unique numeric identifier for the collection associated with this collect. |
product_id | { "product_id" : 23123 } A unique numeric identifier for the product associated with this collect. |
position | { "position" : 2 } The position of this product in a manually sorted collection. The first position is 1. |
Endpoints
GET /api/collects.json
Retrieve a list of collects.
Optional Parameters
limit | Number of results returned. The default is 30, with a maximum of 50 in a single request. |
---|---|
page | The number of the page to return. The number of results per page is set by the limit parameter. If more results are required, then submit the request again, increasing the page number each time.
|
since_id | Limit the results to only include objects which have an id greater than the given value. |
collection_id | Limit the collects to those belonging only to the collection with the given unique id or handle. |
product_id | Limit the collects to those belonging only to the product with the given unique id or handle. |
fields | A comma-separated list of fields to return in the response. |
Example Request and Response
GET /api/collects.json HTTP/1.1 200 OK { "collects": [ { "id": 18978, "collection_id": 155, "product_id": 1504, "position": 2 }, { "id": 18694, "collection_id": 155, "product_id": 1505, "position": 3 }, ... ] } Examples using filters GET /api/collects.json?fields=collection_id,product_id GET /api/collects.json?collection_id=green-things GET /api/collects.json?product_id=1505
GET /api/collects/count.json
Return a count of the number of collects.
Optional Parameters
since_id | Limit the results to only include objects which have an id greater than the given value. |
---|---|
collection_id | Limit the collects to those belonging only to the collection with the given unique id or handle. |
product_id | Limit the collects to those belonging only to the product with the given unique id or handle. |
Example Request and Response
GET /api/collects/count.json HTTP/1.1 200 OK { "count": 35 }
GET /api/collects/COLLECT_ID.json
Retrieves a single collect by ID.
Optional Parameters
fields | A comma-separated list of fields to return in the response. |
---|
Example Request and Response
GET /api/collects/190.json HTTP/1.1 200 OK { "collect": { "id": 18978, "collection_id": 155, "product_id": 1504, "position": 2 } }
POST /api/collects.json
Adds a product to a standard collection by creating a collect linking the two resources.
A product cannot be added to a super collection using this method.
Example Request and Response
POST /api/collects.json { "collect": { "collection_id": "green-things", "product_id": 1504, } } HTTP/1.1 201 Created
DELETE /api/collects/COLLECT_ID.json
Removes a product from a standard collection.
Example Request and Response
DELETE /api/collects/18978.json HTTP/1.1 200 OK {}