Routing API
GeoIP lookups and IP validation
Overview
The Routing API provides GeoIP information lookup and IP address validation for routing decisions.
Base URL
https://<manager-host>/api/v1/routing
Endpoints
GET /api/v1/routing/geoip
Look up GeoIP information for an IP address.
Query Parameters:
ip- IP address to look up
Success Response (200):
{
"city": {
"name": "Washington"
},
"asn": 64512
}
Errors:
400- Invalid IP format500- Backend failure
Caching: Cache-Control: public, max-age=86400 (24 hours)
Example:
curl -s "https://cdn-manager/api/v1/routing/geoip?ip=149.101.100.0"
GET /api/v1/routing/validate
Validate if an IP address is allowed (not blocked).
Query Parameters:
ip- IP address to validate
Success Response (200): Empty body (IP is allowed)
Forbidden Response (403):
Access Denied
Errors:
400- Invalid IP format500- Backend failure
Caching: Cache-Control headers included (default: max-age=300, configurable via [tuning] section)
Example:
curl -i "https://cdn-manager/api/v1/routing/validate?ip=149.101.100.0"
Use Cases
GeoIP-Based Routing
Use the /geoip endpoint to determine the geographic location and ASN of an IP address for routing decisions:
# Get location data for routing
IP_INFO=$(curl -s "https://cdn-manager/api/v1/routing/geoip?ip=203.0.113.50")
CITY=$(echo "$IP_INFO" | jq -r '.city.name')
ASN=$(echo "$IP_INFO" | jq -r '.asn')
echo "Routing based on city: $CITY, ASN: $ASN"
IP Validation
Use the /validate endpoint to check if an IP is allowed before processing requests:
# Check if IP is allowed
RESPONSE=$(curl -s -o /dev/null -w "%{http_code}" \
"https://cdn-manager/api/v1/routing/validate?ip=203.0.113.50")
if [ "$RESPONSE" = "200" ]; then
echo "IP is allowed"
elif [ "$RESPONSE" = "403" ]; then
echo "IP is blocked"
fi
Next Steps
- Discovery API - Host and namespace discovery
- Metrics API - Metrics submission and aggregation
- OpenAPI Specification - Complete API specification