Ready-to-use OpenAI function calling schemas and examples for product search and price comparison using the ShopSavvy Data API.
Get an API key at shopsavvy.com/data.
pip install openai shopsavvy-sdknpm install openai @shopsavvy/sdkThe schemas/ directory contains JSON schema definitions for each function that can be passed directly to the OpenAI API:
search_products.json- Search for products by keywordget_offers.json- Get current retailer offers for a productget_price_history.json- Get historical price dataget_deals.json- Browse current shopping deals
import json
import os
from openai import OpenAI
from shopsavvy import ShopSavvyDataAPI, ShopSavvyConfig
client = OpenAI()
api = ShopSavvyDataAPI(ShopSavvyConfig(api_key=os.environ["SHOPSAVVY_API_KEY"]))
# Load function schemas
with open("schemas/search_products.json") as f:
search_schema = json.load(f)
response = client.chat.completions.create(
model="gpt-4o",
messages=[{"role": "user", "content": "Find the best price for AirPods Pro"}],
tools=[{"type": "function", "function": search_schema}],
)See examples/example_python.py for a complete working example with tool call handling.
import OpenAI from 'openai'
import { ShopSavvyDataAPI } from '@shopsavvy/sdk'
import searchSchema from './schemas/search_products.json'
const openai = new OpenAI()
const api = new ShopSavvyDataAPI({ apiKey: process.env.SHOPSAVVY_API_KEY! })
const response = await openai.chat.completions.create({
model: 'gpt-4o',
messages: [{ role: 'user', content: 'Find the best price for AirPods Pro' }],
tools: [{ type: 'function', function: searchSchema }],
})See examples/example_typescript.ts for a complete working example with tool call handling.
MIT