Enhance E-commerce Experiences with Real Time Product Search API

29 Sep 2025
Enhance E-commerce Experiences with Real Time Product Search API

The Real Time Product Search API offers developers a powerful tool to integrate dynamic product search functionalities into their applications. By leveraging advanced cognitive actions, this API enables seamless interaction with product listings, reviews, and offers from multiple online retailers, enhancing user experience and driving conversions. The benefits of this API include rapid data retrieval, extensive filtering options, and support for various languages and countries, making it an essential asset for e-commerce platforms, comparison shopping sites, and any application that requires real-time product information.

Use Cases:

  • E-commerce Platforms: Integrate product search capabilities to help users find items quickly and efficiently.
  • Price Comparison Websites: Fetch real-time offers, allowing users to compare prices across different retailers.
  • Review Aggregation: Collect and display comprehensive product reviews to assist customers in making informed purchase decisions.
  • Market Research: Gain insights into product availability, pricing trends, and customer feedback to inform business strategies.

Get Store Reviews with Pagination

This action retrieves comprehensive reviews for a store or merchant, offering optional filters for pagination, star ratings, sort order, and language. It allows querying reviews by country and specific time periods, defaulting to reviews from amazon.com in English.

Input Requirements:

  • storeUrl (required): The URL of the online store to fetch reviews from.
  • Optional parameters include limit, cursor, rating, country, orderBy, language, and durationPeriod.

Expected Output:

  • A structured response containing the reviews, pagination cursor, and store rating information.

Use Cases for this specific action:

  • Customer Feedback Display: Show potential buyers what others think about a store before making a purchase.
  • Market Analysis: Analyze reviews to gauge customer satisfaction and identify areas for improvement.

