Developer-friendly & type-safe Typescript SDK specifically catered to leverage *flexprice-sdk-test* API.
npm install flexprice-sdk-testDeveloper-friendly & type-safe Typescript SDK specifically catered to leverage flexprice-sdk-test API.


> [!IMPORTANT]
> This SDK is not yet ready for production use. To complete setup please follow the steps outlined in your workspace. Delete this section before > publishing to a package manager.
FlexPrice API: FlexPrice API Service
> [!TIP]
> To finish publishing your SDK to npm and others you must run your first generation action.
The SDK can be installed with either npm, pnpm, bun or yarn package managers.
``bash`
npm add
`bash`
pnpm add
`bash`
bun add
`bash`
yarn add
For supported JavaScript runtimes, please consult RUNTIMES.md.
`typescript
import { FlexPrice } from "flexprice-sdk-test";
const flexPrice = new FlexPrice({
serverURL: "https://api.example.com",
apiKeyAuth: "
});
async function run() {
const result = await flexPrice.addons.getAddons({});
console.log(result);
}
run();
`
This SDK supports the following security scheme globally:
| Name | Type | Scheme |
| ------------ | ------ | ------- |
| apiKeyAuth | apiKey | API key |
To authenticate with the API the apiKeyAuth parameter must be set when initializing the SDK client instance. For example:`typescript
import { FlexPrice } from "flexprice-sdk-test";
const flexPrice = new FlexPrice({
serverURL: "https://api.example.com",
apiKeyAuth: "
});
async function run() {
const result = await flexPrice.addons.getAddons({});
console.log(result);
}
run();
`
Available methods
* getAddons - List addons
* postAddons - Create addon
* getAddonsLookupLookupKey - Get addon by lookup key
* postAddonsSearch - List addons by filter
* getAddonsId - Get addon
* putAddonsId - Update addon
* deleteAddonsId - Delete addon
* postAlertSearch - List alert logs by filter
* postAuthLogin - Login
* postAuthSignup - Sign up
* getConnections - Get connections
* postConnectionsSearch - List connections by filter
* getConnectionsId - Get a connection
* putConnectionsId - Update a connection
* deleteConnectionsId - Delete a connection
* postCosts - Create a new costsheet
* getCostsActive - Get active costsheet for tenant
* postCostsAnalytics - Get combined revenue and cost analytics
* postCostsAnalyticsV2 - Get combined revenue and cost analytics
* postCostsSearch - List costsheets by filter
* getCostsId - Get a costsheet by ID
* putCostsId - Update a costsheet
* deleteCostsId - Delete a costsheet
* getCoupons - List coupons with filtering
* postCoupons - Create a new coupon
* getCouponsId - Get a coupon by ID
* putCouponsId - Update a coupon
* deleteCouponsId - Delete a coupon
* getCreditnotes - List credit notes with filtering
* postCreditnotes - Create a new credit note
* getCreditnotesId - Get a credit note by ID
* postCreditnotesIdFinalize - Process a draft credit note
* postCreditnotesIdVoid - Void a credit note
* getCreditgrants - Get credit grants
* postCreditgrants - Create a new credit grant
* getCreditgrantsId - Get a credit grant by ID
* putCreditgrantsId - Update a credit grant
* deleteCreditgrantsId - Delete a credit grant
* getPlansIdCreditgrants - Get plan credit grants
* getPortalExternalId - Create a customer portal session
* getCustomers - Get customers
* putCustomers - Update a customer
* postCustomers - Create a customer
* getCustomersExternalExternalId - Get a customer by external id
* postCustomersSearch - List customers by filter
* getCustomersUsage - Get customer usage summary
* getCustomersId - Get a customer
* deleteCustomersId - Delete a customer
* getCustomersIdEntitlements - Get customer entitlements
* getCustomersIdGrantsUpcoming - Get upcoming credit grant applications
* getAddonsIdEntitlements - Get addon entitlements
* getEntitlements - Get entitlements
* postEntitlements - Create a new entitlement
* postEntitlementsBulk - Create multiple entitlements in bulk
* postEntitlementsSearch - List entitlements by filter
* getEntitlementsId - Get an entitlement by ID
* putEntitlementsId - Update an entitlement
* deleteEntitlementsId - Delete an entitlement
* getPlansIdEntitlements - Get plan entitlements
* getEntityIntegrationMappings - List entity integration mappings
* postEntityIntegrationMappings - Create entity integration mapping
* getEntityIntegrationMappingsId - Get entity integration mapping
* deleteEntityIntegrationMappingsId - Delete entity integration mapping
* getEnvironments - Get environments
* postEnvironments - Create an environment
* getEnvironmentsId - Get an environment
* putEnvironmentsId - Update an environment
* postEvents - Ingest event
* postEventsAnalytics - Get usage analytics
* postEventsBulk - Bulk Ingest events
* postEventsHuggingfaceInference - Get hugging face inference data
* getEventsMonitoring - Get monitoring data
* postEventsQuery - List raw events
* postEventsUsage - Get usage statistics
* postEventsUsageMeter - Get usage by meter
* getEventsId - Get event by ID
* getFeatures - List features
* postFeatures - Create a new feature
* postFeaturesSearch - List features by filter
* getFeaturesId - Get a feature by ID
* putFeaturesId - Update a feature
* deleteFeaturesId - Delete a feature
* postGroups - Create a group
* postGroupsSearch - Get groups
* getGroupsId - Get a group
* deleteGroupsId - Delete a group
* getSecretsIntegrationsByProviderProvider - Get integration details
* postSecretsIntegrationsCreateProvider - Create or update an integration
* getSecretsIntegrationsLinked - List linked integrations
* deleteSecretsIntegrationsId - Delete an integration
* getCustomersIdInvoicesSummary - Get a customer invoice summary
* getInvoices - List invoices
* postInvoices - Create a new one off invoice
* postInvoicesPreview - Get a preview invoice
* postInvoicesSearch - List invoices by filter
* getInvoicesId - Get an invoice by ID
* putInvoicesId - Update an invoice
* postInvoicesIdCommsTrigger - Trigger communication webhook for an invoice
* postInvoicesIdFinalize - Finalize an invoice
* putInvoicesIdPayment - Update invoice payment status
* postInvoicesIdPaymentAttempt - Attempt payment for an invoice
* getInvoicesIdPdf - Get PDF for an invoice
* postInvoicesIdRecalculate - Recalculate invoice totals and line items
* postInvoicesIdVoid - Void an invoice
* getPayments - List payments
* postPayments - Create a new payment
* getPaymentsId - Get a payment by ID
* putPaymentsId - Update a payment
* deletePaymentsId - Delete a payment
* postPaymentsIdProcess - Process a payment
* getPlans - Get plans
* postPlans - Create a new plan
* postPlansSearch - List plans by filter
* getPlansId - Get a plan
* putPlansId - Update a plan
* deletePlansId - Delete a plan
* postPlansIdSyncSubscriptions - Synchronize plan prices
* getPricesUnits - List price units
* postPricesUnits - Create a new price unit
* getPricesUnitsCodeCode - Get a price unit by code
* postPricesUnitsSearch - List price units by filter
* getPricesUnitsId - Get a price unit by ID
* putPricesUnitsId - Update a price unit
* deletePricesUnitsId - Delete a price unit
* getPrices - Get prices
* postPrices - Create a new price
* postPricesBulk - Create multiple prices in bulk
* getPricesLookupLookupKey - Get price by lookup key
* getPricesId - Get a price by ID
* putPricesId - Update a price
* deletePricesId - Delete a price
* getRbacRoles - List all RBAC roles
* getRbacRolesId - Get a specific RBAC role
* getTasksScheduled - List scheduled tasks
* postTasksScheduled - Create a scheduled task
* postTasksScheduledScheduleUpdateBillingPeriod - Schedule update billing period
* getTasksScheduledId - Get a scheduled task
* putTasksScheduledId - Update a scheduled task
* deleteTasksScheduledId - Delete a scheduled task
* postTasksScheduledIdRun - Trigger force run
* getSecretsApiKeys - List API keys
* postSecretsApiKeys - Create a new API key
* deleteSecretsApiKeysId - Delete an API key
* getSubscriptions - List subscriptions
* postSubscriptions - Create subscription
* postSubscriptionsAddon - Add addon to subscription
* deleteSubscriptionsAddon - Remove addon from subscription
* putSubscriptionsLineitemsId - Update subscription line item
* deleteSubscriptionsLineitemsId - Delete subscription line item
* postSubscriptionsSearch - List subscriptions by filter
* postSubscriptionsUsage - Get usage by subscription
* getSubscriptionsId - Get subscription
* postSubscriptionsIdActivate - Activate draft subscription
* getSubscriptionsIdAddonsAssociations - Get active addon associations
* postSubscriptionsIdCancel - Cancel subscription
* postSubscriptionsIdChangeExecute - Execute subscription plan change
* postSubscriptionsIdChangePreview - Preview subscription plan change
* getSubscriptionsIdEntitlements - Get subscription entitlements
* getSubscriptionsIdGrantsUpcoming - Get upcoming credit grant applications
* postSubscriptionsIdPause - Pause a subscription
* getSubscriptionsIdPauses - List all pauses for a subscription
* postSubscriptionsIdResume - Resume a paused subscription
* getSubscriptionsIdV2 - Get subscription V2
* getV1SubscriptionSchedules - List all subscription schedules
* getV1SubscriptionSchedulesId - Get subscription schedule
* postV1SubscriptionsSchedulesScheduleIdCancel - Cancel subscription schedule
* getV1SubscriptionsSubscriptionIdSchedules - List subscription schedules
* getTasks - List tasks
* postTasks - Create a new task
* getTasksResult - Get task processing result
* getTasksId - Get a task
* getTasksIdDownload - Download task export file
* putTasksIdStatus - Update task status
* getTaxesAssociations - List tax associations
* postTaxesAssociations - Create Tax Association
* getTaxesAssociationsId - Get Tax Association
* putTaxesAssociationsId - Update tax association
* deleteTaxesAssociationsId - Delete tax association
* getTaxesRates - Get tax rates
* postTaxesRates - Create a tax rate
* getTaxesRatesId - Get a tax rate
* putTaxesRatesId - Update a tax rate
* deleteTaxesRatesId - Delete a tax rate
* getTenantBilling - Get billing usage for the current tenant
* postTenants - Create a new tenant
* putTenantsUpdate - Update a tenant
* getTenantsId - Get tenant by ID
* postUsers - Create service account
* getUsersMe - Get user info
* postUsersSearch - List users with filters
* getCustomersWallets - Get Customer Wallets
* getCustomersIdWallets - Get wallets by customer ID
* getWallets - List wallets
* postWallets - Create a new wallet
* postWalletsSearch - List wallets by filter
* postWalletsTransactionsSearch - List wallet transactions by filter
* getWalletsId - Get wallet by ID
* putWalletsId - Update a wallet
* getWalletsIdBalanceRealTime - Get wallet balance
* postWalletsIdTerminate - Terminate a wallet
* postWalletsIdTopUp - Top up wallet
* getWalletsIdTransactions - Get wallet transactions
* postWebhooksChargebeeTenantIdEnvironmentId - Handle Chargebee webhook events
* postWebhooksHubspotTenantIdEnvironmentId - Handle HubSpot webhook events
* postWebhooksMoyasarTenantIdEnvironmentId - Handle Moyasar webhook events
* postWebhooksNomodTenantIdEnvironmentId - Handle Nomod webhook events
* postWebhooksQuickbooksTenantIdEnvironmentId - Handle QuickBooks webhook events
* postWebhooksRazorpayTenantIdEnvironmentId - Handle Razorpay webhook events
* postWebhooksStripeTenantIdEnvironmentId - Handle Stripe webhook events
All the methods listed above are available as standalone functions. These
functions are ideal for use in applications running in the browser, serverless
runtimes or other environments where application bundle size is a primary
concern. When using a bundler to build your application, all unused
functionality will be either excluded from the final bundle or tree-shaken away.
To read more about standalone functions, check FUNCTIONS.md.
- addonsDeleteAddonsId - Delete addon
- addonsGetAddons - List addons
- addonsGetAddonsId - Get addon
- addonsGetAddonsLookupLookupKey - Get addon by lookup key
- addonsPostAddons - Create addon
- addonsPostAddonsSearch - List addons by filter
- addonsPutAddonsId - Update addon
- alertLogsPostAlertSearch - List alert logs by filter
- authPostAuthLogin - Login
- authPostAuthSignup - Sign up
- connectionsDeleteConnectionsId - Delete a connection
- connectionsGetConnections - Get connections
- connectionsGetConnectionsId - Get a connection
- connectionsPostConnectionsSearch - List connections by filter
- connectionsPutConnectionsId - Update a connection
- costsDeleteCostsId - Delete a costsheet
- costsGetCostsActive - Get active costsheet for tenant
- costsGetCostsId - Get a costsheet by ID
- costsPostCosts - Create a new costsheet
- costsPostCostsAnalytics - Get combined revenue and cost analytics
- costsPostCostsAnalyticsV2 - Get combined revenue and cost analytics
- costsPostCostsSearch - List costsheets by filter
- costsPutCostsId - Update a costsheet
- couponsDeleteCouponsId - Delete a coupon
- couponsGetCoupons - List coupons with filtering
- couponsGetCouponsId - Get a coupon by ID
- couponsPostCoupons - Create a new coupon
- couponsPutCouponsId - Update a coupon
- creditGrantsDeleteCreditgrantsId - Delete a credit grant
- creditGrantsGetCreditgrants - Get credit grants
- creditGrantsGetCreditgrantsId - Get a credit grant by ID
- creditGrantsGetPlansIdCreditgrants - Get plan credit grants
- creditGrantsPostCreditgrants - Create a new credit grant
- creditGrantsPutCreditgrantsId - Update a credit grant
- creditNotesGetCreditnotes - List credit notes with filtering
- creditNotesGetCreditnotesId - Get a credit note by ID
- creditNotesPostCreditnotes - Create a new credit note
- creditNotesPostCreditnotesIdFinalize - Process a draft credit note
- creditNotesPostCreditnotesIdVoid - Void a credit note
- customerPortalGetPortalExternalId - Create a customer portal session
- customersDeleteCustomersId - Delete a customer
- customersGetCustomers - Get customers
- customersGetCustomersExternalExternalId - Get a customer by external id
- customersGetCustomersId - Get a customer
- customersGetCustomersIdEntitlements - Get customer entitlements
- customersGetCustomersIdGrantsUpcoming - Get upcoming credit grant applications
- customersGetCustomersUsage - Get customer usage summary
- customersPostCustomers - Create a customer
- customersPostCustomersSearch - List customers by filter
- customersPutCustomers - Update a customer
- entitlementsDeleteEntitlementsId - Delete an entitlement
- entitlementsGetAddonsIdEntitlements - Get addon entitlements
- entitlementsGetEntitlements - Get entitlements
- entitlementsGetEntitlementsId - Get an entitlement by ID
- entitlementsGetPlansIdEntitlements - Get plan entitlements
- entitlementsPostEntitlements - Create a new entitlement
- entitlementsPostEntitlementsBulk - Create multiple entitlements in bulk
- entitlementsPostEntitlementsSearch - List entitlements by filter
- entitlementsPutEntitlementsId - Update an entitlement
- entityIntegrationMappingsDeleteEntityIntegrationMappingsId - Delete entity integration mapping
- entityIntegrationMappingsGetEntityIntegrationMappings - List entity integration mappings
- entityIntegrationMappingsGetEntityIntegrationMappingsId - Get entity integration mapping
- entityIntegrationMappingsPostEntityIntegrationMappings - Create entity integration mapping
- environmentsGetEnvironments - Get environments
- environmentsGetEnvironmentsId - Get an environment
- environmentsPostEnvironments - Create an environment
- environmentsPutEnvironmentsId - Update an environment
- eventsGetEventsId - Get event by ID
- eventsGetEventsMonitoring - Get monitoring data
- eventsPostEvents - Ingest event
- eventsPostEventsAnalytics - Get usage analytics
- eventsPostEventsBulk - Bulk Ingest events
- eventsPostEventsHuggingfaceInference - Get hugging face inference data
- eventsPostEventsQuery - List raw events
- eventsPostEventsUsage - Get usage statistics
- eventsPostEventsUsageMeter - Get usage by meter
- featuresDeleteFeaturesId - Delete a feature
- featuresGetFeatures - List features
- featuresGetFeaturesId - Get a feature by ID
- featuresPostFeatures - Create a new feature
- featuresPostFeaturesSearch - List features by filter
- featuresPutFeaturesId - Update a feature
- groupsDeleteGroupsId - Delete a group
- groupsGetGroupsId - Get a group
- groupsPostGroups - Create a group
- groupsPostGroupsSearch - Get groups
- integrationsDeleteSecretsIntegrationsId - Delete an integration
- integrationsGetSecretsIntegrationsByProviderProvider - Get integration details
- integrationsGetSecretsIntegrationsLinked - List linked integrations
- integrationsPostSecretsIntegrationsCreateProvider - Create or update an integration
- invoicesGetCustomersIdInvoicesSummary - Get a customer invoice summary
- invoicesGetInvoices - List invoices
- invoicesGetInvoicesId - Get an invoice by ID
- invoicesGetInvoicesIdPdf - Get PDF for an invoice
- invoicesPostInvoices - Create a new one off invoice
- invoicesPostInvoicesIdCommsTrigger - Trigger communication webhook for an invoice
- invoicesPostInvoicesIdFinalize - Finalize an invoice
- invoicesPostInvoicesIdPaymentAttempt - Attempt payment for an invoice
- invoicesPostInvoicesIdRecalculate - Recalculate invoice totals and line items
- invoicesPostInvoicesIdVoid - Void an invoice
- invoicesPostInvoicesPreview - Get a preview invoice
- invoicesPostInvoicesSearch - List invoices by filter
- invoicesPutInvoicesId - Update an invoice
- invoicesPutInvoicesIdPayment - Update invoice payment status
- paymentsDeletePaymentsId - Delete a payment
- paymentsGetPayments - List payments
- paymentsGetPaymentsId - Get a payment by ID
- paymentsPostPayments - Create a new payment
- paymentsPostPaymentsIdProcess - Process a payment
- paymentsPutPaymentsId - Update a payment
- plansDeletePlansId - Delete a plan
- plansGetPlans - Get plans
- plansGetPlansId - Get a plan
- plansPostPlans - Create a new plan
- plansPostPlansIdSyncSubscriptions - Synchronize plan prices
- plansPostPlansSearch - List plans by filter
- plansPutPlansId - Update a plan
- pricesDeletePricesId - Delete a price
- pricesGetPrices - Get prices
- pricesGetPricesId - Get a price by ID
- pricesGetPricesLookupLookupKey - Get price by lookup key
- pricesPostPrices - Create a new price
- pricesPostPricesBulk - Create multiple prices in bulk
- pricesPutPricesId - Update a price
- priceUnitsDeletePricesUnitsId - Delete a price unit
- priceUnitsGetPricesUnits - List price units
- priceUnitsGetPricesUnitsCodeCode - Get a price unit by code
- priceUnitsGetPricesUnitsId - Get a price unit by ID
- priceUnitsPostPricesUnits - Create a new price unit
- priceUnitsPostPricesUnitsSearch - List price units by filter
- priceUnitsPutPricesUnitsId - Update a price unit
- rbacGetRBACRoles - List all RBAC roles
- rbacGetRBACRolesId - Get a specific RBAC role
- scheduledTasksDeleteTasksScheduledId - Delete a scheduled task
- scheduledTasksGetTasksScheduled - List scheduled tasks
- scheduledTasksGetTasksScheduledId - Get a scheduled task
- scheduledTasksPostTasksScheduled - Create a scheduled task
- scheduledTasksPostTasksScheduledIdRun - Trigger force run
- scheduledTasksPostTasksScheduledScheduleUpdateBillingPeriod - Schedule update billing period
- scheduledTasksPutTasksScheduledId - Update a scheduled task
- secretsDeleteSecretsApiKeysId - Delete an API key
- secretsGetSecretsApiKeys - List API keys
- secretsPostSecretsApiKeys - Create a new API key
- subscriptionsDeleteSubscriptionsAddon - Remove addon from subscription
- subscriptionsDeleteSubscriptionsLineitemsId - Delete subscription line item
- subscriptionsGetSubscriptions - List subscriptions
- subscriptionsGetSubscriptionsId - Get subscription
- subscriptionsGetSubscriptionsIdAddonsAssociations - Get active addon associations
- subscriptionsGetSubscriptionsIdEntitlements - Get subscription entitlements
- subscriptionsGetSubscriptionsIdGrantsUpcoming - Get upcoming credit grant applications
- subscriptionsGetSubscriptionsIdPauses - List all pauses for a subscription
- subscriptionsGetSubscriptionsIdV2 - Get subscription V2
- subscriptionsGetV1SubscriptionSchedules - List all subscription schedules
- subscriptionsGetV1SubscriptionSchedulesId - Get subscription schedule
- subscriptionsGetV1SubscriptionsSubscriptionIdSchedules - List subscription schedules
- subscriptionsPostSubscriptions - Create subscription
- subscriptionsPostSubscriptionsAddon - Add addon to subscription
- subscriptionsPostSubscriptionsIdActivate - Activate draft subscription
- subscriptionsPostSubscriptionsIdCancel - Cancel subscription
- subscriptionsPostSubscriptionsIdChangeExecute - Execute subscription plan change
- subscriptionsPostSubscriptionsIdChangePreview - Preview subscription plan change
- subscriptionsPostSubscriptionsIdPause - Pause a subscription
- subscriptionsPostSubscriptionsIdResume - Resume a paused subscription
- subscriptionsPostSubscriptionsSearch - List subscriptions by filter
- subscriptionsPostSubscriptionsUsage - Get usage by subscription
- subscriptionsPostV1SubscriptionsSchedulesScheduleIdCancel - Cancel subscription schedule
- subscriptionsPutSubscriptionsLineitemsId - Update subscription line item
- tasksGetTasks - List tasks
- tasksGetTasksId - Get a task
- tasksGetTasksIdDownload - Download task export file
- tasksGetTasksResult - Get task processing result
- tasksPostTasks - Create a new task
- tasksPutTasksIdStatus - Update task status
- taxAssociationsDeleteTaxesAssociationsId - Delete tax association
- taxAssociationsGetTaxesAssociations - List tax associations
- taxAssociationsGetTaxesAssociationsId - Get Tax Association
- taxAssociationsPostTaxesAssociations - Create Tax Association
- taxAssociationsPutTaxesAssociationsId - Update tax association
- taxRatesDeleteTaxesRatesId - Delete a tax rate
- taxRatesGetTaxesRates - Get tax rates
- taxRatesGetTaxesRatesId - Get a tax rate
- taxRatesPostTaxesRates - Create a tax rate
- taxRatesPutTaxesRatesId - Update a tax rate
- tenantsGetTenantBilling - Get billing usage for the current tenant
- tenantsGetTenantsId - Get tenant by ID
- tenantsPostTenants - Create a new tenant
- tenantsPutTenantsUpdate - Update a tenant
- usersGetUsersMe - Get user info
- usersPostUsers - Create service account
- usersPostUsersSearch - List users with filters
- walletsGetCustomersIdWallets - Get wallets by customer ID
- walletsGetCustomersWallets - Get Customer Wallets
- walletsGetWallets - List wallets
- walletsGetWalletsId - Get wallet by ID
- walletsGetWalletsIdBalanceRealTime - Get wallet balance
- walletsGetWalletsIdTransactions - Get wallet transactions
- walletsPostWallets - Create a new wallet
- walletsPostWalletsIdTerminate - Terminate a wallet
- walletsPostWalletsIdTopUp - Top up wallet
- walletsPostWalletsSearch - List wallets by filter
- walletsPostWalletsTransactionsSearch - List wallet transactions by filter
- walletsPutWalletsId - Update a wallet
- webhooksPostWebhooksChargebeeTenantIdEnvironmentId - Handle Chargebee webhook events
- webhooksPostWebhooksHubspotTenantIdEnvironmentId - Handle HubSpot webhook events
- webhooksPostWebhooksMoyasarTenantIdEnvironmentId - Handle Moyasar webhook events
- webhooksPostWebhooksNomodTenantIdEnvironmentId - Handle Nomod webhook events
- webhooksPostWebhooksQuickbooksTenantIdEnvironmentId - Handle QuickBooks webhook events
- webhooksPostWebhooksRazorpayTenantIdEnvironmentId - Handle Razorpay webhook events
- webhooksPostWebhooksStripeTenantIdEnvironmentId - Handle Stripe webhook events
Certain SDK methods accept files as part of a multi-part request. It is possible and typically recommended to upload files as a stream rather than reading the entire contents into memory. This avoids excessive memory consumption and potentially crashing with out-of-memory errors when working with very large files. The following example demonstrates how to attach a file stream to a request.
> [!TIP]
>
> Depending on your JavaScript runtime, there are convenient utilities that return a handle to a file without reading the entire contents into memory:
>
> - Node.js v20+: Since v20, Node.js comes with a native openAsBlob function in node:fs.Bun.file
> - Bun: The native function produces a file handle that can be used for streaming file uploads.File
> - Browsers: All supported browsers return an instance to a when reading the value from an element.fileFrom
> - Node.js v18: A file stream can be created using the helper from fetch-blob/from.js.
`typescript
import { FlexPrice } from "flexprice-sdk-test";
import { openAsBlob } from "node:fs";
const flexPrice = new FlexPrice({
serverURL: "https://api.example.com",
apiKeyAuth: "
});
async function run() {
const result = await flexPrice.events.postEventsAnalytics(
await openAsBlob("example.file"),
);
console.log(result);
}
run();
`
Some of the endpoints in this SDK support retries. If you use the SDK without any configuration, it will fall back to the default retry strategy provided by the API. However, the default retry strategy can be overridden on a per-operation basis, or across the entire SDK.
To change the default retry strategy for a single API call, simply provide a retryConfig object to the call:
`typescript
import { FlexPrice } from "flexprice-sdk-test";
const flexPrice = new FlexPrice({
serverURL: "https://api.example.com",
apiKeyAuth: "
});
async function run() {
const result = await flexPrice.addons.getAddons({}, {
retries: {
strategy: "backoff",
backoff: {
initialInterval: 1,
maxInterval: 50,
exponent: 1.1,
maxElapsedTime: 100,
},
retryConnectionErrors: false,
},
});
console.log(result);
}
run();
`
If you'd like to override the default retry strategy for all operations that support retries, you can provide a retryConfig at SDK initialization:
`typescript
import { FlexPrice } from "flexprice-sdk-test";
const flexPrice = new FlexPrice({
serverURL: "https://api.example.com",
retryConfig: {
strategy: "backoff",
backoff: {
initialInterval: 1,
maxInterval: 50,
exponent: 1.1,
maxElapsedTime: 100,
},
retryConnectionErrors: false,
},
apiKeyAuth: "
});
async function run() {
const result = await flexPrice.addons.getAddons({});
console.log(result);
}
run();
`
FlexPriceError is the base class for all HTTP error responses. It has the following properties:
| Property | Type | Description |
| ------------------- | ---------- | --------------------------------------------------------------------------------------- |
| error.message | string | Error message |error.statusCode
| | number | HTTP response status code eg 404 |error.headers
| | Headers | HTTP response headers |error.body
| | string | HTTP body. Can be empty string if no body is returned. |error.rawResponse
| | Response | Raw HTTP response |error.data$
| | | Optional. Some errors may contain structured data. See Error Classes. |
typescript
import { FlexPrice } from "flexprice-sdk-test";
import * as errors from "flexprice-sdk-test/models/errors";const flexPrice = new FlexPrice({
serverURL: "https://api.example.com",
apiKeyAuth: "",
});
async function run() {
try {
const result = await flexPrice.addons.getAddons({});
console.log(result);
} catch (error) {
// The base class for HTTP error responses
if (error instanceof errors.FlexPriceError) {
console.log(error.message);
console.log(error.statusCode);
console.log(error.body);
console.log(error.headers);
// Depending on the method different errors may be thrown
if (error instanceof errors.ErrorsErrorResponse) {
console.log(error.data$.error); // components.ErrorsErrorDetail
console.log(error.data$.success); // boolean
}
}
}
}
run();
`$3
Primary errors:
* FlexPriceError: The base class for HTTP error responses.
ErrorsErrorResponse: Less common errors (6)
ConnectionError: HTTP client was unable to make a request to a server.
* RequestTimeoutError: HTTP request timed out due to an AbortSignal signal.
* RequestAbortedError: HTTP request was aborted by the client.
* InvalidRequestError: Any input used to create a request is invalid.
* UnexpectedClientError: Unrecognised or unexpected error.FlexPriceError:
* ResponseValidationError: Type mismatch between the data returned from the server and the structure expected by the SDK. See error.rawValue for the raw value and error.pretty() for a nicely formatted multi-line string.\* Check the method documentation to see if the error is applicable.
Custom HTTP Client
The TypeScript SDK makes API calls using an
HTTPClient that wraps the native
Fetch API. This
client is a thin wrapper around fetch and provides the ability to attach hooks
around the request lifecycle that can be used to modify the request or handle
errors and response.The
HTTPClient constructor takes an optional fetcher argument that can be
used to integrate a third-party HTTP client or when writing tests to mock out
the HTTP client and feed in fixtures.The following example shows how to use the
"beforeRequest" hook to to add a
custom header and a timeout to requests and how to use the "requestError" hook
to log errors:`typescript
import { FlexPrice } from "flexprice-sdk-test";
import { HTTPClient } from "flexprice-sdk-test/lib/http";const httpClient = new HTTPClient({
// fetcher takes a function that has the same signature as native
fetch.
fetcher: (request) => {
return fetch(request);
}
});httpClient.addHook("beforeRequest", (request) => {
const nextRequest = new Request(request, {
signal: request.signal || AbortSignal.timeout(5000)
});
nextRequest.headers.set("x-custom-header", "custom value");
return nextRequest;
});
httpClient.addHook("requestError", (error, request) => {
console.group("Request Error");
console.log("Reason:",
${error});
console.log("Endpoint:", ${request.method} ${request.url});
console.groupEnd();
});const sdk = new FlexPrice({ httpClient: httpClient });
`
Debugging
You can setup your SDK to emit debug logs for SDK requests and responses.
You can pass a logger that matches
console's interface as an SDK option.> [!WARNING]
> Beware that debug logging will reveal secrets, like API tokens in headers, in log messages printed to a console or files. It's recommended to use this feature only during local development and not in production.
`typescript
import { FlexPrice } from "flexprice-sdk-test";const sdk = new FlexPrice({ debugLogger: console });
``This SDK is in beta, and there may be breaking changes between versions without a major version update. Therefore, we recommend pinning usage
to a specific package version. This way, you can install the same version each time without breaking changes unless you are intentionally
looking for the latest version.
While we value open-source contributions to this SDK, this library is generated programmatically. Any manual changes added to internal files will be overwritten on the next generation.
We look forward to hearing your feedback. Feel free to open a PR or an issue with a proof of concept and we'll do our best to include it in a future release.