Documentation
¶
Overview ¶
Package feed provides types and helpers for exporting ACP product feeds. Product feed is used to index and display your products with up-to-date price and availability in AI platforms such as OpenAI.
Before you begin, you will have to sign up at chatgpt.com/merchants(https://chatgpt.com/merchants).
How it works ¶
- Prepare and export your feed.
- Share the feed using the preferred delivery method and file format described in the [integration section](https://developers.openai.com/commerce/specs/feed#integration-overview).
- OpenAI ingests the feed, validates records, and indexes product metadata for retrieval and ranking in ChatGPT.
- Update the feed whenever products, pricing, or availability change to ensure users see accurate information.
Example ¶
feed := New([]Product{
{
EnableSearch: true,
EnableCheckout: true,
ID: "sku_123",
Title: "Everyday T-Shirt",
Description: "Soft cotton tee in classic fit.",
Link: "https://store.example.com/products/sku_123",
ProductCategory: "Apparel & Accessories > Clothing",
ImageLink: "https://store.example.com/images/sku_123.jpg",
Price: "19.00 EUR",
Availability: "in_stock",
SellerName: "Example Store",
SellerURL: "https://store.example.com",
},
{
EnableSearch: true,
EnableCheckout: true,
ID: "sku_456",
Title: "Canvas Tote",
Description: "Reusable tote bag for daily errands.",
Link: "https://store.example.com/products/sku_456",
ProductCategory: "Apparel & Accessories > Bags",
ImageLink: "https://store.example.com/images/sku_456.jpg",
Price: "12.00 EUR",
Availability: "in_stock",
SellerName: "Example Store",
SellerURL: "https://store.example.com",
},
})
var buf bytes.Buffer
writer := NewJSONLGzWriter(&buf)
for i := range feed {
_ = writer.Write(feed[i])
}
_ = writer.Close()
Index ¶
- func CSVGzReadSeq(r io.Reader) iter.Seq[Result]
- func CSVReadSeq(r io.Reader) iter.Seq[Result]
- func JSONLGzReadSeq(r io.Reader) iter.Seq[Result]
- func JSONLReadSeq(r io.Reader) iter.Seq[Result]
- type CSVGzWriter
- type Feed
- type JSONLGzWriter
- type Product
- type ProductAgeGroup
- type ProductCondition
- type Result
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func CSVGzReadSeq ¶
CSVGzReadSeq reads products from a gzip-compressed ACP CSV feed.
func CSVReadSeq ¶
CSVReadSeq reads products from an ACP CSV feed.
func JSONLGzReadSeq ¶
JSONLGzReadSeq reads products from a gzip-compressed ACP JSON Lines feed.
Types ¶
type CSVGzWriter ¶
type CSVGzWriter struct {
// contains filtered or unexported fields
}
CSVGzWriter streams products as gzip-compressed CSV.
func NewCSVGzWriter ¶
func NewCSVGzWriter(w io.Writer) *CSVGzWriter
NewCSVGzWriter creates a writer for gzip-compressed CSV output.
func (*CSVGzWriter) Close ¶
func (w *CSVGzWriter) Close() error
Close flushes CSV data and finalizes the gzip stream.
func (*CSVGzWriter) Write ¶
func (w *CSVGzWriter) Write(p *Product) error
Write appends a single product record to the CSV feed.
type JSONLGzWriter ¶
type JSONLGzWriter struct {
// contains filtered or unexported fields
}
JSONLGzWriter streams products as gzip-compressed JSON Lines.
func NewJSONLGzWriter ¶
func NewJSONLGzWriter(w io.Writer) *JSONLGzWriter
NewJSONLGzWriter creates a writer for gzip-compressed JSON Lines output.
func (*JSONLGzWriter) Close ¶
func (w *JSONLGzWriter) Close() error
Close flushes and finalizes the gzip stream.
func (*JSONLGzWriter) Write ¶
func (w *JSONLGzWriter) Write(p *Product) error
Write appends a single product record as one JSON Lines entry.
type Product ¶
type Product struct {
// EnableSearch controls whether the product can be surfaced in ChatGPT search results.
EnableSearch bool `json:"enable_search" csv:"enable_search"`
// EnableCheckout allows direct purchase inside ChatGPT when EnableSearch is true.
EnableCheckout bool `json:"enable_checkout" csv:"enable_checkout"`
// ID is the merchant product identifier and must remain stable over time.
//
// Example: SKU12345
ID string `json:"id" csv:"id"`
// GTIN is a universal product identifier such as GTIN, UPC, or ISBN.
//
// Example: 123456789543
GTIN string `json:"gtin,omitempty" csv:"gtin"`
// MPN is the manufacturer part number, required if GTIN is absent.
//
// Example: GPT5
MPN string `json:"mpn,omitempty" csv:"mpn"`
// Title is the product title shown to shoppers.
//
// Example: Men's Trail Running Shoes Black
Title string `json:"title" csv:"title"`
// Description is the full product description, plain text.
//
// Example: Waterproof trail shoe with cushioned sole…
Description string `json:"description" csv:"description"`
// Link is the product detail page URL.
//
// Example: https://example.com/product/SKU12345
Link string `json:"link" csv:"link"`
// Condition is the product condition such as new, refurbished, or used.
//
// Example: new
Condition ProductCondition `json:"condition,omitempty" csv:"condition"`
// ProductCategory is the taxonomy path using a ">" separator.
ProductCategory string `json:"product_category" csv:"product_category"`
// Brand is the product brand name.
Brand string `json:"brand,omitempty" csv:"brand"`
// Material describes the primary material.
Material string `json:"material,omitempty" csv:"material"`
// Dimensions is the overall size formatted as LxWxH with a unit.
Dimensions string `json:"dimensions,omitempty" csv:"dimensions"`
// Length is the individual length dimension with a unit.
Length string `json:"length,omitempty" csv:"length"`
// Width is the individual width dimension with a unit.
Width string `json:"width,omitempty" csv:"width"`
// Height is the individual height dimension with a unit.
Height string `json:"height,omitempty" csv:"height"`
// Weight is the product weight with a unit.
Weight string `json:"weight,omitempty" csv:"weight"`
// AgeGroup is the target demographic such as newborn, infant, toddler, kids, or adult.
AgeGroup ProductAgeGroup `json:"age_group,omitempty" csv:"age_group"`
// ImageLink is the main product image URL.
ImageLink string `json:"image_link" csv:"image_link"`
// AdditionalImageLink lists extra image URLs (comma-separated in CSV).
AdditionalImageLink []string `json:"additional_image_link,omitempty" csv:"additional_image_link"`
// VideoLink is a publicly accessible product video URL.
VideoLink string `json:"video_link,omitempty" csv:"video_link"`
// Model3DLink is a 3D model URL (GLB/GLTF preferred).
Model3DLink string `json:"model_3d_link,omitempty" csv:"model_3d_link"`
// Price is the regular price with ISO 4217 currency code.
Price string `json:"price" csv:"price"`
// SalePrice is the discounted price with currency code.
SalePrice string `json:"sale_price,omitempty" csv:"sale_price"`
// SalePriceEffectiveDate is the ISO 8601 sale window date range.
SalePriceEffectiveDate string `json:"sale_price_effective_date,omitempty" csv:"sale_price_effective_date"`
// UnitPricingMeasure and BaseMeasure describe unit pricing (both required together).
UnitPricingMeasure string `json:"unit_pricing_measure,omitempty" csv:"unit_pricing_measure"`
// BaseMeasure is the base unit used for unit pricing.
BaseMeasure string `json:"base_measure,omitempty" csv:"base_measure"`
// PricingTrend is a short string like "Lowest price in N months".
PricingTrend string `json:"pricing_trend,omitempty" csv:"pricing_trend"`
// Availability is the stock status: in_stock, out_of_stock, or preorder.
Availability string `json:"availability" csv:"availability"`
// AvailabilityDate is the ISO 8601 availability date for preorder items.
AvailabilityDate string `json:"availability_date,omitempty" csv:"availability_date"`
// InventoryQuantity is the non-negative stock count.
InventoryQuantity *int `json:"inventory_quantity,omitempty" csv:"inventory_quantity"`
// ExpirationDate is the ISO 8601 date to remove the product after.
ExpirationDate string `json:"expiration_date,omitempty" csv:"expiration_date"`
// PickupMethod specifies pickup options: in_store, reserve, or not_supported.
PickupMethod string `json:"pickup_method,omitempty" csv:"pickup_method"`
// PickupSLA is the pickup service-level agreement, like "1 day".
PickupSLA string `json:"pickup_sla,omitempty" csv:"pickup_sla"`
// ItemGroupID groups variants under a canonical product listing.
ItemGroupID string `json:"item_group_id,omitempty" csv:"item_group_id"`
// ItemGroupTitle is the title for the variant group.
ItemGroupTitle string `json:"item_group_title,omitempty" csv:"item_group_title"`
// Color is the variant color.
Color string `json:"color,omitempty" csv:"color"`
// Size is the variant size.
Size string `json:"size,omitempty" csv:"size"`
// SizeSystem is the ISO 3166 size system code, such as US.
SizeSystem string `json:"size_system,omitempty" csv:"size_system"`
// Gender is the target gender: male, female, or unisex.
Gender string `json:"gender,omitempty" csv:"gender"`
// OfferID identifies a specific offer (SKU + seller + price), unique within the feed.
OfferID string `json:"offer_id,omitempty" csv:"offer_id"`
// CustomVariant1Category names the first custom variant dimension.
CustomVariant1Category string `json:"custom_variant1_category,omitempty" csv:"custom_variant1_category"`
// CustomVariant1Option provides the option value for custom variant 1.
CustomVariant1Option string `json:"custom_variant1_option,omitempty" csv:"custom_variant1_option"`
// CustomVariant2Category names the second custom variant dimension.
CustomVariant2Category string `json:"custom_variant2_category,omitempty" csv:"custom_variant2_category"`
// CustomVariant2Option provides the option value for custom variant 2.
CustomVariant2Option string `json:"custom_variant2_option,omitempty" csv:"custom_variant2_option"`
// CustomVariant3Category names the third custom variant dimension.
CustomVariant3Category string `json:"custom_variant3_category,omitempty" csv:"custom_variant3_category"`
// CustomVariant3Option provides the option value for custom variant 3.
CustomVariant3Option string `json:"custom_variant3_option,omitempty" csv:"custom_variant3_option"`
// Shipping lists shipping entries in country:region:service_class:price format.
Shipping []string `json:"shipping,omitempty" csv:"shipping"`
// DeliveryEstimate is the ISO 8601 estimated arrival date.
DeliveryEstimate string `json:"delivery_estimate,omitempty" csv:"delivery_estimate"`
// SellerName is the merchant display name.
SellerName string `json:"seller_name" csv:"seller_name"`
// SellerURL is the merchant storefront URL.
SellerURL string `json:"seller_url" csv:"seller_url"`
// SellerPrivacyPolicy is the seller-specific privacy policy URL.
SellerPrivacyPolicy string `json:"seller_privacy_policy,omitempty" csv:"seller_privacy_policy"`
// SellerTOS is the seller-specific terms of service URL.
SellerTOS string `json:"seller_tos,omitempty" csv:"seller_tos"`
// ReturnPolicy is the return policy URL.
ReturnPolicy string `json:"return_policy,omitempty" csv:"return_policy"`
// ReturnWindow is the number of days allowed for returns.
ReturnWindow *int `json:"return_window,omitempty" csv:"return_window"`
// PopularityScore is a popularity indicator (for example, 0-5 scale).
PopularityScore *float64 `json:"popularity_score,omitempty" csv:"popularity_score"`
// ReturnRate is the percentage of returns, 0-100%.
ReturnRate string `json:"return_rate,omitempty" csv:"return_rate"`
// Warning is a product disclaimer or regulatory warning.
Warning string `json:"warning,omitempty" csv:"warning"`
// WarningURL links to warning details and must resolve.
WarningURL string `json:"warning_url,omitempty" csv:"warning_url"`
// AgeRestriction is the minimum purchase age.
AgeRestriction *int `json:"age_restriction,omitempty" csv:"age_restriction"`
// ProductReviewCount is the number of product reviews.
ProductReviewCount *int `json:"product_review_count,omitempty" csv:"product_review_count"`
// ProductReviewRating is the average product review score.
ProductReviewRating *float64 `json:"product_review_rating,omitempty" csv:"product_review_rating"`
// StoreReviewCount is the number of brand or store reviews.
StoreReviewCount *int `json:"store_review_count,omitempty" csv:"store_review_count"`
// StoreReviewRating is the average brand or store rating.
StoreReviewRating *float64 `json:"store_review_rating,omitempty" csv:"store_review_rating"`
// QAndA is FAQ content in plain text.
QAndA string `json:"q_and_a,omitempty" csv:"q_and_a"`
// RawReviewData contains raw review payloads and may include JSON blobs.
RawReviewData string `json:"raw_review_data,omitempty" csv:"raw_review_data"`
// RelatedProductID lists associated product IDs (comma-separated in CSV).
RelatedProductID []string `json:"related_product_id,omitempty" csv:"related_product_id"`
// RelationshipType describes how related products connect (for example, part_of_set).
RelationshipType string `json:"relationship_type,omitempty" csv:"relationship_type"`
// GeoPrice lists country-specific prices using ISO 3166-1 country codes.
//
// Example: 79.99 EUR (California)
GeoPrice []string `json:"geo_price,omitempty" csv:"geo_price"`
// GeoAvailability lists country-specific availability using ISO 3166-1 country codes.
//
// Example: in_stock (Texas), out_of_stock (New York)
GeoAvailability []string `json:"geo_availability,omitempty" csv:"geo_availability"`
}
Product describes a single product entry in an ACP product feed. Field names follow the feed specification for JSONL and CSV export.
type ProductAgeGroup ¶
type ProductAgeGroup string
ProductAgeGroup is the target demographic of the product.
const ( ProductAgeGroupNewborn ProductAgeGroup = "newborn" ProductAgeGroupInfant ProductAgeGroup = "infant" ProductAgeGroupToddler ProductAgeGroup = "toddler" ProductAgeGroupKids ProductAgeGroup = "kids" ProductAgeGroupAdult ProductAgeGroup = "adult" )
type ProductCondition ¶
type ProductCondition string
ProductCondition is the condition of the product.
const ( ProductConditionNew ProductCondition = "new" ProductConditionRefurbished ProductCondition = "refurbished" ProductConditionUsed ProductCondition = "used" )