```python
import requests
import json

# Replace with your actual Cognitive Actions API key and endpoint
# Ensure your environment securely handles the API key
COGNITIVE_ACTIONS_API_KEY = "YOUR_COGNITIVE_ACTIONS_API_KEY"
# This endpoint URL is hypothetical and should be documented for users
COGNITIVE_ACTIONS_EXECUTE_URL = "https://api.cognitiveactions.com/actions/execute"

action_id = "11e77c0c-8367-4c87-90d5-894ee01341b0" # Action ID for: Get Store Reviews with Pagination

# Construct the exact input payload based on the action's requirements
# This example uses the predefined example_input for this action:
payload = {
  "limit": 10,
  "rating": "ALL",
  "country": "us",
  "orderBy": "MOST_HELPFUL",
  "language": "en",
  "storeUrl": "amazon.com",
  "durationPeriod": "ALL"
}

headers = {
    "Authorization": f"Bearer {COGNITIVE_ACTIONS_API_KEY}",
    "Content-Type": "application/json",
    # Add any other required headers for the Cognitive Actions API
}

# Prepare the request body for the hypothetical execution endpoint
request_body = {
    "action_id": action_id,
    "inputs": payload
}

print(f"--- Calling Cognitive Action: {action.name or action_id} ---")
print(f"Endpoint: {COGNITIVE_ACTIONS_EXECUTE_URL}")
print(f"Action ID: {action_id}")
print("Payload being sent:")
print(json.dumps(request_body, indent=2))
print("------------------------------------------------")

try:
    response = requests.post(
        COGNITIVE_ACTIONS_EXECUTE_URL,
        headers=headers,
        json=request_body
    )
    response.raise_for_status() # Raise an exception for bad status codes (4xx or 5xx)

    result = response.json()
    print("Action executed successfully. Result:")
    print(json.dumps(result, indent=2))

except requests.exceptions.RequestException as e:
    print(f"Error executing action {action_id}: {e}")
    if e.response is not None:
        print(f"Response status: {e.response.status_code}")
        try:
            print(f"Response body: {e.response.json()}")
        except json.JSONDecodeError:
            print(f"Response body (non-JSON): {e.response.text}")
    print("------------------------------------------------")


## Execute Product Search on Google Shopping
This action allows developers to perform ultra-fast product searches using Google Shopping's extensive data resources. It retrieves product listings, sponsored products, and search refinements, making it easier for users to find what they are looking for.

**Input Requirements:**
- `query` (required): The search term used to find products.
- Optional parameters include `page`, `limit`, `onSale`, `sortBy`, `stores`, `country`, `language`, `maxPrice`, and `minPrice`.

**Expected Output:**
- A list of products matching the search criteria, along with details such as price, shipping information, and store ratings.

**Use Cases for this specific action:**
- **Product Discovery:** Enable users to quickly find products across various categories and retailers.
- **Sales Promotion:** Highlight products that are on sale or meet specific criteria, increasing the likelihood of purchase.

import requests
import json

# Replace with your actual Cognitive Actions API key and endpoint
# Ensure your environment securely handles the API key
COGNITIVE_ACTIONS_API_KEY = "YOUR_COGNITIVE_ACTIONS_API_KEY"
# This endpoint URL is hypothetical and should be documented for users
COGNITIVE_ACTIONS_EXECUTE_URL = "https://api.cognitiveactions.com/actions/execute"

action_id = "2731d561-5532-4745-9e5c-f44f1b783daa" # Action ID for: Execute Product Search on Google Shopping

# Construct the exact input payload based on the action's requirements
# This example uses the predefined example_input for this action:
payload = {
  "page": 1,
  "limit": 10,
  "query": "Nike shoes",
  "sortBy": "BEST_MATCH",
  "country": "us",
  "language": "en",
  "productCondition": "ANY"
}

headers = {
    "Authorization": f"Bearer {COGNITIVE_ACTIONS_API_KEY}",
    "Content-Type": "application/json",
    # Add any other required headers for the Cognitive Actions API
}

# Prepare the request body for the hypothetical execution endpoint
request_body = {
    "action_id": action_id,
    "inputs": payload
}

print(f"--- Calling Cognitive Action: {action.name or action_id} ---")
print(f"Endpoint: {COGNITIVE_ACTIONS_EXECUTE_URL}")
print(f"Action ID: {action_id}")
print("Payload being sent:")
print(json.dumps(request_body, indent=2))
print("------------------------------------------------")

try:
    response = requests.post(
        COGNITIVE_ACTIONS_EXECUTE_URL,
        headers=headers,
        json=request_body
    )
    response.raise_for_status() # Raise an exception for bad status codes (4xx or 5xx)

    result = response.json()
    print("Action executed successfully. Result:")
    print(json.dumps(result, indent=2))

except requests.exceptions.RequestException as e:
    print(f"Error executing action {action_id}: {e}")
    if e.response is not None:
        print(f"Response status: {e.response.status_code}")
        try:
            print(f"Response body: {e.response.json()}")
        except json.JSONDecodeError:
            print(f"Response body (non-JSON): {e.response.text}")
    print("------------------------------------------------")


## Retrieve Product Offers
This action fetches all available offers for a specific product from the Google Shopping layout, including offers from multiple sellers. It supports real-time product searches across various countries and languages.

**Input Requirements:**
- `productId` (required): A unique identifier for the product, including various components such as catalog ID and offer document ID.
- Optional parameters include `page`, `country`, and `language`.

**Expected Output:**
- Details of all available offers for the specified product, including pricing, shipping options, and seller ratings.

**Use Cases for this specific action:**
- **Competitive Pricing Display:** Allow users to view offers from multiple sellers, promoting informed purchasing decisions.
- **Dynamic Market Analysis:** Track pricing trends and availability across different retailers.

import requests
import json

# Replace with your actual Cognitive Actions API key and endpoint
# Ensure your environment securely handles the API key
COGNITIVE_ACTIONS_API_KEY = "YOUR_COGNITIVE_ACTIONS_API_KEY"
# This endpoint URL is hypothetical and should be documented for users
COGNITIVE_ACTIONS_EXECUTE_URL = "https://api.cognitiveactions.com/actions/execute"

action_id = "2fd6ab12-d136-4868-8dfc-ce67ab9c4e3e" # Action ID for: Retrieve Product Offers

# Construct the exact input payload based on the action's requirements
# This example uses the predefined example_input for this action:
payload = {
  "page": 1,
  "country": "us",
  "language": "en",
  "productId": "catalogid:15554707778408471208,gpcid:6219277726645206819,headlineOfferDocid:8835386203856143595,rds:PC_15478400683365031707|PROD_PC_15478400683365031707,imageDocid:10653897321817113741,mid:576462815432560445,pvt:hg,pvf:"
}

headers = {
    "Authorization": f"Bearer {COGNITIVE_ACTIONS_API_KEY}",
    "Content-Type": "application/json",
    # Add any other required headers for the Cognitive Actions API
}

# Prepare the request body for the hypothetical execution endpoint
request_body = {
    "action_id": action_id,
    "inputs": payload
}

print(f"--- Calling Cognitive Action: {action.name or action_id} ---")
print(f"Endpoint: {COGNITIVE_ACTIONS_EXECUTE_URL}")
print(f"Action ID: {action_id}")
print("Payload being sent:")
print(json.dumps(request_body, indent=2))
print("------------------------------------------------")

try:
    response = requests.post(
        COGNITIVE_ACTIONS_EXECUTE_URL,
        headers=headers,
        json=request_body
    )
    response.raise_for_status() # Raise an exception for bad status codes (4xx or 5xx)

    result = response.json()
    print("Action executed successfully. Result:")
    print(json.dumps(result, indent=2))

except requests.exceptions.RequestException as e:
    print(f"Error executing action {action_id}: {e}")
    if e.response is not None:
        print(f"Response status: {e.response.status_code}")
        try:
            print(f"Response body: {e.response.json()}")
        except json.JSONDecodeError:
            print(f"Response body (non-JSON): {e.response.text}")
    print("------------------------------------------------")


## Search Google Shopping Deals
This action performs searches for product deals on Google Shopping, allowing for pagination and multiple filters, including sale status, price range, and product condition.

**Input Requirements:**
- `query` (required): The search term to query in the database.
- Optional parameters include `page`, `limit`, `onSale`, `sortBy`, `country`, `language`, and various price filters.

**Expected Output:**
- A list of deals matching the search criteria, along with filtering options and associated product details.

**Use Cases for this specific action:**
- **Deal Hunting:** Help users find the best deals on products, especially during sales or holiday seasons.
- **Targeted Promotions:** Serve specific user segments with offers tailored to their interests.

import requests
import json

# Replace with your actual Cognitive Actions API key and endpoint
# Ensure your environment securely handles the API key
COGNITIVE_ACTIONS_API_KEY = "YOUR_COGNITIVE_ACTIONS_API_KEY"
# This endpoint URL is hypothetical and should be documented for users
COGNITIVE_ACTIONS_EXECUTE_URL = "https://api.cognitiveactions.com/actions/execute"

action_id = "48dabd01-5590-408f-a71f-eb869be46623" # Action ID for: Search Google Shopping Deals

# Construct the exact input payload based on the action's requirements
# This example uses the predefined example_input for this action:
payload = {
  "page": 1,
  "limit": 10,
  "query": "Laptop",
  "sortBy": "BEST_MATCH",
  "country": "us",
  "language": "en",
  "productCondition": "ANY"
}

headers = {
    "Authorization": f"Bearer {COGNITIVE_ACTIONS_API_KEY}",
    "Content-Type": "application/json",
    # Add any other required headers for the Cognitive Actions API
}

# Prepare the request body for the hypothetical execution endpoint
request_body = {
    "action_id": action_id,
    "inputs": payload
}

print(f"--- Calling Cognitive Action: {action.name or action_id} ---")
print(f"Endpoint: {COGNITIVE_ACTIONS_EXECUTE_URL}")
print(f"Action ID: {action_id}")
print("Payload being sent:")
print(json.dumps(request_body, indent=2))
print("------------------------------------------------")

try:
    response = requests.post(
        COGNITIVE_ACTIONS_EXECUTE_URL,
        headers=headers,
        json=request_body
    )
    response.raise_for_status() # Raise an exception for bad status codes (4xx or 5xx)

    result = response.json()
    print("Action executed successfully. Result:")
    print(json.dumps(result, indent=2))

except requests.exceptions.RequestException as e:
    print(f"Error executing action {action_id}: {e}")
    if e.response is not None:
        print(f"Response status: {e.response.status_code}")
        try:
            print(f"Response body: {e.response.json()}")
        except json.JSONDecodeError:
            print(f"Response body (non-JSON): {e.response.text}")
    print("------------------------------------------------")


## Retrieve Product Details by ID
This action fetches comprehensive details about a specific product using its product ID, including reviews, photos, specifications, and more.

**Input Requirements:**
- `productId` (required): A unique string that identifies the product.
- Optional parameters include `country` and `language`.

**Expected Output:**
- Detailed product information, including pricing, specifications, and customer reviews.

**Use Cases for this specific action:**
- **In-depth Product Analysis:** Provide users with all relevant information about a product to assist in their purchasing decisions.
- **Content Enrichment:** Enhance product pages or listings with rich content like images, specifications, and reviews.

import requests
import json

# Replace with your actual Cognitive Actions API key and endpoint
# Ensure your environment securely handles the API key
COGNITIVE_ACTIONS_API_KEY = "YOUR_COGNITIVE_ACTIONS_API_KEY"
# This endpoint URL is hypothetical and should be documented for users
COGNITIVE_ACTIONS_EXECUTE_URL = "https://api.cognitiveactions.com/actions/execute"

action_id = "52279626-21e8-4075-8b91-857fc31bae32" # Action ID for: Retrieve Product Details by ID

# Construct the exact input payload based on the action's requirements
# This example uses the predefined example_input for this action:
payload = {
  "country": "us",
  "language": "en",
  "productId": "catalogid:8425421641323327810,gpcid:1261873578657646759,headlineOfferDocid:6367138647863486978,rds:PC_1261873578657646759|PROD_PC_1261873578657646759,imageDocid:17958223083723421156,mid:576462516936404275,pvt:hg,pvf:"
}

headers = {
    "Authorization": f"Bearer {COGNITIVE_ACTIONS_API_KEY}",
    "Content-Type": "application/json",
    # Add any other required headers for the Cognitive Actions API
}

# Prepare the request body for the hypothetical execution endpoint
request_body = {
    "action_id": action_id,
    "inputs": payload
}

print(f"--- Calling Cognitive Action: {action.name or action_id} ---")
print(f"Endpoint: {COGNITIVE_ACTIONS_EXECUTE_URL}")
print(f"Action ID: {action_id}")
print("Payload being sent:")
print(json.dumps(request_body, indent=2))
print("------------------------------------------------")

try:
    response = requests.post(
        COGNITIVE_ACTIONS_EXECUTE_URL,
        headers=headers,
        json=request_body
    )
    response.raise_for_status() # Raise an exception for bad status codes (4xx or 5xx)

    result = response.json()
    print("Action executed successfully. Result:")
    print(json.dumps(result, indent=2))

except requests.exceptions.RequestException as e:
    print(f"Error executing action {action_id}: {e}")
    if e.response is not None:
        print(f"Response status: {e.response.status_code}")
        try:
            print(f"Response body: {e.response.json()}")
        except json.JSONDecodeError:
            print(f"Response body (non-JSON): {e.response.text}")
    print("------------------------------------------------")


## Fetch Product Reviews with Pagination
This action retrieves product reviews using pagination, providing fast access to reviews for products in specified countries.

**Input Requirements:**
- `productId` (required): A unique identifier for the product.
- Optional parameters include `limit`, `cursor`, `rating`, `sortBy`, `country`, and `language`.

**Expected Output:**
- A structured response containing reviews, pagination cursor, and overall product ratings.

**Use Cases for this specific action:**
- **Customer Insights:** Collect and display customer feedback to help new buyers understand product performance.
- **Market Research:** Analyze trends in customer satisfaction and product performance over time.

import requests
import json

# Replace with your actual Cognitive Actions API key and endpoint
# Ensure your environment securely handles the API key
COGNITIVE_ACTIONS_API_KEY = "YOUR_COGNITIVE_ACTIONS_API_KEY"
# This endpoint URL is hypothetical and should be documented for users
COGNITIVE_ACTIONS_EXECUTE_URL = "https://api.cognitiveactions.com/actions/execute"

action_id = "aba150c3-e597-4b6a-aeed-eed9829fdce5" # Action ID for: Fetch Product Reviews with Pagination

# Construct the exact input payload based on the action's requirements
# This example uses the predefined example_input for this action:
payload = {
  "limit": 10,
  "sortBy": "MOST_RELEVANT",
  "country": "us",
  "language": "en",
  "productId": "catalogid:8425421641323327810,gpcid:1261873578657646759,headlineOfferDocid:6367138647863486978,rds:PC_1261873578657646759|PROD_PC_1261873578657646759,imageDocid:17958223083723421156,mid:576462516936404275,pvt:hg,pvf:"
}

headers = {
    "Authorization": f"Bearer {COGNITIVE_ACTIONS_API_KEY}",
    "Content-Type": "application/json",
    # Add any other required headers for the Cognitive Actions API
}

# Prepare the request body for the hypothetical execution endpoint
request_body = {
    "action_id": action_id,
    "inputs": payload
}

print(f"--- Calling Cognitive Action: {action.name or action_id} ---")
print(f"Endpoint: {COGNITIVE_ACTIONS_EXECUTE_URL}")
print(f"Action ID: {action_id}")
print("Payload being sent:")
print(json.dumps(request_body, indent=2))
print("------------------------------------------------")

try:
    response = requests.post(
        COGNITIVE_ACTIONS_EXECUTE_URL,
        headers=headers,
        json=request_body
    )
    response.raise_for_status() # Raise an exception for bad status codes (4xx or 5xx)

    result = response.json()
    print("Action executed successfully. Result:")
    print(json.dumps(result, indent=2))

except requests.exceptions.RequestException as e:
    print(f"Error executing action {action_id}: {e}")
    if e.response is not None:
        print(f"Response status: {e.response.status_code}")
        try:
            print(f"Response body: {e.response.json()}")
        except json.JSONDecodeError:
            print(f"Response body (non-JSON): {e.response.text}")
    print("------------------------------------------------")


### Conclusion
The Real Time Product Search API empowers developers to create engaging and efficient shopping experiences through its suite of cognitive actions. By integrating these features, applications can provide users with real-time product information, enhance decision-making through reviews, and ultimately drive sales. As the e-commerce landscape continues to evolve, leveraging such powerful tools will be crucial for staying competitive and meeting customer expectations. Explore the possibilities with the Real Time Product Search API and elevate your application today!