The ProductSearch API gives extensions access to the native product search and fetching functionality of Shopify POS. The interface provides numerous functions to search for products by query, or to fetch the details of one or more products or product variants.
Fetches a page of product variants associated with a product.
Fetches multiple products' details.
Fetches multiple product variants' details.
Fetches all product variants associated with a product.
Fetches a single product variant's details.
Fetches a single product's details.
Search for products on the POS device.
Base interface for pagination.
Specifies the page cursor. Items after this cursor will be returned.
Specifies the number of results to be returned in this page. The maximum number of items that will be returned is 50.
Contains a page of fetched results.
Whether or not there is another page of results that can be fetched.
The items returned from the fetch.
The cursor of the last item. This can be used to fetch more results. The format of this cursor may look different depending on if POS is fetching results from the remote API, or its local database. However, that should not affect its usage with the search functions.
'DENY' | 'CONTINUE'
The result of a fetch function where the input is multiple IDs. This object contains the resources that were found, as well as an array of IDs specifying which IDs, if any, did not correspond to a resource.
The resources that were fetched using the IDs provided.
The IDs for which a resource was not found.
Interface for product search
Specifies the page cursor. Items after this cursor will be returned.
Specifies the number of results to be returned in this page. The maximum number of items that will be returned is 50.
The search term to be used to search for POS products.
Specifies the order in which products should be sorted. When a `queryString` is provided, sortType will not have any effect, as the results will be returned in order by relevance to the `queryString`.
'RECENTLY_ADDED' | 'RECENTLY_ADDED_ASCENDING' | 'ALPHABETICAL_A_TO_Z' | 'ALPHABETICAL_Z_TO_A'
The ProductSearch API gives extensions access to the native product search and fetching functionality of Shopify POS. The interface provides numerous functions to search for products by query, or to fetch the details of one or more products or product variants.
import React, { useState } from 'react'
import { Screen, List, Navigator, reactExtension, SearchBar, useApi, ListRow } from '@shopify/ui-extensions-react/point-of-sale';
const Modal = () => {
const api = useApi<'pos.home.modal.render'>();
const [data, setData] = useState<ListRow[]>([]);
const search = async (queryString?: string) => {
const results = await api.productSearch.searchProducts({queryString})
const data = results.items.map((product): ListRow => {
return {
id: String(product.id),
leftSide: {
label: product.title,
image: {
source: product.featuredImage
}
}
}
})
setData(data)
}
return (
<Navigator>
<Screen name="HelloWorld" title="Hello World!">
<List
listHeaderComponent={<SearchBar
placeholder='Search products'
onTextChange={search}
onSearch={search}
/>}
imageDisplayStrategy='always'
data={data}
/>
</Screen>
</Navigator>
)
}
export default reactExtension('pos.home.modal.render', () => <Modal />);
import {
SearchBar,
Screen,
Navigator,
extension,
ListRow,
List,
} from '@shopify/ui-extensions/point-of-sale';
export default extension('pos.home.modal.render', (root, api) => {
const list = root.createComponent(List, {
imageDisplayStrategy: 'always',
data: [],
});
const search = async (queryString?: string) => {
const results = await api.productSearch.searchProducts({queryString});
const data = results.items.map((product): ListRow => {
return {
id: String(product.id),
leftSide: {
label: product.title,
image: {
source: product.featuredImage,
},
},
};
});
list.updateProps({data});
};
const searchBar = root.createFragment();
searchBar.append(
root.createComponent(SearchBar, {
placeholder: 'Search products',
onTextChange: search,
onSearch: search,
}),
);
list.updateProps({listHeaderComponent: searchBar});
const screen = root.createComponent(Screen, {
title: 'Home',
name: 'Home',
});
screen.append(list);
const navigator = root.createComponent(Navigator);
navigator.append(screen);
root.append(navigator);
});
import React, { useState } from 'react'
import { Screen, List, Navigator, reactExtension, SearchBar, useApi, ListRow } from '@shopify/ui-extensions-react/point-of-sale';
const Modal = () => {
const api = useApi<'pos.home.modal.render'>();
const [data, setData] = useState<ListRow[]>([]);
const search = async (queryString?: string) => {
const results = await api.productSearch.searchProducts({queryString})
const data = results.items.map((product): ListRow => {
return {
id: String(product.id),
leftSide: {
label: product.title,
image: {
source: product.featuredImage
}
}
}
})
setData(data)
}
return (
<Navigator>
<Screen name="HelloWorld" title="Hello World!">
<List
listHeaderComponent={<SearchBar
placeholder='Search products'
onTextChange={search}
onSearch={search}
/>}
imageDisplayStrategy='always'
data={data}
/>
</Screen>
</Navigator>
)
}
export default reactExtension('pos.home.modal.render', () => <Modal />);
import {
SearchBar,
Screen,
Navigator,
extension,
ListRow,
List,
} from '@shopify/ui-extensions/point-of-sale';
export default extension('pos.home.modal.render', (root, api) => {
const list = root.createComponent(List, {
imageDisplayStrategy: 'always',
data: [],
});
const search = async (queryString?: string) => {
const results = await api.productSearch.searchProducts({queryString});
const data = results.items.map((product): ListRow => {
return {
id: String(product.id),
leftSide: {
label: product.title,
image: {
source: product.featuredImage,
},
},
};
});
list.updateProps({data});
};
const searchBar = root.createFragment();
searchBar.append(
root.createComponent(SearchBar, {
placeholder: 'Search products',
onTextChange: search,
onSearch: search,
}),
);
list.updateProps({listHeaderComponent: searchBar});
const screen = root.createComponent(Screen, {
title: 'Home',
name: 'Home',
});
screen.append(list);
const navigator = root.createComponent(Navigator);
navigator.append(screen);
root.append(navigator);
});
import React, { useEffect, useState } from 'react'
import { Screen, List, Navigator, reactExtension, SearchBar, useApi, ListRow } from '@shopify/ui-extensions-react/point-of-sale';
const Modal = () => {
const api = useApi<'pos.home.modal.render'>();
const [data, setData] = useState<ListRow[]>([]);
useEffect(() => {
const fetchProduct = async () => {
const resultProduct = await api.productSearch.fetchProductWithId(1)
if (resultProduct) {
const listItem = {
id: String(resultProduct.id),
leftSide: {
label: resultProduct.title,
image: {
source: resultProduct.featuredImage
}
}
}
setData([listItem])
}
}
fetchProduct();
}, []);
return (
<Navigator>
<Screen name="HelloWorld" title="Hello World!">
<List
imageDisplayStrategy='always'
data={data}
/>
</Screen>
</Navigator>
)
}
export default reactExtension('pos.home.modal.render', () => <Modal />);
import {
SearchBar,
Screen,
Navigator,
extension,
ListRow,
List,
} from '@shopify/ui-extensions/point-of-sale';
export default extension('pos.home.modal.render', (root, api) => {
const list = root.createComponent(List, {
imageDisplayStrategy: 'always',
data: [],
});
const fetchProduct = async () => {
const resultProduct = await api.productSearch.fetchProductWithId(1);
if (resultProduct) {
const listItem = {
id: String(resultProduct.id),
leftSide: {
label: resultProduct.title,
image: {
source: resultProduct.featuredImage,
},
},
};
list.updateProps({data: [listItem]});
}
};
const screen = root.createComponent(Screen, {
title: 'Home',
name: 'Home',
});
screen.append(list);
const navigator = root.createComponent(Navigator);
navigator.append(screen);
root.append(navigator);
fetchProduct();
});
import React, { useEffect, useState } from 'react'
import { Screen, List, Navigator, reactExtension, SearchBar, useApi, ListRow } from '@shopify/ui-extensions-react/point-of-sale';
const Modal = () => {
const api = useApi<'pos.home.modal.render'>();
const [data, setData] = useState<ListRow[]>([]);
useEffect(() => {
const fetchProduct = async () => {
const resultProduct = await api.productSearch.fetchProductWithId(1)
if (resultProduct) {
const listItem = {
id: String(resultProduct.id),
leftSide: {
label: resultProduct.title,
image: {
source: resultProduct.featuredImage
}
}
}
setData([listItem])
}
}
fetchProduct();
}, []);
return (
<Navigator>
<Screen name="HelloWorld" title="Hello World!">
<List
imageDisplayStrategy='always'
data={data}
/>
</Screen>
</Navigator>
)
}
export default reactExtension('pos.home.modal.render', () => <Modal />);
import {
SearchBar,
Screen,
Navigator,
extension,
ListRow,
List,
} from '@shopify/ui-extensions/point-of-sale';
export default extension('pos.home.modal.render', (root, api) => {
const list = root.createComponent(List, {
imageDisplayStrategy: 'always',
data: [],
});
const fetchProduct = async () => {
const resultProduct = await api.productSearch.fetchProductWithId(1);
if (resultProduct) {
const listItem = {
id: String(resultProduct.id),
leftSide: {
label: resultProduct.title,
image: {
source: resultProduct.featuredImage,
},
},
};
list.updateProps({data: [listItem]});
}
};
const screen = root.createComponent(Screen, {
title: 'Home',
name: 'Home',
});
screen.append(list);
const navigator = root.createComponent(Navigator);
navigator.append(screen);
root.append(navigator);
fetchProduct();
});
import React, { useEffect, useState } from 'react'
import { Screen, List, Navigator, reactExtension, SearchBar, useApi, ListRow } from '@shopify/ui-extensions-react/point-of-sale';
const Modal = () => {
const api = useApi<'pos.home.modal.render'>();
const [data, setData] = useState<ListRow[]>([]);
useEffect(() => {
const fetchProducts = async () => {
const results = await api.productSearch.fetchProductsWithIds([1, 2, 3]);
const data = results.fetchedResources.map((product): ListRow => {
return {
id: String(product.id),
leftSide: {
label: product.title,
image: {
source: product.featuredImage
}
}
}
})
console.log('IDs not found: ', results.idsForResourcesNotFound);
setData(data)
}
fetchProducts();
}, []);
return (
<Navigator>
<Screen name="HelloWorld" title="Hello World!">
<List
imageDisplayStrategy='always'
data={data}
/>
</Screen>
</Navigator>
)
}
export default reactExtension('pos.home.modal.render', () => <Modal />);
import {
SearchBar,
Screen,
Navigator,
extension,
ListRow,
List,
} from '@shopify/ui-extensions/point-of-sale';
export default extension('pos.home.modal.render', (root, api) => {
const list = root.createComponent(List, {
imageDisplayStrategy: 'always',
data: [],
});
const fetchProducts = async () => {
const results = await api.productSearch.fetchProductsWithIds([1, 2, 3, 4]);
const data = results.fetchedResources.map((product): ListRow => {
return {
id: String(product.id),
leftSide: {
label: product.title,
image: {
source: product.featuredImage,
},
},
};
});
console.log('IDs not found: ', results.idsForResourcesNotFound);
list.updateProps({data});
};
const screen = root.createComponent(Screen, {
title: 'Home',
name: 'Home',
});
screen.append(list);
const navigator = root.createComponent(Navigator);
navigator.append(screen);
root.append(navigator);
fetchProducts();
});
import React, { useEffect, useState } from 'react'
import { Screen, List, Navigator, reactExtension, SearchBar, useApi, ListRow } from '@shopify/ui-extensions-react/point-of-sale';
const Modal = () => {
const api = useApi<'pos.home.modal.render'>();
const [data, setData] = useState<ListRow[]>([]);
useEffect(() => {
const fetchProducts = async () => {
const results = await api.productSearch.fetchProductsWithIds([1, 2, 3]);
const data = results.fetchedResources.map((product): ListRow => {
return {
id: String(product.id),
leftSide: {
label: product.title,
image: {
source: product.featuredImage
}
}
}
})
console.log('IDs not found: ', results.idsForResourcesNotFound);
setData(data)
}
fetchProducts();
}, []);
return (
<Navigator>
<Screen name="HelloWorld" title="Hello World!">
<List
imageDisplayStrategy='always'
data={data}
/>
</Screen>
</Navigator>
)
}
export default reactExtension('pos.home.modal.render', () => <Modal />);
import {
SearchBar,
Screen,
Navigator,
extension,
ListRow,
List,
} from '@shopify/ui-extensions/point-of-sale';
export default extension('pos.home.modal.render', (root, api) => {
const list = root.createComponent(List, {
imageDisplayStrategy: 'always',
data: [],
});
const fetchProducts = async () => {
const results = await api.productSearch.fetchProductsWithIds([1, 2, 3, 4]);
const data = results.fetchedResources.map((product): ListRow => {
return {
id: String(product.id),
leftSide: {
label: product.title,
image: {
source: product.featuredImage,
},
},
};
});
console.log('IDs not found: ', results.idsForResourcesNotFound);
list.updateProps({data});
};
const screen = root.createComponent(Screen, {
title: 'Home',
name: 'Home',
});
screen.append(list);
const navigator = root.createComponent(Navigator);
navigator.append(screen);
root.append(navigator);
fetchProducts();
});
import React, { useEffect, useState } from 'react'
import { Screen, List, Navigator, reactExtension, SearchBar, useApi, ListRow } from '@shopify/ui-extensions-react/point-of-sale';
const Modal = () => {
const api = useApi<'pos.home.modal.render'>();
const [data, setData] = useState<ListRow[]>([]);
useEffect(() => {
const fetchProductVariant = async () => {
const resultProductVariant = await api.productSearch.fetchProductVariantWithId(1);
if (resultProductVariant) {
const listItem = {
id: String(resultProductVariant.id),
leftSide: {
label: resultProductVariant.title,
image: {
source: resultProductVariant.image
}
}
}
setData([listItem])
}
}
fetchProductVariant();
}, []);
return (
<Navigator>
<Screen name="HelloWorld" title="Hello World!">
<List
imageDisplayStrategy='always'
data={data}
/>
</Screen>
</Navigator>
)
}
export default reactExtension('pos.home.modal.render', () => <Modal />);
import {
SearchBar,
Screen,
Navigator,
extension,
ListRow,
List,
} from '@shopify/ui-extensions/point-of-sale';
export default extension('pos.home.modal.render', (root, api) => {
const list = root.createComponent(List, {
imageDisplayStrategy: 'always',
data: [],
});
const fetchProductVariant = async () => {
const resultProductVariant =
await api.productSearch.fetchProductVariantWithId(1);
if (resultProductVariant) {
const listItem = {
id: String(resultProductVariant.id),
leftSide: {
label: resultProductVariant.title,
image: {
source: resultProductVariant.image,
},
},
};
list.updateProps({data: [listItem]});
}
};
const screen = root.createComponent(Screen, {
title: 'Home',
name: 'Home',
});
screen.append(list);
const navigator = root.createComponent(Navigator);
navigator.append(screen);
root.append(navigator);
fetchProductVariant();
});
import React, { useEffect, useState } from 'react'
import { Screen, List, Navigator, reactExtension, SearchBar, useApi, ListRow } from '@shopify/ui-extensions-react/point-of-sale';
const Modal = () => {
const api = useApi<'pos.home.modal.render'>();
const [data, setData] = useState<ListRow[]>([]);
useEffect(() => {
const fetchProductVariant = async () => {
const resultProductVariant = await api.productSearch.fetchProductVariantWithId(1);
if (resultProductVariant) {
const listItem = {
id: String(resultProductVariant.id),
leftSide: {
label: resultProductVariant.title,
image: {
source: resultProductVariant.image
}
}
}
setData([listItem])
}
}
fetchProductVariant();
}, []);
return (
<Navigator>
<Screen name="HelloWorld" title="Hello World!">
<List
imageDisplayStrategy='always'
data={data}
/>
</Screen>
</Navigator>
)
}
export default reactExtension('pos.home.modal.render', () => <Modal />);
import {
SearchBar,
Screen,
Navigator,
extension,
ListRow,
List,
} from '@shopify/ui-extensions/point-of-sale';
export default extension('pos.home.modal.render', (root, api) => {
const list = root.createComponent(List, {
imageDisplayStrategy: 'always',
data: [],
});
const fetchProductVariant = async () => {
const resultProductVariant =
await api.productSearch.fetchProductVariantWithId(1);
if (resultProductVariant) {
const listItem = {
id: String(resultProductVariant.id),
leftSide: {
label: resultProductVariant.title,
image: {
source: resultProductVariant.image,
},
},
};
list.updateProps({data: [listItem]});
}
};
const screen = root.createComponent(Screen, {
title: 'Home',
name: 'Home',
});
screen.append(list);
const navigator = root.createComponent(Navigator);
navigator.append(screen);
root.append(navigator);
fetchProductVariant();
});
import React, { useEffect, useState } from 'react'
import { Screen, List, Navigator, reactExtension, SearchBar, useApi, ListRow } from '@shopify/ui-extensions-react/point-of-sale';
const Modal = () => {
const api = useApi<'pos.home.modal.render'>();
const [data, setData] = useState<ListRow[]>([]);
useEffect(() => {
const fetchProductVariants = async () => {
const results = await api.productSearch.fetchProductVariantsWithIds([1, 2, 3]);
const data = results.fetchedResources.map((variant): ListRow => {
return {
id: String(variant.id),
leftSide: {
label: variant.title,
image: {
source: variant.image
}
}
}
})
console.log('IDs not found: ', results.idsForResourcesNotFound);
setData(data)
}
fetchProductVariants();
}, []);
return (
<Navigator>
<Screen name="HelloWorld" title="Hello World!">
<List
imageDisplayStrategy='always'
data={data}
/>
</Screen>
</Navigator>
)
}
export default reactExtension('pos.home.modal.render', () => <Modal />);
import {
SearchBar,
Screen,
Navigator,
extension,
ListRow,
List,
} from '@shopify/ui-extensions/point-of-sale';
export default extension('pos.home.modal.render', (root, api) => {
const list = root.createComponent(List, {
imageDisplayStrategy: 'always',
data: [],
});
const fetchProductVariants = async () => {
const results = await api.productSearch.fetchProductVariantsWithIds([
1, 2, 3, 4,
]);
const data = results.fetchedResources.map((variant): ListRow => {
return {
id: String(variant.id),
leftSide: {
label: variant.title,
image: {
source: variant.image,
},
},
};
});
console.log('IDs not found: ', results.idsForResourcesNotFound);
list.updateProps({data});
};
const screen = root.createComponent(Screen, {
title: 'Home',
name: 'Home',
});
screen.append(list);
const navigator = root.createComponent(Navigator);
navigator.append(screen);
root.append(navigator);
fetchProductVariants();
});
import React, { useEffect, useState } from 'react'
import { Screen, List, Navigator, reactExtension, SearchBar, useApi, ListRow } from '@shopify/ui-extensions-react/point-of-sale';
const Modal = () => {
const api = useApi<'pos.home.modal.render'>();
const [data, setData] = useState<ListRow[]>([]);
useEffect(() => {
const fetchProductVariants = async () => {
const results = await api.productSearch.fetchProductVariantsWithIds([1, 2, 3]);
const data = results.fetchedResources.map((variant): ListRow => {
return {
id: String(variant.id),
leftSide: {
label: variant.title,
image: {
source: variant.image
}
}
}
})
console.log('IDs not found: ', results.idsForResourcesNotFound);
setData(data)
}
fetchProductVariants();
}, []);
return (
<Navigator>
<Screen name="HelloWorld" title="Hello World!">
<List
imageDisplayStrategy='always'
data={data}
/>
</Screen>
</Navigator>
)
}
export default reactExtension('pos.home.modal.render', () => <Modal />);
import {
SearchBar,
Screen,
Navigator,
extension,
ListRow,
List,
} from '@shopify/ui-extensions/point-of-sale';
export default extension('pos.home.modal.render', (root, api) => {
const list = root.createComponent(List, {
imageDisplayStrategy: 'always',
data: [],
});
const fetchProductVariants = async () => {
const results = await api.productSearch.fetchProductVariantsWithIds([
1, 2, 3, 4,
]);
const data = results.fetchedResources.map((variant): ListRow => {
return {
id: String(variant.id),
leftSide: {
label: variant.title,
image: {
source: variant.image,
},
},
};
});
console.log('IDs not found: ', results.idsForResourcesNotFound);
list.updateProps({data});
};
const screen = root.createComponent(Screen, {
title: 'Home',
name: 'Home',
});
screen.append(list);
const navigator = root.createComponent(Navigator);
navigator.append(screen);
root.append(navigator);
fetchProductVariants();
});
import React, { useEffect, useState } from 'react'
import { Screen, List, Navigator, reactExtension, SearchBar, useApi, ListRow } from '@shopify/ui-extensions-react/point-of-sale';
const Modal = () => {
const api = useApi<'pos.home.modal.render'>();
const [data, setData] = useState<ListRow[]>([]);
useEffect(() => {
const fetchProductVariants = async () => {
const results = await api.productSearch.fetchPaginatedProductVariantsWithProductId(1, {first: 10});
const data = results.items.map((variant): ListRow => {
return {
id: String(variant.id),
leftSide: {
label: variant.title,
image: {
source: variant.image
}
}
}
})
console.log('Cursor for next page: ', results.lastCursor);
setData(data)
}
fetchProductVariants();
}, []);
return (
<Navigator>
<Screen name="HelloWorld" title="Hello World!">
<List
imageDisplayStrategy='always'
data={data}
/>
</Screen>
</Navigator>
)
}
export default reactExtension('pos.home.modal.render', () => <Modal />);
import {
SearchBar,
Screen,
Navigator,
extension,
ListRow,
List,
} from '@shopify/ui-extensions/point-of-sale';
export default extension('pos.home.modal.render', (root, api) => {
const list = root.createComponent(List, {
imageDisplayStrategy: 'always',
data: [],
});
const fetchProductVariants = async () => {
const results =
await api.productSearch.fetchPaginatedProductVariantsWithProductId(1, {
first: 10,
});
const data = results.items.map((variant): ListRow => {
return {
id: String(variant.id),
leftSide: {
label: variant.title,
image: {
source: variant.image,
},
},
};
});
console.log('Cursor for next page: ', results.lastCursor);
list.updateProps({data});
};
const screen = root.createComponent(Screen, {
title: 'Home',
name: 'Home',
});
screen.append(list);
const navigator = root.createComponent(Navigator);
navigator.append(screen);
root.append(navigator);
fetchProductVariants();
});
import React, { useEffect, useState } from 'react'
import { Screen, List, Navigator, reactExtension, SearchBar, useApi, ListRow } from '@shopify/ui-extensions-react/point-of-sale';
const Modal = () => {
const api = useApi<'pos.home.modal.render'>();
const [data, setData] = useState<ListRow[]>([]);
useEffect(() => {
const fetchProductVariants = async () => {
const results = await api.productSearch.fetchPaginatedProductVariantsWithProductId(1, {first: 10});
const data = results.items.map((variant): ListRow => {
return {
id: String(variant.id),
leftSide: {
label: variant.title,
image: {
source: variant.image
}
}
}
})
console.log('Cursor for next page: ', results.lastCursor);
setData(data)
}
fetchProductVariants();
}, []);
return (
<Navigator>
<Screen name="HelloWorld" title="Hello World!">
<List
imageDisplayStrategy='always'
data={data}
/>
</Screen>
</Navigator>
)
}
export default reactExtension('pos.home.modal.render', () => <Modal />);
import {
SearchBar,
Screen,
Navigator,
extension,
ListRow,
List,
} from '@shopify/ui-extensions/point-of-sale';
export default extension('pos.home.modal.render', (root, api) => {
const list = root.createComponent(List, {
imageDisplayStrategy: 'always',
data: [],
});
const fetchProductVariants = async () => {
const results =
await api.productSearch.fetchPaginatedProductVariantsWithProductId(1, {
first: 10,
});
const data = results.items.map((variant): ListRow => {
return {
id: String(variant.id),
leftSide: {
label: variant.title,
image: {
source: variant.image,
},
},
};
});
console.log('Cursor for next page: ', results.lastCursor);
list.updateProps({data});
};
const screen = root.createComponent(Screen, {
title: 'Home',
name: 'Home',
});
screen.append(list);
const navigator = root.createComponent(Navigator);
navigator.append(screen);
root.append(navigator);
fetchProductVariants();
});