Display Products on a Custom Storefront
This tutorial guides you through fetching product data from your CarePortals catalog. You will learn how to retrieve a full list of your products and how to fetch the details for a single product, enabling you to build custom product listing and detail pages.
This guide is designed for developers building a custom e-commerce storefront, website, or mobile application that needs to display products managed in CarePortals.
Prerequisites
Before you begin, make sure you have the following:
- Configured Products: You must have products created and configured within the CarePortals CRM catalog.
- Organization ID (
<ORG_ID>): You must send the Organization ID (<ORG_ID>) in the request header.
Flow Overview
Here's a high-level overview of the process:
- Retrieve All Products: Fetch the complete list of products to populate a catalog or product listing page.
- Get Specific Product Details: Retrieve the detailed information for a single product to display on a product detail page.
Step 1: Retrieve All Products
To display your product catalog, you first need to fetch a complete list of all products. You can do this by calling the Retrieve All Products endpoint with a GET request. The response will contain an array of product objects, which you can use to populate a product listing page.
Example Request:
curl -X GET 'https://public-api.portals.care/v2/products' \
-H 'organization: <ORG_ID>'[
{
"_id": "67913a49df75bdf65ad795f3",
"name": "Finasteride 1mg",
"sku": "FINA-1",
"price": 90,
"listPrice": 111,
"imageUrl": "https://cdn.portals.care/images/finasteride.jpg",
"type": "physical"
},
{
"_id": "67913a49df75bdf65ad795f4",
"name": "Minoxidil 5% Solution",
"sku": "MINO-5",
"price": 45,
"listPrice": 55,
"imageUrl": "https://cdn.portals.care/images/minoxidil.jpg",
"type": "physical"
}
]A successful request returns a 200 OK status code and an array of product objects.
Step 2: Get Specific Product Details
For a product detail page, you will need to retrieve all information for a single product. You can fetch these details by calling the Retrieve a Product by ID endpoint with a GET request and passing the specific product's id in the URL path.
The Product ID is located in the detail view of a product's configuration page within the CRM Portal. There is no public API endpoint to list all available Product IDs; they must be retrieved manually from the CRM.
curl -X GET 'https://public-api.portals.care/v2/products/67913a49df75bdf65ad795f3' \
-H 'organization: <ORG_ID>'{
"_id": "67913a49df75bdf65ad795f3",
"name": "Finasteride 1mg",
"sku": "FINA-1",
"description": "Finasteride is a prescription medication used to treat male pattern hair loss. This package contains a 3-month supply.",
"price": 90,
"listPrice": 111,
"imageUrl": "https://cdn.portals.care/images/finasteride.jpg",
"type": "physical",
"isSubscription": true,
"options": [
{
"name": "Supply",
"values": ["3-Month", "6-Month"]
}
]
}The endpoint returns a 200 OK status and a single, detailed product object.
Updated about 2 months ago
