- list - List Meters
- create - Create Meter
- get - Get Meter
- update - Update Meter
- quantities - Get Meter Quantities
List meters.
Scopes: meters:read meters:write
import { Polar } from "@polar-sh/sdk";
const polar = new Polar({
accessToken: process.env["POLAR_ACCESS_TOKEN"] ?? "",
});
async function run() {
const result = await polar.meters.list({
organizationId: "1dbfc517-0bbf-4301-9ba8-555ca42b9737",
});
for await (const page of result) {
console.log(page);
}
}
run();The standalone function version of this method:
import { PolarCore } from "@polar-sh/sdk/core.js";
import { metersList } from "@polar-sh/sdk/funcs/metersList.js";
// Use `PolarCore` for best tree-shaking performance.
// You can create one instance of it to use across an application.
const polar = new PolarCore({
accessToken: process.env["POLAR_ACCESS_TOKEN"] ?? "",
});
async function run() {
const res = await metersList(polar, {
organizationId: "1dbfc517-0bbf-4301-9ba8-555ca42b9737",
});
if (res.ok) {
const { value: result } = res;
for await (const page of result) {
console.log(page);
}
} else {
console.log("metersList failed:", res.error);
}
}
run();| Parameter | Type | Required | Description |
|---|---|---|---|
request |
operations.MetersListRequest | ✔️ | The request object to use for the request. |
options |
RequestOptions | ➖ | Used to set various options for making HTTP requests. |
options.fetchOptions |
RequestInit | ➖ | Options that are passed to the underlying HTTP request. This can be used to inject extra headers for examples. All Request options, except method and body, are allowed. |
options.retries |
RetryConfig | ➖ | Enables retrying HTTP requests under certain failure conditions. |
Promise<operations.MetersListResponse>
| Error Type | Status Code | Content Type |
|---|---|---|
| errors.HTTPValidationError | 422 | application/json |
| errors.SDKError | 4XX, 5XX | */* |
Create a meter.
Scopes: meters:write
import { Polar } from "@polar-sh/sdk";
const polar = new Polar({
accessToken: process.env["POLAR_ACCESS_TOKEN"] ?? "",
});
async function run() {
const result = await polar.meters.create({
name: "<value>",
filter: {
conjunction: "or",
clauses: [
{
property: "<value>",
operator: "ne",
value: "<value>",
},
],
},
aggregation: {
func: "max",
property: "<value>",
},
organizationId: "1dbfc517-0bbf-4301-9ba8-555ca42b9737",
});
console.log(result);
}
run();The standalone function version of this method:
import { PolarCore } from "@polar-sh/sdk/core.js";
import { metersCreate } from "@polar-sh/sdk/funcs/metersCreate.js";
// Use `PolarCore` for best tree-shaking performance.
// You can create one instance of it to use across an application.
const polar = new PolarCore({
accessToken: process.env["POLAR_ACCESS_TOKEN"] ?? "",
});
async function run() {
const res = await metersCreate(polar, {
name: "<value>",
filter: {
conjunction: "or",
clauses: [
{
property: "<value>",
operator: "ne",
value: "<value>",
},
],
},
aggregation: {
func: "max",
property: "<value>",
},
organizationId: "1dbfc517-0bbf-4301-9ba8-555ca42b9737",
});
if (res.ok) {
const { value: result } = res;
console.log(result);
} else {
console.log("metersCreate failed:", res.error);
}
}
run();| Parameter | Type | Required | Description |
|---|---|---|---|
request |
components.MeterCreate | ✔️ | The request object to use for the request. |
options |
RequestOptions | ➖ | Used to set various options for making HTTP requests. |
options.fetchOptions |
RequestInit | ➖ | Options that are passed to the underlying HTTP request. This can be used to inject extra headers for examples. All Request options, except method and body, are allowed. |
options.retries |
RetryConfig | ➖ | Enables retrying HTTP requests under certain failure conditions. |
Promise<components.Meter>
| Error Type | Status Code | Content Type |
|---|---|---|
| errors.HTTPValidationError | 422 | application/json |
| errors.SDKError | 4XX, 5XX | */* |
Get a meter by ID.
Scopes: meters:read meters:write
import { Polar } from "@polar-sh/sdk";
const polar = new Polar({
accessToken: process.env["POLAR_ACCESS_TOKEN"] ?? "",
});
async function run() {
const result = await polar.meters.get({
id: "<value>",
});
console.log(result);
}
run();The standalone function version of this method:
import { PolarCore } from "@polar-sh/sdk/core.js";
import { metersGet } from "@polar-sh/sdk/funcs/metersGet.js";
// Use `PolarCore` for best tree-shaking performance.
// You can create one instance of it to use across an application.
const polar = new PolarCore({
accessToken: process.env["POLAR_ACCESS_TOKEN"] ?? "",
});
async function run() {
const res = await metersGet(polar, {
id: "<value>",
});
if (res.ok) {
const { value: result } = res;
console.log(result);
} else {
console.log("metersGet failed:", res.error);
}
}
run();| Parameter | Type | Required | Description |
|---|---|---|---|
request |
operations.MetersGetRequest | ✔️ | The request object to use for the request. |
options |
RequestOptions | ➖ | Used to set various options for making HTTP requests. |
options.fetchOptions |
RequestInit | ➖ | Options that are passed to the underlying HTTP request. This can be used to inject extra headers for examples. All Request options, except method and body, are allowed. |
options.retries |
RetryConfig | ➖ | Enables retrying HTTP requests under certain failure conditions. |
Promise<components.Meter>
| Error Type | Status Code | Content Type |
|---|---|---|
| errors.ResourceNotFound | 404 | application/json |
| errors.HTTPValidationError | 422 | application/json |
| errors.SDKError | 4XX, 5XX | */* |
Update a meter.
Scopes: meters:write
import { Polar } from "@polar-sh/sdk";
const polar = new Polar({
accessToken: process.env["POLAR_ACCESS_TOKEN"] ?? "",
});
async function run() {
const result = await polar.meters.update({
id: "<value>",
meterUpdate: {},
});
console.log(result);
}
run();The standalone function version of this method:
import { PolarCore } from "@polar-sh/sdk/core.js";
import { metersUpdate } from "@polar-sh/sdk/funcs/metersUpdate.js";
// Use `PolarCore` for best tree-shaking performance.
// You can create one instance of it to use across an application.
const polar = new PolarCore({
accessToken: process.env["POLAR_ACCESS_TOKEN"] ?? "",
});
async function run() {
const res = await metersUpdate(polar, {
id: "<value>",
meterUpdate: {},
});
if (res.ok) {
const { value: result } = res;
console.log(result);
} else {
console.log("metersUpdate failed:", res.error);
}
}
run();| Parameter | Type | Required | Description |
|---|---|---|---|
request |
operations.MetersUpdateRequest | ✔️ | The request object to use for the request. |
options |
RequestOptions | ➖ | Used to set various options for making HTTP requests. |
options.fetchOptions |
RequestInit | ➖ | Options that are passed to the underlying HTTP request. This can be used to inject extra headers for examples. All Request options, except method and body, are allowed. |
options.retries |
RetryConfig | ➖ | Enables retrying HTTP requests under certain failure conditions. |
Promise<components.Meter>
| Error Type | Status Code | Content Type |
|---|---|---|
| errors.ResourceNotFound | 404 | application/json |
| errors.HTTPValidationError | 422 | application/json |
| errors.SDKError | 4XX, 5XX | */* |
Get quantities of a meter over a time period.
Scopes: meters:read meters:write
import { Polar } from "@polar-sh/sdk";
const polar = new Polar({
accessToken: process.env["POLAR_ACCESS_TOKEN"] ?? "",
});
async function run() {
const result = await polar.meters.quantities({
id: "<value>",
startTimestamp: new Date("2025-11-25T04:37:16.823Z"),
endTimestamp: new Date("2025-11-26T17:06:00.727Z"),
interval: "day",
});
console.log(result);
}
run();The standalone function version of this method:
import { PolarCore } from "@polar-sh/sdk/core.js";
import { metersQuantities } from "@polar-sh/sdk/funcs/metersQuantities.js";
// Use `PolarCore` for best tree-shaking performance.
// You can create one instance of it to use across an application.
const polar = new PolarCore({
accessToken: process.env["POLAR_ACCESS_TOKEN"] ?? "",
});
async function run() {
const res = await metersQuantities(polar, {
id: "<value>",
startTimestamp: new Date("2025-11-25T04:37:16.823Z"),
endTimestamp: new Date("2025-11-26T17:06:00.727Z"),
interval: "day",
});
if (res.ok) {
const { value: result } = res;
console.log(result);
} else {
console.log("metersQuantities failed:", res.error);
}
}
run();| Parameter | Type | Required | Description |
|---|---|---|---|
request |
operations.MetersQuantitiesRequest | ✔️ | The request object to use for the request. |
options |
RequestOptions | ➖ | Used to set various options for making HTTP requests. |
options.fetchOptions |
RequestInit | ➖ | Options that are passed to the underlying HTTP request. This can be used to inject extra headers for examples. All Request options, except method and body, are allowed. |
options.retries |
RetryConfig | ➖ | Enables retrying HTTP requests under certain failure conditions. |
Promise<components.MeterQuantities>
| Error Type | Status Code | Content Type |
|---|---|---|
| errors.ResourceNotFound | 404 | application/json |
| errors.HTTPValidationError | 422 | application/json |
| errors.SDKError | 4XX, 5XX | */* |