Code Examples

Practical examples for consuming ACP product feeds in your agent applications.

Fetch Brand Directory (cURL)

curl
curl -H "Accept: application/json" \
  https://feeds.gxo.dev/v1/index.json

Fetch Product Feed (Node.js)

node
const response = await fetch(
  'https://feeds.gxo.dev/v1/feeds/acme-electronics/products.json'
);
const products = await response.json();

console.log(`Found ${products.length} products`);
products.forEach(product => {
  console.log(`${product.name}: $${product.price.amount}`);
});

Stream NDJSON Feed (Python)

node
import requests
import json

url = 'https://feeds.gxo.dev/v1/feeds/acme-electronics/products.ndjson'
response = requests.get(url, stream=True)

for line in response.iter_lines():
    if line:
        product = json.loads(line)
        print(f"{product['name']}: ${product['price']['amount']}")

Filter by Availability (JavaScript)

node
const response = await fetch(
  'https://feeds.gxo.dev/v1/feeds/acme-electronics/products.json'
);
const products = await response.json();

const inStock = products.filter(p => p.availability === 'in_stock');
console.log(`${inStock.length} products in stock`);
Code Examples | GXO Feeds