Collection API
Endpoints
Create a Collection
Creates a new product collection.
Request Schema (application/json)
| Field Name | Field Type | Required |
|---|---|---|
| name | string | No |
| description | string | No |
| code | string | No |
POST/api/collections
- cURL
- JavaScript
curl
-H "Accept: application/json"
-H "Authorization: Bearer <admin JWT token>"
--data-raw '<JSON DATA>'
https://<your domain>/api/collections
fetch('https://<your domain>/api/collections', {
headers: {
'Accept': 'application/json',
'Authorization': 'Bearer <admin JWT token>'
},
body: <JSON DATA>
})
.then(response => response.json())
.then(data => {
if(data.error) {
// Handle the error
} else {
// Handle the data
}
})
.catch(error => {
// Handle the error
});
Sample Of Response
{
"data": {
"collection_id": 5,
"uuid": "a1b2c3d4-e5f6-7890-abcd-ef1234567890",
"name": "Summer Sale",
"code": "summer-sale",
"description": "Products on sale for summer"
}
}
Update a Collection
Updates an existing product collection.
Request Schema (application/json)
| Field Name | Field Type | Required |
|---|---|---|
| name | string | No |
| description | string | No |
| code | string | No |
PATCH/api/collections/{id}
- cURL
- JavaScript
curl
-H "Accept: application/json"
-H "Authorization: Bearer <admin JWT token>"
--data-raw '<JSON DATA>'
https://<your domain>/api/collections/{id}
fetch('https://<your domain>/api/collections/{id}', {
headers: {
'Accept': 'application/json',
'Authorization': 'Bearer <admin JWT token>'
},
body: <JSON DATA>
})
.then(response => response.json())
.then(data => {
if(data.error) {
// Handle the error
} else {
// Handle the data
}
})
.catch(error => {
// Handle the error
});
Sample Of Response
{
"data": {
"collection_id": 5,
"uuid": "a1b2c3d4-e5f6-7890-abcd-ef1234567890",
"name": "Summer Sale 2024",
"code": "summer-sale"
}
}
Delete a Collection
Permanently removes a collection. Products in the collection are not deleted.
Request Schema (application/json)
No request body requiredDELETE/api/collections/{id}
- cURL
- JavaScript
curl
-H "Accept: application/json"
-H "Authorization: Bearer <admin JWT token>"
https://<your domain>/api/collections/{id}
fetch('https://<your domain>/api/collections/{id}', {
headers: {
'Accept': 'application/json',
'Authorization': 'Bearer <admin JWT token>'
}
})
.then(response => response.json())
.then(data => {
if(data.error) {
// Handle the error
} else {
// Handle the data
}
})
.catch(error => {
// Handle the error
});
Sample Of Response
{
"data": {
"collection_id": 5,
"uuid": "a1b2c3d4-e5f6-7890-abcd-ef1234567890"
}
}
Add Product to Collection
Adds an existing product to a collection.
Request Schema (application/json)
| Field Name | Field Type | Required |
|---|---|---|
| product_id | string | Yes |
POST/api/collections/{collection_id}/products
- cURL
- JavaScript
curl
-H "Accept: application/json"
-H "Authorization: Bearer <admin JWT token>"
--data-raw '<JSON DATA>'
https://<your domain>/api/collections/{collection_id}/products
fetch('https://<your domain>/api/collections/{collection_id}/products', {
headers: {
'Accept': 'application/json',
'Authorization': 'Bearer <admin JWT token>'
},
body: <JSON DATA>
})
.then(response => response.json())
.then(data => {
if(data.error) {
// Handle the error
} else {
// Handle the data
}
})
.catch(error => {
// Handle the error
});
Sample Of Response
{
"data": {
"success": true
}
}
Remove Product from Collection
Removes a product from a collection. The product itself is not deleted.
Request Schema (application/json)
No request body requiredDELETE/api/collections/{collection_id}/products/{product_id}
- cURL
- JavaScript
curl
-H "Accept: application/json"
-H "Authorization: Bearer <admin JWT token>"
https://<your domain>/api/collections/{collection_id}/products/{product_id}
fetch('https://<your domain>/api/collections/{collection_id}/products/{product_id}', {
headers: {
'Accept': 'application/json',
'Authorization': 'Bearer <admin JWT token>'
}
})
.then(response => response.json())
.then(data => {
if(data.error) {
// Handle the error
} else {
// Handle the data
}
})
.catch(error => {
// Handle the error
});
Sample Of Response
{
"data": {
"success": true
}
}
Get Collection Data with GraphQL
EverShop uses GraphQL for querying collection data. For detailed information on how to query collections, refer to the GraphQL API documentation.