--- title: Scanner API description: >- The Scanner API allows you to use the mobile device's camera to scan barcodes. Use this API to capture barcode data and integrate it into your app's workflow on Shopify POS. api_name: app-home source_url: html: >- https://shopify.dev/docs/api/app-home/apis/device-and-platform-integration/scanner-api md: >- https://shopify.dev/docs/api/app-home/apis/device-and-platform-integration/scanner-api.md --- # Scanner API The Scanner API allows you to use the mobile device's camera to scan barcodes. Use this API to capture barcode data and integrate it into your app's workflow on Shopify POS. ### Use cases * **Product lookup:** Scan barcodes to quickly look up products in the store catalog. * **Inventory management:** Scan items during inventory counts or stocktaking workflows. * **Order processing:** Scan package barcodes during fulfillment or receiving workflows. * **Custom scanning:** Implement custom barcode scanning workflows that process scan data for your app's needs. ### Methods The `scanner` API provides a `capture` method that opens the mobile device's scanner to capture a barcode. It returns a Promise resolving to the scanned barcode data or an error. * **capture** **() => Promise\** **required** Opens the device camera to scan a barcode. Returns a Promise that resolves to a `ScannerPayload` containing the scanned data. ### ScannerPayload The result returned after a successful barcode scan. * data The scanned barcode data as a string. ```ts string ``` Examples ### Examples * #### ##### Description Look up products by scanning their barcode. This example captures a barcode and queries the Admin API to find the matching product variant. ##### js ```js // Scan a product barcode and look it up try { const { data: barcode } = await shopify.scanner.capture(); // Look up the product variant by barcode const response = await fetch('shopify:admin/api/graphql.json', { method: 'POST', body: JSON.stringify({ query: ` query getVariantByBarcode($barcode: String!) { productVariants(first: 1, query: $barcode) { nodes { id title price product { title } } } } `, variables: { barcode: `barcode:${barcode}` } }) }); const { data } = await response.json(); const variant = data.productVariants.nodes[0]; if (variant) { shopify.toast.show(`Found: ${variant.product.title} - ${variant.title}`); } else { shopify.toast.show('Product not found', { isError: true }); } } catch (error) { shopify.toast.show('Scan cancelled or failed', { isError: true }); } ``` ***