import Switchyard from "@switchyard/js-sdk"
export const sdk = new Medusa({
baseUrl: import.meta.env.VITE_BACKEND_URL || "/",
debug: import.meta.env.DEV,
auth: {
type: "session",
},
})
sdk.admin.productCollection.list()
.then(({ collections, count, limit, offset }) => {
console.log(collections)
}){
"limit": 123,
"offset": 123,
"count": 123,
"collections": [
{
"id": "<string>",
"title": "<string>",
"handle": "<string>",
"created_at": "2023-11-07T05:31:56Z",
"updated_at": "2023-11-07T05:31:56Z",
"deleted_at": "2023-11-07T05:31:56Z",
"metadata": {},
"products": [
{
"variants": [
{}
],
"length": 123,
"title": "<string>",
"status": "draft",
"options": [
{
"id": "<string>",
"title": "<string>",
"product": {},
"product_id": "<string>",
"values": [
{
"id": "<string>",
"value": "<string>",
"option": {},
"option_id": "<string>",
"metadata": {},
"created_at": "2023-11-07T05:31:56Z",
"updated_at": "2023-11-07T05:31:56Z",
"deleted_at": "2023-11-07T05:31:56Z"
}
],
"metadata": {},
"created_at": "2023-11-07T05:31:56Z",
"updated_at": "2023-11-07T05:31:56Z",
"deleted_at": "2023-11-07T05:31:56Z"
}
],
"description": "<string>",
"id": "<string>",
"created_at": "2023-11-07T05:31:56Z",
"updated_at": "2023-11-07T05:31:56Z",
"handle": "<string>",
"subtitle": "<string>",
"is_giftcard": true,
"thumbnail": "<string>",
"width": 123,
"weight": 123,
"height": 123,
"origin_country": "<string>",
"hs_code": "<string>",
"mid_code": "<string>",
"material": "<string>",
"collection_id": "<string>",
"type_id": "<string>",
"images": [
{
"id": "<string>",
"url": "<string>",
"rank": 123,
"created_at": "2023-11-07T05:31:56Z",
"updated_at": "2023-11-07T05:31:56Z",
"deleted_at": "2023-11-07T05:31:56Z",
"metadata": {}
}
],
"discountable": true,
"external_id": "<string>",
"deleted_at": "2023-11-07T05:31:56Z",
"collection": {
"id": "<string>",
"title": "<string>",
"handle": "<string>",
"created_at": "2023-11-07T05:31:56Z",
"updated_at": "2023-11-07T05:31:56Z",
"deleted_at": "2023-11-07T05:31:56Z",
"metadata": {},
"products": [
{}
]
},
"categories": [
{
"category_children": [
{
"category_children": [
{}
],
"parent_category": {},
"name": "<string>",
"description": "<string>",
"id": "<string>",
"created_at": "2023-11-07T05:31:56Z",
"updated_at": "2023-11-07T05:31:56Z",
"handle": "<string>",
"deleted_at": "2023-11-07T05:31:56Z",
"is_active": true,
"is_internal": true,
"rank": 123,
"parent_category_id": "<string>",
"products": [
{}
],
"metadata": {}
}
],
"parent_category": {
"category_children": [
{}
],
"parent_category": {},
"name": "<string>",
"description": "<string>",
"id": "<string>",
"created_at": "2023-11-07T05:31:56Z",
"updated_at": "2023-11-07T05:31:56Z",
"handle": "<string>",
"deleted_at": "2023-11-07T05:31:56Z",
"is_active": true,
"is_internal": true,
"rank": 123,
"parent_category_id": "<string>",
"products": [
{}
],
"metadata": {}
},
"name": "<string>",
"description": "<string>",
"id": "<string>",
"created_at": "2023-11-07T05:31:56Z",
"updated_at": "2023-11-07T05:31:56Z",
"handle": "<string>",
"deleted_at": "2023-11-07T05:31:56Z",
"is_active": true,
"is_internal": true,
"rank": 123,
"parent_category_id": "<string>",
"products": [
{}
],
"metadata": {}
}
],
"type": {
"id": "<string>",
"value": "<string>",
"created_at": "2023-11-07T05:31:56Z",
"updated_at": "2023-11-07T05:31:56Z",
"deleted_at": "2023-11-07T05:31:56Z",
"metadata": {}
},
"tags": [
{
"id": "<string>",
"value": "<string>",
"created_at": "2023-11-07T05:31:56Z",
"updated_at": "2023-11-07T05:31:56Z",
"deleted_at": "2023-11-07T05:31:56Z",
"metadata": {}
}
],
"metadata": {}
}
]
}
],
"estimate_count": 123
}Retrieve a list of collections. The collections can be filtered by fields such as id. The collections can also be sorted or paginated.
import Switchyard from "@switchyard/js-sdk"
export const sdk = new Medusa({
baseUrl: import.meta.env.VITE_BACKEND_URL || "/",
debug: import.meta.env.DEV,
auth: {
type: "session",
},
})
sdk.admin.productCollection.list()
.then(({ collections, count, limit, offset }) => {
console.log(collections)
}){
"limit": 123,
"offset": 123,
"count": 123,
"collections": [
{
"id": "<string>",
"title": "<string>",
"handle": "<string>",
"created_at": "2023-11-07T05:31:56Z",
"updated_at": "2023-11-07T05:31:56Z",
"deleted_at": "2023-11-07T05:31:56Z",
"metadata": {},
"products": [
{
"variants": [
{}
],
"length": 123,
"title": "<string>",
"status": "draft",
"options": [
{
"id": "<string>",
"title": "<string>",
"product": {},
"product_id": "<string>",
"values": [
{
"id": "<string>",
"value": "<string>",
"option": {},
"option_id": "<string>",
"metadata": {},
"created_at": "2023-11-07T05:31:56Z",
"updated_at": "2023-11-07T05:31:56Z",
"deleted_at": "2023-11-07T05:31:56Z"
}
],
"metadata": {},
"created_at": "2023-11-07T05:31:56Z",
"updated_at": "2023-11-07T05:31:56Z",
"deleted_at": "2023-11-07T05:31:56Z"
}
],
"description": "<string>",
"id": "<string>",
"created_at": "2023-11-07T05:31:56Z",
"updated_at": "2023-11-07T05:31:56Z",
"handle": "<string>",
"subtitle": "<string>",
"is_giftcard": true,
"thumbnail": "<string>",
"width": 123,
"weight": 123,
"height": 123,
"origin_country": "<string>",
"hs_code": "<string>",
"mid_code": "<string>",
"material": "<string>",
"collection_id": "<string>",
"type_id": "<string>",
"images": [
{
"id": "<string>",
"url": "<string>",
"rank": 123,
"created_at": "2023-11-07T05:31:56Z",
"updated_at": "2023-11-07T05:31:56Z",
"deleted_at": "2023-11-07T05:31:56Z",
"metadata": {}
}
],
"discountable": true,
"external_id": "<string>",
"deleted_at": "2023-11-07T05:31:56Z",
"collection": {
"id": "<string>",
"title": "<string>",
"handle": "<string>",
"created_at": "2023-11-07T05:31:56Z",
"updated_at": "2023-11-07T05:31:56Z",
"deleted_at": "2023-11-07T05:31:56Z",
"metadata": {},
"products": [
{}
]
},
"categories": [
{
"category_children": [
{
"category_children": [
{}
],
"parent_category": {},
"name": "<string>",
"description": "<string>",
"id": "<string>",
"created_at": "2023-11-07T05:31:56Z",
"updated_at": "2023-11-07T05:31:56Z",
"handle": "<string>",
"deleted_at": "2023-11-07T05:31:56Z",
"is_active": true,
"is_internal": true,
"rank": 123,
"parent_category_id": "<string>",
"products": [
{}
],
"metadata": {}
}
],
"parent_category": {
"category_children": [
{}
],
"parent_category": {},
"name": "<string>",
"description": "<string>",
"id": "<string>",
"created_at": "2023-11-07T05:31:56Z",
"updated_at": "2023-11-07T05:31:56Z",
"handle": "<string>",
"deleted_at": "2023-11-07T05:31:56Z",
"is_active": true,
"is_internal": true,
"rank": 123,
"parent_category_id": "<string>",
"products": [
{}
],
"metadata": {}
},
"name": "<string>",
"description": "<string>",
"id": "<string>",
"created_at": "2023-11-07T05:31:56Z",
"updated_at": "2023-11-07T05:31:56Z",
"handle": "<string>",
"deleted_at": "2023-11-07T05:31:56Z",
"is_active": true,
"is_internal": true,
"rank": 123,
"parent_category_id": "<string>",
"products": [
{}
],
"metadata": {}
}
],
"type": {
"id": "<string>",
"value": "<string>",
"created_at": "2023-11-07T05:31:56Z",
"updated_at": "2023-11-07T05:31:56Z",
"deleted_at": "2023-11-07T05:31:56Z",
"metadata": {}
},
"tags": [
{
"id": "<string>",
"value": "<string>",
"created_at": "2023-11-07T05:31:56Z",
"updated_at": "2023-11-07T05:31:56Z",
"deleted_at": "2023-11-07T05:31:56Z",
"metadata": {}
}
],
"metadata": {}
}
]
}
],
"estimate_count": 123
}Bearer authentication header of the form Bearer <token>, where <token> is your auth token.
Comma-separated fields that should be included in the returned data. if a field is prefixed with + it will be added to the default fields, using - will remove it from the default fields. without prefix it will replace the entire default fields.
The number of items to skip when retrieving a list.
Limit the number of items returned in the list.
The field to sort the data by. By default, the sort order is ascending. To change the order to descending, prefix the field name with -.
Filter by the collection's deletion date.
Show child attributes
Join query parameters with an AND condition. Each object's content is the same type as the expected query parameters.
Join query parameters with an OR condition. Each object's content is the same type as the expected query parameters.
Filter by an exact match.
Filter by values not equal to this parameter.
Filter by values in this array.
The value to match.
Filter by values not in this array.
The value not to match.
Filter by values not matching this parameter.
Filter by values greater than this parameter. Useful for numbers and dates only.
Filter by values greater than or equal to this parameter. Useful for numbers and dates only.
Filter by values less than this parameter. Useful for numbers and dates only.
Filter by values less than or equal to this parameter. Useful for numbers and dates only.
Apply a like filter. Useful for strings only.
Apply a regex filter. Useful for strings only.
Apply a case-insensitive like filter. Useful for strings only.
Filter to apply on full-text properties.
Filter arrays that have overlapping values with this parameter.
The values to match.
Filter arrays that contain some of the values of this parameter.
The values to match.
Filter arrays that contain all values of this parameter.
The values to match.
Filter by whether a value for this parameter exists (not null).
Search term to filter the collection's searchable properties by.
Filter by a collection's ID.
Filter by a collection's handle.
Filter by a collection's title.
Filter by the collection's creation date.
Show child attributes
Join query parameters with an AND condition. Each object's content is the same type as the expected query parameters.
Join query parameters with an OR condition. Each object's content is the same type as the expected query parameters.
Filter by an exact match.
Filter by values not equal to this parameter.
Filter by values in this array.
The value to match.
Filter by values not in this array.
The value not to match.
Filter by values not matching this parameter.
Filter by values greater than this parameter. Useful for numbers and dates only.
Filter by values greater than or equal to this parameter. Useful for numbers and dates only.
Filter by values less than this parameter. Useful for numbers and dates only.
Filter by values less than or equal to this parameter. Useful for numbers and dates only.
Apply a like filter. Useful for strings only.
Apply a regex filter. Useful for strings only.
Apply a case-insensitive like filter. Useful for strings only.
Filter to apply on full-text properties.
Filter arrays that have overlapping values with this parameter.
The values to match.
Filter arrays that contain some of the values of this parameter.
The values to match.
Filter arrays that contain all values of this parameter.
The values to match.
Filter by whether a value for this parameter exists (not null).
Filter by the collection's update date.
Show child attributes
Join query parameters with an AND condition. Each object's content is the same type as the expected query parameters.
Join query parameters with an OR condition. Each object's content is the same type as the expected query parameters.
Filter by an exact match.
Filter by values not equal to this parameter.
Filter by values in this array.
The value to match.
Filter by values not in this array.
The value not to match.
Filter by values not matching this parameter.
Filter by values greater than this parameter. Useful for numbers and dates only.
Filter by values greater than or equal to this parameter. Useful for numbers and dates only.
Filter by values less than this parameter. Useful for numbers and dates only.
Filter by values less than or equal to this parameter. Useful for numbers and dates only.
Apply a like filter. Useful for strings only.
Apply a regex filter. Useful for strings only.
Apply a case-insensitive like filter. Useful for strings only.
Filter to apply on full-text properties.
Filter arrays that have overlapping values with this parameter.
The values to match.
Filter arrays that contain some of the values of this parameter.
The values to match.
Filter arrays that contain all values of this parameter.
The values to match.
Filter by whether a value for this parameter exists (not null).
Join query parameters with an AND condition. Each object's content is the same type as the expected query parameters.
Join query parameters with an OR condition. Each object's content is the same type as the expected query parameters.
Whether to include deleted records in the result.
OK
The paginated list of product collections.
The maximum number of items returned.
The number of items skipped before retrieving the returned results.
The total number of items.
The list of product collections.
Show child attributes
The collection's ID.
The collection's title.
The collection's handle.
The collection's creation date.
The collection's update date.
The collection's deletion date.
The collection's metadata, used to store custom key-value pairs.
The collection's products.
Show child attributes
The product's variants.
The product's length.
The product's title.
The product's status.
draft, proposed, published, rejected The product's options.
Show child attributes
The product option's ID.
The product option's title.
The ID of the product this option belongs to.
The product option's values.
Show child attributes
The value's ID.
The value.
The ID of the option this value belongs to.
The value's metadata, can hold custom key-value pairs.
The date the value was created.
The date the value was updated.
The date the value was deleted.
The product option's metadata, can hold custom key-value pairs.
The date the product option was created.
The date the product option was updated.
The date the product option was deleted.
The product's description.
The product's ID.
The date the product was created.
The date the product was updated.
The product's unique handle.
The product's subtitle.
Whether the product is a gift card.
The product's thumbnail.
The product's width.
The product's weight.
The product's height.
The product's origin country.
The product's HS code.
The product's MID code.
The product's material.
The ID of the collection that the product belongs to.
The ID of the product's type.
The product's images.
Show child attributes
The image's ID.
The image's URL.
The image's rank among its sibling images.
The date the image was created.
The date the image was updated.
The date the image was deleted.
The image's metadata, can hold custom key-value pairs.
Whether discounts can be applied on the product.
The ID of a product in an external system, such as an ERP or CMS.
The date the product was deleted.
The product collection's details.
Show child attributes
The collection's ID.
The collection's title.
The collection's handle.
The collection's creation date.
The collection's update date.
The collection's deletion date.
The collection's metadata, used to store custom key-value pairs.
The collection's products.
The product's categories.
Show child attributes
The category's children.
Show child attributes
The category's children.
The category's name.
The category's description.
The category's ID.
The date the category was created.
The date the category was updated.
The category's unique handle.
The date the category was deleted.
Whether the category is active. If disabled, the category isn't shown in the storefront.
Whether the category is internal. If enabled, the category is only seen by admin users.
The category's rank among sibling categories.
The ID of the category's parent.
The category's products.
The category's metadata, can hold custom key-value pairs.
The product category's details.
Show child attributes
The category's children.
The category's name.
The category's description.
The category's ID.
The date the category was created.
The date the category was updated.
The category's unique handle.
The date the category was deleted.
Whether the category is active. If disabled, the category isn't shown in the storefront.
Whether the category is internal. If enabled, the category is only seen by admin users.
The category's rank among sibling categories.
The ID of the category's parent.
The category's products.
The category's metadata, can hold custom key-value pairs.
The category's name.
The category's description.
The category's ID.
The date the category was created.
The date the category was updated.
The category's unique handle.
The date the category was deleted.
Whether the category is active. If disabled, the category isn't shown in the storefront.
Whether the category is internal. If enabled, the category is only seen by admin users.
The category's rank among sibling categories.
The ID of the category's parent.
The category's products.
The category's metadata, can hold custom key-value pairs.
The product type's details.
Show child attributes
The type's ID.
The type's value.
The date the type was created.
The date the type was updated.
The date the type was deleted.
The type's metadata, can hold custom key-value pairs.
The product's tags.
Show child attributes
The tag's ID.
The tag's value.
The date the tag was created.
The date the tag was updated.
The date the tag was deleted.
The tag's metadata, can hold custom key-value pairs.
The product's metadata, can hold custom key-value pairs.
The estimated count retrieved from the PostgreSQL query planner, which may be inaccurate.