Search Product
You can search contents exist in store at front-end interface by searching Ajax API
Request information
API Path:
GET https://{handle}.myshopline.com/api/product/search/suggest.json
Request query:
| Parameter name | Parameter type | Whether is array | Required or optional | Example | Description |
|---|---|---|---|---|---|
| q | String | No | Yes | shirt | The content to search. |
| field | String | No | Yes | title,product_type | The fields to be searched and operations: - title - product_type - tag - variants.sku - brand |
| resource_type | String | No | Yes | product | The type of result requested: - product - collection - page - article - query |
| available_type | String | No | Yes | show | Specifies the type of products to return, supported parameters are: show, hide. |
| limit | String | No | No | 10 | An integer from 1 to 30. If not provided or invalid, it defaults to 30. |
| limit_scope | String | No | No | each | each: means returning the first limit records for each resource_type. all: means returning the first limit records according to the following priority. - query - product - collections - article - page |
Response information
Response body:
| Parameter name | Parameter name | Parameter name | Parameter type | Whether is array | Example | Description |
|---|---|---|---|---|---|---|
| message | String | No | ||||
| description | String | No | ||||
| products | Object | This is an array of products. | ||||
| id | String | No | This is the product ID. | |||
| title | String | No | This is the product title. | |||
| handle | String | No | This is the product handle. | |||
| url | String | No | This is the product's relative path, formatted as /products/handle. | |||
| description | String | No | This is the product description. | |||
| brand | String | No | This is the brand name. | |||
| tags | List<String> | No | This is an array of product tags. | |||
| images | List<String> | No | This is an array of product main images. | |||
| featured_image | String | No | This is the product's featured image, the same as images[0]. | |||
| medias | Object | |||||
| resource | String | No | This is the resource location in URL format. | |||
| cover | String | No | This is the cover image location in URL format. | |||
| type | String | No | This is the media resource type. | |||
| alt | String | No | These are words or phrases describing the image feature or content. | |||
| sold_out | Boolean | No | This indicates whether the product is sold out. | |||
| price | Long | No | This is the product price. | |||
| price_min | Long | No | This is the minimum product price. | |||
| price_max | Long | No | This is the maximum product price. | |||
| price_varies | Boolean | No | This indicates whether the minimum and maximum prices of product variants are the same. | |||
| compare_at_price | Long | No | This is the original price of the variant, the same as compareAtPriceMin. | |||
| compare_at_price_min | Long | No | This is the minimum original price of the variant. | |||
| compare_at_price_max | Long | No | This is the maximum original price of the variant. | |||
| compare_at_price_varies | Boolean | No | This indicates whether the minimum and maximum original prices of product variants are the same. | |||
| created_at | Date | No | This is the product creation time. | |||
| published_at | Date | No | This is the product publish time. | |||
| options | Object | This is an array of options. | ||||
| name | String | No | This is the option name. | |||
| values | List<String> | No | These are the option values. | |||
| values_images | Map<String,String> | No | This is a mapping dictionary of option values and option value images. | |||
| variants | Object | This is an array of variants. | ||||
| id | String | No | This is the variant ID. | |||
| barcode | String | No | This is the barcode. | |||
| title | String | No | This is the variant title. | |||
| option1 | String | No | This is the first option value of the variant. | |||
| option2 | String | No | This is the second option value of the variant. | |||
| option3 | String | No | This is the third option value of the variant. | |||
| option4 | String | No | This is the fourth option value of the variant. | |||
| option5 | String | No | This is the fifth option value of the variant. | |||
| sku | String | No | This is the variant SKU. | |||
| featured_image | String | No | This is the variant image. | |||
| name | String | No | This is the variant name, formatted as Product title · Variant title. | |||
| public_title | String | No | This is the public title, the same as variant.title. | |||
| options | List<String> | No | These are the variant options array. | |||
| weight | BigDecimal | No | This is the weight. | |||
| weight_unit | String | No | This is the weight unit. | |||
| price | Long | No | This is the variant price, in the smallest currency unit. | |||
| compare_at_price | Long | No | This is the variant original price, in the smallest currency unit. | |||
| inventory_policy | String | No | This indicates whether overselling is allowed, continue: allowed, deny: not allowed. | |||
| inventory_tracker | Boolean | No | This indicates whether to track inventory, default is false. | |||
| collections | List<Object> | No | This is an array of collections. | |||
| id | String | Yes | This is the collection ID. | |||
| handle | String | Yes | This is the collection handle. | |||
| title | String | Yes | This is the collection title. | |||
| url | String | Yes | This is the collection relative path, formatted as /collections/handle. | |||
| published_at | String | Yes | This is the time published to the online store channel. | |||
| body | String | No | This is the collection description. | |||
| featured_image | This is the collection featured image. | |||||
| alt | String | No | These are words or phrases describing the image feature or content. | |||
| height | Integer | No | This is the image height. | |||
| width | Integer | No | This is the image width. | |||
| url | String | Yes | This is the image location in URL format. | |||
| queries | List<Object> | No | This is an array of recommended queries. | |||
| text | String | Yes | This is the recommended query. | |||
| url | String | Yes | This is the link to the search results page for the query. | |||
| pages | List<Object> | No | This is an array of custom pages. | |||
| id | String | Yes | This is the page ID. | |||
| handle | String | Yes | This is the page handle. | |||
| title | String | Yes | This is the page title. | |||
| url | String | Yes | This is the page relative path, formatted as /pages/handle. | |||
| author | String | No | This is the page author. | |||
| body | String | No | This is the page content. | |||
| published_at | String | No | This is the time published to the online store channel. | |||
| articles | List<Object> | No | This is an array of blogs. | |||
| id | String | Yes | This is the blog ID. | |||
| handle | String | Yes | This is the blog handle. | |||
| title | String | No | This is the blog title. | |||
| url | String | Yes | This is the blog relative path, formatted as /blogs/handle. | |||
| summary_html | String | No | This is the blog summary. | |||
| published_at | String | No | This is the time published to the online store channel. | |||
| featured_image | Object | No | This is the blog featured image. | |||
| alt | String | No | These are words or phrases describing the image feature or content. | |||
| height | Integer | No | This is the image height. | |||
| width | Integer | No | This is the image width. | |||
| url | String | Yes | This is the image location in URL format. |
Request/response examples
Scenario : Search for products whose product name contains dress
Request
fetch("https://linxiaofa14.myshoplinedev.com/api/product/search/suggest.json?q=dress&field=title&resource_type=product&available_type=show&limit=1")
response
"queries": [
{
"text": "100",
"url": "/search?keyword=100"
}
],
"products": [
{
"id": "16060168376183564632570904",
"title": "product",
"handle": "product",
"description": null,
"brand": null,
"vendor": null,
"tags": null,
"images": null,
"price": 11100,
"options": [
{
"name": "Color",
"values": [
"red",
"blue"
],
"values_images": {
"red": null,
"blue": null
}
}
],
"variants": [
{
"id": "18060168376188765569600904",
"barcode": null,
"title": "red",
"option1": "red",
"option2": null,
"option3": null,
"option4": null,
"option5": null,
"sku": null,
"name": "product · red",
"options": [
"red"
],
"weight": null,
"price": 11100,
"available": true,
"featured_image": null,
"public_title": "red",
"weight_unit": null,
"compare_at_price": 22200,
"inventory_policy": "deny",
"inventory_tracker": true,
"requires_selling_plan": false,
"selling_plan_alloactions": [
],
"featured_image_v2": null
},
{
"id": "18060168376188765569640904",
"barcode": null,
"title": "blue",
"option1": "blue",
"option2": null,
"option3": null,
"option4": null,
"option5": null,
"sku": "",
"name": "product · blue",
"options": [
"blue"
],
"weight": null,
"price": 11100,
"available": true,
"featured_image": null,
"public_title": "blue",
"weight_unit": null,
"compare_at_price": 22200,
"inventory_policy": "deny",
"inventory_tracker": true,
"requires_selling_plan": false,
"selling_plan_alloactions": [
],
"featured_image_v2": null
}
],
"visible": true,
"url": "/products/评分100.99--商品002",
"featured_image": null,
"medias": [
],
"sold_out": false,
"price_min": 11100,
"price_max": 11100,
"price_varies": true,
"compare_at_price": 22200,
"compare_at_price_min": 22200,
"compare_at_price_max": 22200,
"compare_at_price_varies": true,
"created_at": "2023-07-10T11:26:18.087+08:00",
"published_at": "2023-07-10T11:26:18.148+08:00",
"requires_selling_plan": false,
"selling_plan_groups": [
],
"featured_image_v2": null,
"custom_category_name": ""
}
],
"collections": [
{
"body": "new collections",
"handle": "new--001--1061392384",
"id": "12260161333887589518440904",
"title": "new collections",
"url": "/collections/new--001--1061392384",
"featured_image": {
"alt": "cover",
"width": 1154,
"height": 642,
"url": "https://d2n979dmt31clo.cloudfront.net/image/store/4200012610/1625907878650/d7614fad260b448a810ce7de0a524997.png?w=1154&h=642",
"aspect_ratio": null
},
"published_at": "2023-07-09T23:46:42.691+08:00"
}
],
"pages": [
{
"author": "4200012610",
"handle": "store",
"id": "5980852662048395303",
"title": "store",
"url": "/pages/store",
"published_at": "2023-06-15T15:38:00.000+08:00"
}
],
"articles": [
{
"author": "sgstore",
"handle": "news/123",
"id": "648ab1a0f301e236c33c9d69",
"title": "123",
"url": "/blogs/news/123",
"featured_image": null,
"published_at": "2023-06-15T14:37:00.000+08:00",
"summary_html": "123"
}
]
}
Was this article helpful to you?