The PostgREST API is available at http://localhost:3000
gaiaCore uses two schemas:
- backbone: Metadata tables (data_source, variable_source, geom_template, attr_template)
- working: Operational tables (location, location_history, external_exposure)
When accessing tables, you need to specify which schema using the Accept-Profile header:
# Access working schema tables
curl -H "Accept-Profile: working" http://localhost:3000/location
curl -H "Accept-Profile: working" http://localhost:3000/location_history
curl -H "Accept-Profile: working" http://localhost:3000/external_exposure
# Access backbone schema tables (default if no header)
curl http://localhost:3000/data_source
curl http://localhost:3000/variable_source
curl http://localhost:3000/geom_template
curl http://localhost:3000/attr_templatePostgREST exposes both schemas (backbone and working) as configured in PGRST_DB_SCHEMAS. When you don't specify a schema profile, PostgREST defaults to the first schema listed (backbone). To access tables in other schemas, use the Accept-Profile header.
# Get all locations
curl -H "Accept-Profile: working" http://localhost:3000/location | jq '.'
# Get specific location by ID
curl -H "Accept-Profile: working" "http://localhost:3000/location?location_id=eq.1" | jq '.'
# Filter locations by city
curl -H "Accept-Profile: working" "http://localhost:3000/location?city=eq.FRESNO" | jq '.'
# Select specific columns
curl -H "Accept-Profile: working" "http://localhost:3000/location?select=location_id,address_1,city,latitude,longitude" | jq '.'
# Limit results
curl -H "Accept-Profile: working" "http://localhost:3000/location?limit=10" | jq '.'# Get all location history
curl -H "Accept-Profile: working" http://localhost:3000/location_history | jq '.'
# Get location history for specific location
curl -H "Accept-Profile: working" "http://localhost:3000/location_history?location_id=eq.1" | jq '.'
# Join location and location_history
curl -H "Accept-Profile: working" "http://localhost:3000/location?select=*,location_history(*)" | jq '.'# Get all exposure results
curl -H "Accept-Profile: working" http://localhost:3000/external_exposure | jq '.'
# Filter by location
curl -H "Accept-Profile: working" "http://localhost:3000/external_exposure?location_id=eq.1" | jq '.'# Get all data sources (backbone schema - no header needed)
curl http://localhost:3000/data_source | jq '.'
# Get all variables
curl http://localhost:3000/variable_source | jq '.'
# Get specific data source with its variables
curl "http://localhost:3000/data_source?select=*,variable_source(*)" | jq '.'# Load JSON-LD metadata
curl -X POST http://localhost:3000/rpc/load_jsonld_file \
-H "Content-Type: application/json" \
-H "Accept-Profile: backbone" \
-d '{"jsonld_text": "..."}'
# List downloadable data sources
curl -X POST http://localhost:3000/rpc/list_downloadable_datasources \
-H "Accept-Profile: backbone" \
-H "Content-Type: application/json"
# Quick ingest data source
curl -X POST http://localhost:3000/rpc/quick_ingest_datasource \
-H "Accept-Profile: backbone" \
-H "Content-Type: application/json" \
-d '{"p_dataset_name": "example_dataset", "p_download_url": "https://..."}'PostgREST supports powerful filtering:
# Equality
?column=eq.value
# Greater than / Less than
?column=gt.value
?column=lt.value
?column=gte.value
?column=lte.value
# Pattern matching
?column=like.*pattern*
?column=ilike.*pattern* # case insensitive
# In list
?column=in.(value1,value2,value3)
# Null checks
?column=is.null
?column=not.is.null
# Combining filters (AND)
?column1=eq.value1&column2=eq.value2
# Ordering
?order=column.asc
?order=column.desc
# Pagination
?limit=10&offset=20If accessing from a web browser, you may need to enable CORS. Add this to postgrest.conf:
server-cors-allowed-origins = "*"
Then restart the PostgREST container:
docker restart gaiacore-postgrestView the auto-generated API documentation:
curl http://localhost:3000/ | jq '.'Or open in your browser: http://localhost:3000/
Solution: Add the Accept-Profile: working header to access tables in the working schema.
Solutions:
- Check the table has data:
docker exec gaiacore-postgres psql -U postgres -d gaiacore -c "SELECT count(*) FROM working.location;" - Verify your filter syntax
- Check permissions
Solution: Verify the PGRST_DB_ANON_ROLE has proper grants:
GRANT USAGE ON SCHEMA working TO postgres;
GRANT ALL ON ALL TABLES IN SCHEMA working TO postgres;