2025/03/14

透過CloudFlare GraphQL 取得SubDomain國家來源數據

權限要給Zone/Logs & Analytics
curl -X POST "https://api.cloudflare.com/client/v4/graphql" ^
  -H "Authorization: Bearer YourToken" ^
  -H "Content-Type: application/json" ^
  --data "{ \"query\": \"query { viewer { zones(filter: { zoneTag: \\\"YourZoneID\\\" }) { httpRequestsAdaptiveGroups( limit: 1000, filter: { clientRequestHTTPHost: \\\"YourSubDomain\\\", datetime_geq: \\\"2025-03-13T00:00:00Z\\\", datetime_lt: \\\"2025-03-14T00:00:00Z\\\" }, orderBy: [count_DESC] ) { dimensions { clientCountryName } count sum { edgeResponseBytes } } } } }\" }"