Skip to content
Start here

Get Account-Level Metrics

r2.buckets.metrics.list(MetricListParams**kwargs) -> MetricListResponse
GET/accounts/{account_id}/r2/metrics

Get Storage/Object Count Metrics across all buckets in your account. Note that Account-Level Metrics may not immediately reflect the latest data.

Security

API Token

The preferred authorization scheme for interacting with the Cloudflare API. Create a token.

Example:Authorization: Bearer Sn3lZJTBX6kkg7OdcBUAxOO963GEIyGQqnFTOFYY
ParametersExpand Collapse
account_id: str

Account ID.

maxLength32
ReturnsExpand Collapse
class MetricListResponse:

Metrics based on the class they belong to.

infrequent_access: Optional[InfrequentAccess]

Metrics based on what state they are in(uploaded or published).

published: Optional[InfrequentAccessPublished]

Metrics on number of objects/amount of storage used.

metadata_size: Optional[float]

Amount of.

objects: Optional[float]

Number of objects stored.

payload_size: Optional[float]

Amount of storage used by object data.

uploaded: Optional[InfrequentAccessUploaded]

Metrics on number of objects/amount of storage used.

metadata_size: Optional[float]

Amount of.

objects: Optional[float]

Number of objects stored.

payload_size: Optional[float]

Amount of storage used by object data.

standard: Optional[Standard]

Metrics based on what state they are in(uploaded or published).

published: Optional[StandardPublished]

Metrics on number of objects/amount of storage used.

metadata_size: Optional[float]

Amount of.

objects: Optional[float]

Number of objects stored.

payload_size: Optional[float]

Amount of storage used by object data.

uploaded: Optional[StandardUploaded]

Metrics on number of objects/amount of storage used.

metadata_size: Optional[float]

Amount of.

objects: Optional[float]

Number of objects stored.

payload_size: Optional[float]

Amount of storage used by object data.

Get Account-Level Metrics

import os
from cloudflare import Cloudflare

client = Cloudflare(
    api_token=os.environ.get("CLOUDFLARE_API_TOKEN"),  # This is the default and can be omitted
)
metrics = client.r2.buckets.metrics.list(
    account_id="023e105f4ecef8ad9ca31a8372d0c353",
)
print(metrics.infrequent_access)
{
  "errors": [
    {
      "code": 1000,
      "message": "message",
      "documentation_url": "documentation_url",
      "source": {
        "pointer": "pointer"
      }
    }
  ],
  "messages": [
    "string"
  ],
  "result": {
    "infrequentAccess": {
      "published": {
        "metadataSize": 0,
        "objects": 0,
        "payloadSize": 0
      },
      "uploaded": {
        "metadataSize": 0,
        "objects": 0,
        "payloadSize": 0
      }
    },
    "standard": {
      "published": {
        "metadataSize": 0,
        "objects": 0,
        "payloadSize": 0
      },
      "uploaded": {
        "metadataSize": 0,
        "objects": 0,
        "payloadSize": 0
      }
    }
  },
  "success": true
}
Returns Examples
{
  "errors": [
    {
      "code": 1000,
      "message": "message",
      "documentation_url": "documentation_url",
      "source": {
        "pointer": "pointer"
      }
    }
  ],
  "messages": [
    "string"
  ],
  "result": {
    "infrequentAccess": {
      "published": {
        "metadataSize": 0,
        "objects": 0,
        "payloadSize": 0
      },
      "uploaded": {
        "metadataSize": 0,
        "objects": 0,
        "payloadSize": 0
      }
    },
    "standard": {
      "published": {
        "metadataSize": 0,
        "objects": 0,
        "payloadSize": 0
      },
      "uploaded": {
        "metadataSize": 0,
        "objects": 0,
        "payloadSize": 0
      }
    }
  },
  "success": true
}