dsajlk
dsajlk
CDCloudflare Developers
Created by dsajlk on 6/25/2024 in #workers-help
How to get Requests today through API
The https://api.cloudflare.com/client/v4/graphql interface is a general interface that can obtain data by passing in different parameters.
3 replies
CDCloudflare Developers
Created by dsajlk on 6/25/2024 in #workers-help
How to get Requests today through API
Self-questioning and self-answering. I got the graphql by grabbing the dash request, adjusted it and put it into the api interface for request and found it was available.
curl -X POST "https://api.cloudflare.com/client/v4/graphql" \
-H "Authorization: Bearer {apiToken}" \
-H "Content-Type: application/json" \
--data '{"query":"query getServiceRequestsQuery($accountTag: String, $filter: ZoneWorkersRequestsFilter_InputObject) { viewer { accounts(filter: { accountTag: $accountTag }) { workersInvocationsAdaptive(limit: 10000, filter: $filter) { sum { requests } } } } }","variables":{"accountTag":"{accountId}}","filter":{"AND":[{"datetimeHour_leq":"2024-06-26T15:25:19Z","datetimeHour_geq":"2024-06-26T00:00:00Z"}]}}}'
curl -X POST "https://api.cloudflare.com/client/v4/graphql" \
-H "Authorization: Bearer {apiToken}" \
-H "Content-Type: application/json" \
--data '{"query":"query getServiceRequestsQuery($accountTag: String, $filter: ZoneWorkersRequestsFilter_InputObject) { viewer { accounts(filter: { accountTag: $accountTag }) { workersInvocationsAdaptive(limit: 10000, filter: $filter) { sum { requests } } } } }","variables":{"accountTag":"{accountId}}","filter":{"AND":[{"datetimeHour_leq":"2024-06-26T15:25:19Z","datetimeHour_geq":"2024-06-26T00:00:00Z"}]}}}'
3 replies