R2- getting bucket size

Hey, I’d like to know if there is programmatic way to see the bucket size in r2?
Since it is is only updated once a day in Aws I am looking at r2 docs and couldn’t find info on bucket size requests.
Thank you😀

You can do it with the graphql API. GraphQL Analytics API · Cloudflare Analytics docs If you open dev tools when looking at dashboard you can copy the queries

1 Like

thanks!! @Cyb3r-Jak3
the query i saw was this:

{"operationName":"getR2OperationsQuery","variables":{"accountTag":"160a4a0512e4ea5efe4af6d7601605ad","filter":{"AND":[{"date_leq":"2023-04-18","date_geq":"2023-04-01","actionType_in":["HeadBucket","HeadObject","GetObject","ReportUsageSummary","GetBucketEncryption","GetBucketLocation"],"bucketName":"wise","actionStatus_in":["success","userError"]}]}},"query":"query getR2OperationsQuery($accountTag: string, $filter: AccountR2OperationsAdaptiveGroupsFilter_InputObject) {\n  viewer {\n    accounts(filter: {accountTag: $accountTag}) {\n      r2OperationsAdaptiveGroups(limit: 10000, filter: $filter) {\n        sum {\n          requests\n          __typename\n        }\n        __typename\n      }\n      __typename\n    }\n    __typename\n  }\n}\n"}

but seems to not return anything, do you have any ideas by any chance?

Never mind that’s another query, the size I see is only gotten from an api call to the server and I must be logged in, I guess this is not supported😥

nevermind, thank you!! this is the request to get the size. https://api.cloudflare.com/client/v4/accounts/{account-id}/r2/buckets/{bucket-name}/usage?=null

This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.