Skip to content
Docs

    List Usage Records

    client.Usage.List(ctx, query) (*Cursor[Usage], error)
    GET/v1/usage

    List per-resource usage records for the current organization. Each item is one resource with its nested dimension history (active and closed segments).

    ParametersExpand Collapse
    query UsageListParams
    Cursor param.Field[string]Optional

    Pagination cursor returned by a previous request

    Limit param.Field[int64]Optional

    Maximum number of items to return

    maximum100
    minimum10
    ReturnsExpand Collapse
    type Usage struct{…}

    Usage record for a single metered resource.

    Dimensions []UsageDimension
    ID string
    Dimension string
    EndedAt string
    Quantity int64
    StartedAt string
    Children []UsageDimensionLeafOptional
    ID string
    Dimension string
    EndedAt string
    Quantity int64
    StartedAt string
    EndedAt string
    ProjectID string
    Region RegionName

    Region the resource is in.

    ResourceID string
    ResourceType UsageResourceType

    Kind of metered resource a ledger row belongs to.

    One of the following:
    const UsageResourceTypeVM UsageResourceType = "vm"
    const UsageResourceTypeVolume UsageResourceType = "volume"
    const UsageResourceTypeVPC UsageResourceType = "vpc"
    const UsageResourceTypeConnectConnection UsageResourceType = "connect_connection"
    const UsageResourceTypeNKSCluster UsageResourceType = "nks_cluster"
    const UsageResourceTypeNKSNodePool UsageResourceType = "nks_node_pool"
    const UsageResourceTypeNKSLoadBalancer UsageResourceType = "nks_load_balancer"
    StartedAt string

    List Usage Records

    package main
    
    import (
      "context"
      "fmt"
    
      "github.com/nirvana-labs/nirvana-go"
      "github.com/nirvana-labs/nirvana-go/option"
      "github.com/nirvana-labs/nirvana-go/usage"
    )
    
    func main() {
      client := nirvana.NewClient(
        option.WithAPIKey("My API Key"),
      )
      page, err := client.Usage.List(context.TODO(), usage.UsageListParams{
    
      })
      if err != nil {
        panic(err.Error())
      }
      fmt.Printf("%+v\n", page)
    }
    
    {
      "items": [
        {
          "dimensions": [
            {
              "id": "123e4567-e89b-12d3-a456-426614174000",
              "dimension": "compute_n1_standard_8",
              "ended_at": "2026-02-01T00:00:00Z",
              "quantity": 1,
              "started_at": "2026-01-01T00:00:00Z",
              "children": [
                {
                  "id": "123e4567-e89b-12d3-a456-426614174000",
                  "dimension": "compute_vcpu",
                  "ended_at": "2026-02-01T00:00:00Z",
                  "quantity": 2,
                  "started_at": "2026-01-01T00:00:00Z"
                }
              ]
            }
          ],
          "ended_at": "2026-02-01T00:00:00Z",
          "project_id": "123e4567-e89b-12d3-a456-426614174000",
          "region": "us-sva-2",
          "resource_id": "123e4567-e89b-12d3-a456-426614174000",
          "resource_type": "vm",
          "started_at": "2026-01-01T00:00:00Z"
        }
      ],
      "pagination": {
        "next_cursor": "RhwniMT4B74siYZcPF8TnCdGI1l9rpPvg",
        "previous_cursor": "ARhwnmi1hA7wEbHbMjdYQlOB_ZusP4fYvw",
        "total_count": 125
      }
    }
    Returns Examples
    {
      "items": [
        {
          "dimensions": [
            {
              "id": "123e4567-e89b-12d3-a456-426614174000",
              "dimension": "compute_n1_standard_8",
              "ended_at": "2026-02-01T00:00:00Z",
              "quantity": 1,
              "started_at": "2026-01-01T00:00:00Z",
              "children": [
                {
                  "id": "123e4567-e89b-12d3-a456-426614174000",
                  "dimension": "compute_vcpu",
                  "ended_at": "2026-02-01T00:00:00Z",
                  "quantity": 2,
                  "started_at": "2026-01-01T00:00:00Z"
                }
              ]
            }
          ],
          "ended_at": "2026-02-01T00:00:00Z",
          "project_id": "123e4567-e89b-12d3-a456-426614174000",
          "region": "us-sva-2",
          "resource_id": "123e4567-e89b-12d3-a456-426614174000",
          "resource_type": "vm",
          "started_at": "2026-01-01T00:00:00Z"
        }
      ],
      "pagination": {
        "next_cursor": "RhwniMT4B74siYZcPF8TnCdGI1l9rpPvg",
        "previous_cursor": "ARhwnmi1hA7wEbHbMjdYQlOB_ZusP4fYvw",
        "total_count": 125
      }
    }