Welcome to the Shopify Product Metafields Retrieval Template! This template is designed to help you quickly set up an application that retrieves metafields for products from a Shopify store using the Shopify API. It's perfect for builders who want to integrate Shopify product information into their own applications or services without worrying about the complexities of API integration and server deployment.
To begin using this template, simply click on "Start with this Template" in the Lazy platform. This will pre-populate the code in the Lazy Builder interface, so you won't need to copy, paste, or delete any code manually.
Before you can use this template, you'll need to set up an environment secret within the Lazy Builder. The code requires a Shopify admin API token to authenticate with the Shopify API. Here's how to acquire and set up your Shopify admin API token:
With the environment secret set, you're ready to deploy the application.
Press the "Test" button to begin the deployment of your app. The Lazy platform will handle all the necessary server setup and deployment processes for you.
After pressing the "Test" button, the Lazy App's CLI interface will appear. You will be prompted to provide the following input:
product_id
: The unique identifier for the product in your Shopify store.shopify_store_url
: The URL of your Shopify store.These inputs are necessary for the app to retrieve the metafields for the specified product.
Once the app is deployed, you will receive a dedicated server link to interact with the API. Additionally, since this template uses FastAPI, you will also be provided with a link to the API documentation. This documentation will allow you to explore the available endpoints and their expected parameters.
To retrieve the metafields for a product, you will use the provided server link to send a POST request to the "/product_metafields" endpoint with the required JSON body containing the `product_id` and `shopify_store_url`.
Here's a sample request you might send:
POST /product_metafields HTTP/1.1
Host: your-server-link
Content-Type: application/json
{
"product_id": "1234567890",
"shopify_store_url": "yourstore.myshopify.com"
}
And a sample response you might receive:
[
{
"id": 1010101010,
"namespace": "inventory",
"key": "warehouse",
"value": "42",
"value_type": "integer",
"description": "Warehouse number with inventory"
},
// ... more metafields
]
After successfully retrieving product metafields, you may want to integrate this data into your own application or service. Depending on your needs, this could involve:
If you need to integrate the API into an external tool, you will use the server link provided by Lazy. For example, you might add the API endpoint to a web application to fetch product details dynamically.
Remember, the Lazy platform has taken care of the deployment, so you can focus on how to use the API in your project. Happy building!