GET
/
v1
/
meters
/
{id}
/
quantities
package main

import(
	"context"
	"os"
	polargo "github.com/polarsource/polar-go"
	"github.com/polarsource/polar-go/types"
	"github.com/polarsource/polar-go/models/components"
	"github.com/polarsource/polar-go/models/operations"
	"log"
)

func main() {
    ctx := context.Background()

    s := polargo.New(
        polargo.WithSecurity(os.Getenv("POLAR_ACCESS_TOKEN")),
    )

    res, err := s.Meters.Quantities(ctx, operations.MetersQuantitiesRequest{
        ID: "<value>",
        StartTimestamp: types.MustTimeFromString("2023-09-17T00:45:34.608Z"),
        EndTimestamp: types.MustTimeFromString("2023-07-21T18:11:39.069Z"),
        Interval: components.TimeIntervalHour,
    })
    if err != nil {
        log.Fatal(err)
    }
    if res.MeterQuantities != nil {
        // handle response
    }
}
{
  "quantities": [
    {
      "timestamp": "2023-11-07T05:31:56Z",
      "quantity": 10
    }
  ],
  "total": 100
}

Authorizations

Authorization
string
header
required

You can generate an Organization Access Token from your organization's settings.

Path Parameters

id
string
required

The meter ID.

Query Parameters

start_timestamp
string
required

Start timestamp.

end_timestamp
string
required

End timestamp.

interval
enum<string>
required

Interval between two timestamps.

Available options:
year,
month,
week,
day,
hour
customer_id

Filter by customer ID.

external_customer_id

Filter by external customer ID.

Response

200
application/json
Successful Response
quantities
object[]
required
total
number
required

The total quantity for the period.

Example:

100

Was this page helpful?