GPC API Demo
This page demonstrates how to use the GPC API endpoints to access product classification data.
The API provides RESTful endpoints for accessing all levels of the GPC hierarchy: Segments, Families, Classes, Bricks, and Attributes. You can also search across all entities using the search endpoint.
For full API documentation, visit Swagger UI or ReDoc.
API Explorer
Select an API endpoint:
API Request:
GET
/api/gpc/segments/
API Response:
Execute an API request to see the response.
API Usage Examples
JavaScript Example:
// Using the provided gpcApi client
const gpcApi = window.gpcApi;
// Get all segments
gpcApi.getSegments()
.then(data => console.log('Segments:', data))
.catch(error => console.error('Error:', error));
// Search for products
gpcApi.search('food')
.then(data => console.log('Search results:', data))
.catch(error => console.error('Error:', error));
// Get a specific brick with attributes
gpcApi.getBrick('10000309')
.then(data => console.log('Brick details:', data))
.catch(error => console.error('Error:', error));
Python Example:
import requests
base_url = 'https://your-domain.com/api/gpc'
# Get all segments
response = requests.get(f'{base_url}/segments/')
segments = response.json()
print(f"Segments: {segments}")
# Search for products
response = requests.get(f'{base_url}/search/', params={'q': 'food'})
search_results = response.json()
print(f"Search results: {search_results}")
# Get a specific brick with attributes
response = requests.get(f'{base_url}/bricks/10000309/')
brick_details = response.json()
print(f"Brick details: {brick_details}")