---
title: "History API client"
url: "https://platformdocs.coinme.com/#/docs/caas-history-api-client"
markdown: "https://platformdocs.coinme.com/docs/caas-history-api-client.md"
summary: "The `@coinme/history-api-client` package provides a client for interacting with the Coinme History APIs."
surface: "caas"
platform: "server"
package: "@coinme/history-api-client"
updated: "2026-11-04"
---

# History API client

The `@coinme/history-api-client` package provides a client for interacting with the Coinme History APIs.

> **Server only.**
>
> `AuthService` takes your partner client secret and mints a partner access token. Use it, and these clients, only on your backend (Node.js). Never bundle them into a browser, WebView or mobile (React Native) app, where anyone can extract the secret and the token: `AuthService` throws if it runs there. For anything that runs on a customer's device, mint a [Transient Auth Token](https://platformdocs.coinme.com/docs/transient-auth-token.md) on your backend instead.

> **This is version 2.0.0, and 1.x is deprecated.**
>
> This page documents version 2.0.0 of the CaaS API clients, which is not published yet; until it is, the registry serves 1.x, which is configured differently. Install with `@^2.0.0`. [CaaS API clients](https://platformdocs.coinme.com/docs/caas-api-clients.md) covers installing, authenticating, environments and [upgrading from 1.x](https://platformdocs.coinme.com/docs/caas-api-clients.md#upgrading-from-1-x).

## Install

```bash
npm install @coinme/history-api-client@^2.0.0 @coinme/core-api-client@^2.0.0
```

The packages come from Coinme's private registry; [Install in the overview](https://platformdocs.coinme.com/docs/caas-api-clients.md#install) shows the `.npmrc` entries. Every client needs a token from `AuthService` in `@coinme/core-api-client`.

## Create the client

The API client for interacting with the Coinme History APIs.

```typescript
import { APIClient } from '@coinme/history-api-client';

const historyClient = new APIClient({
  baseUrl: 'https://caas-staging.coinme.com/services',
  partnerId: process.env.COINME_PARTNER_ID!,
  token: await authService.getToken(),
});
```

| Property | Type | Required | Description |
| --- | --- | --- | --- |
| `baseUrl` | `string` | Yes | Base URL of the CaaS API for the environment to call, including the `/services` path, for example `https://caas-staging.coinme.com/services` for staging. Use the URLs Coinme provides for each environment. |
| `partnerId` | `string` | Yes | The unique identifier Coinme assigns to each partner. |
| `token` | `string` | Yes | The bearer token from `AuthService.getToken()`. |

A client keeps the token it was given; pass a new one to `updateToken` when it expires, or create the client per request. [Environments in the overview](https://platformdocs.coinme.com/docs/caas-api-clients.md#environments) lists the base URLs.

## Methods

### getAssetBalances

Get asset balances for a given customer.

```typescript
getAssetBalances(queryParams: GetAssetBalancesQuery): Promise<GetAssetBalancesResponse>
```

| Parameter | Type | Description |
| --- | --- | --- |
| `queryParams` | `GetAssetBalancesQuery` | The parameters required to fetch the asset balances. |

A promise that resolves to a `GetAssetBalancesResponse`. See [GetAssetBalancesResponse](#getassetbalancesresponse), [GetAssetBalancesQuery](#getassetbalancesquery).

```typescript
const response = await historyClient.getAssetBalances({
  customerId: 'customer-id',
  estimatedBalanceCurrencyCode: 'USD',
});
```

### getTransaction

Get transaction details based on the `partnerTransactionId`.

```typescript
getTransaction(partnerTransactionId: string): Promise<GetTransactionResponse>
```

| Parameter | Type | Description |
| --- | --- | --- |
| `partnerTransactionId` | `string` | Unique identifier required for fetching the specific transaction. |

A promise that resolves to the `GetTransactionResponse`, whose `transaction` holds the details. See [GetTransactionResponse](#gettransactionresponse).

```typescript
const response = await historyClient.getTransaction('partner-transaction-id');
```

### getTransactionHistory

Fetches the transaction history for a given customer.

```typescript
getTransactionHistory(queryParams: GetTransactionHistoryQuery): Promise<GetTransactionHistoryResponse>
```

| Parameter | Type | Description |
| --- | --- | --- |
| `queryParams` | `GetTransactionHistoryQuery` | The parameters required to fetch the transaction history. |

A promise that resolves to a `GetTransactionHistoryResponse`. See [GetTransactionHistoryResponse](#gettransactionhistoryresponse), [GetTransactionHistoryQuery](#gettransactionhistoryquery).

```typescript
const response = await historyClient.getTransactionHistory({
  customerId: 'customer-id',
});
```

### updateToken

Allows updating the token dynamically (e.g., after refresh), without creating a new instance of the client.

```typescript
updateToken(newToken: string): void
```

| Parameter | Type | Description |
| --- | --- | --- |
| `newToken` | `string` | The new token to use. |

Returns `void`.

```typescript
historyClient.updateToken('new-token');
```

## Types

The request, query and response types of the methods above, as the package exports them. Ids are strings and amounts are decimal strings, as the API sends and expects them; response fields are optional and may be null, because the API leaves out or nulls values it has no data for.

### GetAssetBalancesQuery

Query for `GET /services/cryptoassetbalance`: Get Crypto Asset Balance.

| Property | Type | Required | Description |
| --- | --- | --- | --- |
| `customerId` | `string` | Yes | Unique customer identifier |
| `estimatedBalanceCurrencyCode` | `string` | Yes | Currency code of the balance (i.e. USD) |

### GetAssetBalancesResponse

Response for `GET /services/cryptoassetbalance`: Get Crypto Asset Balance.

| Property | Type | Required | Description |
| --- | --- | --- | --- |
| `cryptoAssetsBalance` | `object[] \| null` | No |  |
| `cryptoAssetsBalance[].balance` | `string \| null` | No |  |
| `cryptoAssetsBalance[].currencyName` | `string \| null` | No |  |
| `cryptoAssetsBalance[].currencySymbol` | `string \| null` | No |  |
| `cryptoAssetsBalance[].estimatedBalanceValue` | `string \| null` | No |  |
| `cryptoAssetsBalance[].updatedAt` | `string \| null` | No |  |

### GetTransactionHistoryQuery

Query for `GET /services/transactionhistory`: Get Transaction History.

| Property | Type | Required | Description |
| --- | --- | --- | --- |
| `currencyCode` | `string` | No | Currency code of the cryptocurrency (i.e. DOGE) |
| `customerId` | `string` | Yes | Unique customer identifier |
| `endDateTime` | `string` | No | UTC (i.e. 2022-01-24T16:44:49Z) |
| `page` | `number` | No | Number of pages |
| `size` | `number` | No | Page size (max value is 500) |
| `startDateTime` | `string` | No | UTC (i.e. 2022-01-24T16:44:49Z) |

### GetTransactionHistoryResponse

Response for `GET /services/transactionhistory`: Get Transaction History.

| Property | Type | Required | Description |
| --- | --- | --- | --- |
| `transactions` | `object[] \| null` | No |  |
| `transactions[].bankPaymentRail` | `'ACH_STANDARD' \| 'ACH_SAMEDAY' \| 'RTP' \| 'DOMESTIC_FED_WIRE' \| null` | No |  |
| `transactions[].bankTransferBeneficiaryId` | `string \| null` | No |  |
| `transactions[].blockchainTransactionId` | `string \| null` | No |  |
| `transactions[].creditAssetId` | `string \| null` | No |  |
| `transactions[].creditCurrencyAmount` | `string \| null` | No |  |
| `transactions[].creditCurrencyChain` | `string \| null` | No |  |
| `transactions[].creditCurrencyCode` | `string \| null` | No |  |
| `transactions[].cryptoSettlementType` | `string \| null` | No |  |
| `transactions[].debitAssetId` | `string \| null` | No |  |
| `transactions[].debitCurrencyAmount` | `string \| null` | No |  |
| `transactions[].debitCurrencyChain` | `string \| null` | No |  |
| `transactions[].debitCurrencyCode` | `string \| null` | No |  |
| `transactions[].errorCode` | `string \| null` | No |  |
| `transactions[].externalSessionId` | `string \| null` | No |  |
| `transactions[].feeCurrencyCode` | `string \| null` | No |  |
| `transactions[].feesMap` | `Record<string, string> \| null` | No |  |
| `transactions[].fiatFees` | `object \| null` | No |  |
| `transactions[].fiatFees.feeAssetId` | `string \| null` | No |  |
| `transactions[].fiatFees.feesMap` | `Record<string, string> \| null` | No |  |
| `transactions[].fiatFees.total` | `string \| null` | No |  |
| `transactions[].imageUrl` | `string \| null` | No |  |
| `transactions[].location` | `object \| null` | No |  |
| `transactions[].location.address1` | `string \| null` | No |  |
| `transactions[].location.address2` | `string \| null` | No |  |
| `transactions[].location.city` | `string \| null` | No |  |
| `transactions[].location.coordinates` | `object \| null` | No |  |
| `transactions[].location.coordinates.latitude` | `number \| null` | No |  |
| `transactions[].location.coordinates.longitude` | `number \| null` | No |  |
| `transactions[].location.country` | `string \| null` | No |  |
| `transactions[].location.description` | `string \| null` | No |  |
| `transactions[].location.locationReference` | `string \| null` | No |  |
| `transactions[].location.state` | `string \| null` | No |  |
| `transactions[].location.zipCode` | `string \| null` | No |  |
| `transactions[].orderType` | `string \| null` | No |  |
| `transactions[].originatorNumOwner` | `'COINME' \| 'PARTNER' \| 'USER' \| null` | No |  |
| `transactions[].partnerTransactionId` | `string \| null` | No |  |
| `transactions[].paymentMethodId` | `string \| null` | No |  |
| `transactions[].promoCode` | `string \| null` | No |  |
| `transactions[].providerId` | `string \| null` | No |  |
| `transactions[].providerTransactionId` | `string \| null` | No |  |
| `transactions[].providerTransactionRef` | `string \| null` | No |  |
| `transactions[].spreadAmount` | `string \| null` | No |  |
| `transactions[].spreadCurrencyCode` | `string \| null` | No |  |
| `transactions[].tags` | `string[] \| null` | No |  |
| `transactions[].totalFees` | `string \| null` | No |  |
| `transactions[].trackingInfo` | `object \| null` | No |  |
| `transactions[].trackingInfo.orderUpdateDateTime` | `string \| null` | No |  |
| `transactions[].trackingInfo.trackingComplete` | `boolean \| null` | No |  |
| `transactions[].trackingInfo.trackingState` | `string \| null` | No |  |
| `transactions[].trackingInfo.trackingStateDescription` | `string \| null` | No |  |
| `transactions[].trackingInfo.trackingType` | `string \| null` | No |  |
| `transactions[].transactionDateTime` | `string \| null` | No |  |
| `transactions[].transactionStatus` | `'PENDING' \| 'BLOCKCHAIN_ACCEPTED' \| 'CONFIRMED' \| 'FAILED' \| null` | No |  |

### GetTransactionPathParams

PathParams for `GET /services/transactions/{partnerTransactionID}`: Get Specific Transaction.

| Property | Type | Required | Description |
| --- | --- | --- | --- |
| `partnerTransactionID` | `string` | Yes |  |

### GetTransactionResponse

Response for `GET /services/transactions/{partnerTransactionID}`: Get Specific Transaction.

| Property | Type | Required | Description |
| --- | --- | --- | --- |
| `transaction` | `object \| null` | No |  |
| `transaction.bankPaymentRail` | `'ACH_STANDARD' \| 'ACH_SAMEDAY' \| 'RTP' \| 'DOMESTIC_FED_WIRE' \| null` | No |  |
| `transaction.bankTransferBeneficiaryId` | `string \| null` | No |  |
| `transaction.blockchainTransactionId` | `string \| null` | No |  |
| `transaction.creditAssetId` | `string \| null` | No |  |
| `transaction.creditCurrencyAmount` | `string \| null` | No |  |
| `transaction.creditCurrencyChain` | `string \| null` | No |  |
| `transaction.creditCurrencyCode` | `string \| null` | No |  |
| `transaction.cryptoSettlementType` | `string \| null` | No |  |
| `transaction.debitAssetId` | `string \| null` | No |  |
| `transaction.debitCurrencyAmount` | `string \| null` | No |  |
| `transaction.debitCurrencyChain` | `string \| null` | No |  |
| `transaction.debitCurrencyCode` | `string \| null` | No |  |
| `transaction.errorCode` | `string \| null` | No |  |
| `transaction.externalSessionId` | `string \| null` | No |  |
| `transaction.feeCurrencyCode` | `string \| null` | No |  |
| `transaction.feesMap` | `Record<string, string> \| null` | No |  |
| `transaction.fiatFees` | `object \| null` | No |  |
| `transaction.fiatFees.feeAssetId` | `string \| null` | No |  |
| `transaction.fiatFees.feesMap` | `Record<string, string> \| null` | No |  |
| `transaction.fiatFees.total` | `string \| null` | No |  |
| `transaction.imageUrl` | `string \| null` | No |  |
| `transaction.location` | `object \| null` | No |  |
| `transaction.location.address1` | `string \| null` | No |  |
| `transaction.location.address2` | `string \| null` | No |  |
| `transaction.location.city` | `string \| null` | No |  |
| `transaction.location.coordinates` | `object \| null` | No |  |
| `transaction.location.coordinates.latitude` | `number \| null` | No |  |
| `transaction.location.coordinates.longitude` | `number \| null` | No |  |
| `transaction.location.country` | `string \| null` | No |  |
| `transaction.location.description` | `string \| null` | No |  |
| `transaction.location.locationReference` | `string \| null` | No |  |
| `transaction.location.state` | `string \| null` | No |  |
| `transaction.location.zipCode` | `string \| null` | No |  |
| `transaction.orderType` | `string \| null` | No |  |
| `transaction.originatorNumOwner` | `'COINME' \| 'PARTNER' \| 'USER' \| null` | No |  |
| `transaction.partnerTransactionId` | `string \| null` | No |  |
| `transaction.paymentMethodId` | `string \| null` | No |  |
| `transaction.promoCode` | `string \| null` | No |  |
| `transaction.providerId` | `string \| null` | No |  |
| `transaction.providerTransactionId` | `string \| null` | No |  |
| `transaction.providerTransactionRef` | `string \| null` | No |  |
| `transaction.spreadAmount` | `string \| null` | No |  |
| `transaction.spreadCurrencyCode` | `string \| null` | No |  |
| `transaction.tags` | `string[] \| null` | No |  |
| `transaction.totalFees` | `string \| null` | No |  |
| `transaction.trackingInfo` | `object \| null` | No |  |
| `transaction.trackingInfo.orderUpdateDateTime` | `string \| null` | No |  |
| `transaction.trackingInfo.trackingComplete` | `boolean \| null` | No |  |
| `transaction.trackingInfo.trackingState` | `string \| null` | No |  |
| `transaction.trackingInfo.trackingStateDescription` | `string \| null` | No |  |
| `transaction.trackingInfo.trackingType` | `string \| null` | No |  |
| `transaction.transactionDateTime` | `string \| null` | No |  |
| `transaction.transactionStatus` | `'PENDING' \| 'BLOCKCHAIN_ACCEPTED' \| 'CONFIRMED' \| 'FAILED' \| null` | No |  |

### CryptoAssetsBalance

One crypto asset balance in a `GetAssetBalancesResponse`.

```typescript
type CryptoAssetsBalance = NonNullable<GetAssetBalancesResponse['cryptoAssetsBalance']>[number];
```

### GPSCoordinates

GPS coordinates of a location.

```typescript
type GPSCoordinates = NonNullable<LocationInfo['coordinates']>;
```

### LocationInfo

Where a cash transaction took place.

```typescript
type LocationInfo = NonNullable<TransactionDetails['location']>;
```

### Nullable

A type that represents a nullable version of the given type.

```typescript
type Nullable<T> = { [P in keyof T]: T[P] | null };
```

### OrderTrackingInfo

Tracking details of an order.

```typescript
type OrderTrackingInfo = NonNullable<TransactionDetails['trackingInfo']>;
```

### Transaction

One transaction in a `GetTransactionHistoryResponse`.

```typescript
type Transaction = NonNullable<GetTransactionHistoryResponse['transactions']>[number];
```

### TransactionDetails

The transaction in a `GetTransactionResponse`.

```typescript
type TransactionDetails = NonNullable<GetTransactionResponse['transaction']>;
```

### Other names

Names the package also exports for the types above. The 1.x names remain as aliases of the generated ones.

| Name | Same as |
| --- | --- |
| `CryptoAssetsBalancesQueryParams` | `GetAssetBalancesQuery` |
| `GetTransactionHistoryQueryParams` | `GetTransactionHistoryQuery` |

## Errors

Every method rejects with an `APIError` when a call fails. Check for it with `isAPIError`, which works across packages, rather than `instanceof`. [Errors in the overview](https://platformdocs.coinme.com/docs/caas-api-clients.md#errors) explains the error shape.

| Export | What it is |
| --- | --- |
| `APIError` | Custom error class for handling API responses. Extends the native Error class to include structured error response details. |
| `isAPIError` | Tells whether an error was thrown by a CaaS API client. Prefer this to `instanceof APIError` when an application uses more than one client package: each package carries its own copy of the class. |
| `CAASErrorData` | Represents detailed information about an individual error in a CAAS error response. |
| `CAASErrorResponse` | Represents the structure of a CAAS error response, including HTTP status, timestamp, path, and an array of individual error data. |
| `GenericErrorResponse` | Represents the structure of a generic error response, used when handling non-CAAS errors like client or server errors (4xx or 5xx). |

### CAASErrorResponse

| Property | Type | Required | Description |
| --- | --- | --- | --- |
| `caasError` | `boolean` | Yes | True when the response body carried the CaaS error envelope (`errorResponse.errorData`), whatever the HTTP status; `errorData` then holds the server's own error codes. False for network failures and other error bodies, which are reported as one `GENERIC_ERROR`. |
| `errorData` | `CAASErrorData<U, V>[]` | Yes | Array of detailed error information objects, each representing an individual error. For non-CAAS errors, this array may contain generic error data. |
| `httpStatus` | `string` | Yes | HTTP status code as a string, indicating the type of error response. |
| `path` | `string` | Yes | API path where the error occurred, useful for tracing the origin of the error. |
| `timestamp` | `string` | Yes | Timestamp when the error occurred, in ISO 8601 format. |

### CAASErrorData

| Property | Type | Required | Description |
| --- | --- | --- | --- |
| `errorCode` | `U` | Yes | Unique code identifying the specific error that occurred. |
| `message` | `string` | Yes | Descriptive message explaining the nature of the error. |
| `metadata` | `V` | No | Optional metadata providing additional context for the error. |

```typescript
import { isAPIError } from '@coinme/history-api-client';

try {
  // a call on the client
} catch (error) {
  if (isAPIError(error)) {
    console.error(error.errorResponse.httpStatus, error.errorResponse.errorData);
  }
  throw error;
}
```
