Core API
- Checkout
- Checkout Links
- Custom Checkout Fields
- Customers
- Subscriptions
- Orders
- Discounts
- Refunds
- Products
- Benefits
- License Keys
- Files
- Organizations
- Metrics
Customer Portal API
- GETGet Customer
- GETGet Organization
- Sessions
- Subscriptions
- Orders
- License Keys
- File Downloads
Webhook Events
- Billing Events
- Organization Events
OAuth 2.0 API
- Connect
- Clients
Get Metrics
Get metrics about your orders and subscriptions.
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.Metrics.Get(ctx, operations.MetricsGetRequest{
StartDate: types.MustDateFromString("2025-02-06"),
EndDate: types.MustDateFromString("2024-09-04"),
Interval: components.TimeIntervalWeek,
})
if err != nil {
log.Fatal(err)
}
if res.MetricsResponse != nil {
// handle response
}
}
{
"periods": [
{
"timestamp": "2023-11-07T05:31:56Z",
"orders": 123,
"revenue": 123,
"cumulative_revenue": 123,
"average_order_value": 123,
"one_time_products": 123,
"one_time_products_revenue": 123,
"new_subscriptions": 123,
"new_subscriptions_revenue": 123,
"renewed_subscriptions": 123,
"renewed_subscriptions_revenue": 123,
"active_subscriptions": 123,
"monthly_recurring_revenue": 123
}
],
"metrics": {
"orders": {
"slug": "<string>",
"display_name": "<string>",
"type": "scalar"
},
"revenue": {
"slug": "<string>",
"display_name": "<string>",
"type": "scalar"
},
"cumulative_revenue": {
"slug": "<string>",
"display_name": "<string>",
"type": "scalar"
},
"average_order_value": {
"slug": "<string>",
"display_name": "<string>",
"type": "scalar"
},
"one_time_products": {
"slug": "<string>",
"display_name": "<string>",
"type": "scalar"
},
"one_time_products_revenue": {
"slug": "<string>",
"display_name": "<string>",
"type": "scalar"
},
"new_subscriptions": {
"slug": "<string>",
"display_name": "<string>",
"type": "scalar"
},
"new_subscriptions_revenue": {
"slug": "<string>",
"display_name": "<string>",
"type": "scalar"
},
"renewed_subscriptions": {
"slug": "<string>",
"display_name": "<string>",
"type": "scalar"
},
"renewed_subscriptions_revenue": {
"slug": "<string>",
"display_name": "<string>",
"type": "scalar"
},
"active_subscriptions": {
"slug": "<string>",
"display_name": "<string>",
"type": "scalar"
},
"monthly_recurring_revenue": {
"slug": "<string>",
"display_name": "<string>",
"type": "scalar"
}
}
}
Authorizations
Bearer authentication header of the form Bearer <token>
, where <token>
is your auth token.
Query Parameters
Start date.
End date.
Interval between two timestamps.
year
, month
, week
, day
, hour
Filter by organization ID.
Filter by product ID.
Filter by billing type. recurring
will filter data corresponding to subscriptions creations or renewals. one_time
will filter data corresponding to one-time purchases.
one_time
, recurring
Filter by customer ID.
Response
Metrics response schema.
List of data for each timestamp.
Timestamp of this period data.
Information about the returned metrics.
Information about a metric.
Information about a metric.
Information about a metric.
Unique identifier for the metric.
Human-readable name for the metric.
Type of the metric, useful to know the unit or format of the value.
scalar
, currency
Information about a metric.
Unique identifier for the metric.
Human-readable name for the metric.
Type of the metric, useful to know the unit or format of the value.
scalar
, currency
Information about a metric.
Unique identifier for the metric.
Human-readable name for the metric.
Type of the metric, useful to know the unit or format of the value.
scalar
, currency
Information about a metric.
Unique identifier for the metric.
Human-readable name for the metric.
Type of the metric, useful to know the unit or format of the value.
scalar
, currency
Information about a metric.
Unique identifier for the metric.
Human-readable name for the metric.
Type of the metric, useful to know the unit or format of the value.
scalar
, currency
Information about a metric.
Unique identifier for the metric.
Human-readable name for the metric.
Type of the metric, useful to know the unit or format of the value.
scalar
, currency
Information about a metric.
Unique identifier for the metric.
Human-readable name for the metric.
Type of the metric, useful to know the unit or format of the value.
scalar
, currency
Information about a metric.
Unique identifier for the metric.
Human-readable name for the metric.
Type of the metric, useful to know the unit or format of the value.
scalar
, currency
Information about a metric.
Unique identifier for the metric.
Human-readable name for the metric.
Type of the metric, useful to know the unit or format of the value.
scalar
, currency
Information about a metric.
Unique identifier for the metric.
Human-readable name for the metric.
Type of the metric, useful to know the unit or format of the value.
scalar
, currency
Was this page helpful?
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.Metrics.Get(ctx, operations.MetricsGetRequest{
StartDate: types.MustDateFromString("2025-02-06"),
EndDate: types.MustDateFromString("2024-09-04"),
Interval: components.TimeIntervalWeek,
})
if err != nil {
log.Fatal(err)
}
if res.MetricsResponse != nil {
// handle response
}
}
{
"periods": [
{
"timestamp": "2023-11-07T05:31:56Z",
"orders": 123,
"revenue": 123,
"cumulative_revenue": 123,
"average_order_value": 123,
"one_time_products": 123,
"one_time_products_revenue": 123,
"new_subscriptions": 123,
"new_subscriptions_revenue": 123,
"renewed_subscriptions": 123,
"renewed_subscriptions_revenue": 123,
"active_subscriptions": 123,
"monthly_recurring_revenue": 123
}
],
"metrics": {
"orders": {
"slug": "<string>",
"display_name": "<string>",
"type": "scalar"
},
"revenue": {
"slug": "<string>",
"display_name": "<string>",
"type": "scalar"
},
"cumulative_revenue": {
"slug": "<string>",
"display_name": "<string>",
"type": "scalar"
},
"average_order_value": {
"slug": "<string>",
"display_name": "<string>",
"type": "scalar"
},
"one_time_products": {
"slug": "<string>",
"display_name": "<string>",
"type": "scalar"
},
"one_time_products_revenue": {
"slug": "<string>",
"display_name": "<string>",
"type": "scalar"
},
"new_subscriptions": {
"slug": "<string>",
"display_name": "<string>",
"type": "scalar"
},
"new_subscriptions_revenue": {
"slug": "<string>",
"display_name": "<string>",
"type": "scalar"
},
"renewed_subscriptions": {
"slug": "<string>",
"display_name": "<string>",
"type": "scalar"
},
"renewed_subscriptions_revenue": {
"slug": "<string>",
"display_name": "<string>",
"type": "scalar"
},
"active_subscriptions": {
"slug": "<string>",
"display_name": "<string>",
"type": "scalar"
},
"monthly_recurring_revenue": {
"slug": "<string>",
"display_name": "<string>",
"type": "scalar"
}
}
}