# @keeex/keeex-api-sdk

> SDK to call KeeeX API

Latest version **6.1.3** (published 2026-09-04) · SEE LICENSE IN LICENSE license · 0 weekly downloads

## Install

```sh
npm install @keeex/keeex-api-sdk
pnpm add @keeex/keeex-api-sdk
yarn add @keeex/keeex-api-sdk
bun add @keeex/keeex-api-sdk
```

## Health

**Score 70/100 (B)** — status: active.

Positive: has types; esm support; no vulnerabilities; recently updated; high maintenance score; high quality score.

Warnings: low downloads.

## Facts

| | |
|---|---|
| Version | 6.1.3 |
| Published | 2026-09-04 |
| First published | 2023-11-06 |
| Weekly downloads | 0 |
| License | SEE LICENSE IN LICENSE |
| TypeScript types | bundled |
| Module format | ESM + CommonJS |
| Dependencies | 5 |
| Unpacked size | 235.6 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Author | KeeeX SAS |
| Maintainers | marc-keeex, cley_faye, keeex_jenkins |

## Links

- npm: https://www.npmjs.com/package/@keeex/keeex-api-sdk
- Repository: https://devtools.keeex.me:222/KeeeX/KeeeXApi-sdk-js
- npm.io page: https://npm.io/package/@keeex/keeex-api-sdk

## Dependencies (5)

- [axios](https://npm.io/package/axios.md) ^1.20.0
- [@keeex/utils](https://npm.io/package/@keeex/utils.md) ^7.6.5
- [@keeex/crypto](https://npm.io/package/@keeex/crypto.md) ^3.7.9
- [@keeex/js-keys](https://npm.io/package/@keeex/js-keys.md) ^4.7.7
- [@keeex/sdk-helper](https://npm.io/package/@keeex/sdk-helper.md) ^7.3.2

## Recent versions

- 6.1.3 (latest) — 2026-09-04
- 5.0.0-11 (prerelease) — 2024-12-17
- 6.1.2 — 2026-09-04
- 6.1.1 — 2026-04-09
- 6.1.0 — 2026-03-20
- 6.0.0 — 2026-02-18
- 5.2.1 — 2025-06-19
- 5.1.4 — 2025-06-11
- 5.1.3 — 2025-06-10
- 5.1.1 — 2025-03-17
- 5.1.0 — 2025-03-04
- 5.0.2 — 2025-02-27
- 5.0.0-10 — 2024-11-19
- 5.0.0-9 — 2024-11-07
- 5.0.0-7 — 2024-10-15
- … 14 more at https://npm.io/package/@keeex/keeex-api-sdk/versions

## README

# @keeex/keeex-api-sdk



Provide access to the KeeeX API for timestamping and user management.

## Installation

Use npm:

```shell
npm install @keeex/keeex-api-sdk
```

## Usage

Import the KeeexApi class and instantiate it with the authentication info.
Authentication and tokens are renewed as needed.

A crypto-provider must be set before any operation can be done.

Example:

```JavaScript
import KeeexApi from "@keeex/keeex-api-sdk";
import "@keeex/crypto-provider-node";

/**
 * @param {object} data
 * @param {string} [data.appId]
 * @param {string} [data.authToken] - Provide a previously obtained token to avoid the login
 *   call.
 * @param {string} [data.authType] - one of "header" or "cookie"
 * @param {boolean} [data.autoRenewAuthToken] - if true, will enable lazy auth and auto-renewal of
 *   authToken on 401
 * @param {AxiosInstance} [data.axios] - Axios used for generic URL call (calls to outside
 *   world, not on API server)
 * @param {object} [data.endpointOptions] - if provided, all sub property MUST be present.
 * @param {string} [data.endpointOptions.licenseSigningAddress]
 * @param {string} [data.endpointOptions.responseSigningAddress]
 * @param {string} [data.endpointOptions.signature]
 * @param {string} [data.endpointOptions.url]
 * @param {string} [data.login]
 * @param {NewAuthTokenCb} [data.newAuthTokenCb] - callback to get the newly acquired authToken
 * @param {string} [data.password]
 * @param {ProxySettings} [data.proxy]
 * @param {UnauthorizedCb} [data.unauthorizedCb] - Callback to globally handle disconnection
 */
const api = await KeeexApi.factory({
  login: "<userlogin>",
  password: "<userpassword>",
  appId: "<app id>",
});

await api.getAuthToken(); // only needed if you provied credentials in the factory
await api.timestamp({idx: "zuzi-ntinen"});

const res = await api.getTimestampInfo({idx: "zuzi-ntinen"});

console.log(res.idx);
```

In the above example, the login and password are required, as well as the appId.
An application can optionaly provide an `authToken` that was saved previously.
If the token is still valid, it will be used, otherwise it will be automatically renewed.

If you do not provide credentials, you can still call the the `getTimestampInfo` method.

### Get timestamp info

This method return timestamp information about an IDX.

You can either is authenticated or not but, beware that throttling might be applied if you are not.

```javascript
/**
 * @param {object} data
 * @param {string} data.idx
 */
const timestampInfo = await api.getTimestampInfo({idx: "zuzi-ntinen"});
```

### Get license text

This method return the license text either of the current authenticated user or the one
required in the `user` option's parameter.

You MUST be authenticated to do this call.

```javascript
/**
 * @param {object} [options]
 * @param {string} [options.userEmail] - If provided, will get the license of this user.
 *   /!\ Only works if authenticated user is from keeex
 * @param {number} [options.userId] - If provided, will get the license of this user.
 *   /!\ Only works if authenticated user is from keeex
 */
// get own license
const licenseFile = await api.getLicenseText();
// get license for another user
const licenseFile = await api.getLicenseText({user: 1});
```

### Get remaining credits

This method return the remaining credits either for the current authenticated user or the one
required in the `user` parameter.

You MUST be authenticated to do this call.

```javascript
/**
 * @param {object} [data]
 * @param {string} [data.userEmail] - If provided, will get this user's remaining credits.
 *   /!\ Only works if authenticated user is from keeex
 * @param {number} [data.userId] - same as userEmail
 */
// get own remaining credits
const remainingCredits = await api.remainingCredits();
// get remaining credits for another user
const remainingCredits = await api.remainingCredits({userId: 1});
```

### Verify credits

This method allow you to know if the current authenticated user or the one required in the `user`
parameter can use 1 credit of selected types.

You MUST be authenticated to do this call.

```javascript
/**
 * @param {object} data
 * @param {Array<CreditTypes>} data.credits
 * @param {string} [data.userEmail] - If provided, will get this user's remaining credits.
 *   /!\ Only works if authenticated user is from keeex
 * @param {number} [data.userId] - same as userEmail
 **/
// check if current user can do 1 keeexing
const permissions = await api.verifyCredits({credits: [CreditTypes.keeex]});
// check if another user can do 1 bitcoin anchoring
cosnt permissions = await api.checkPermission({credits: [CreditTypes.bitcoin], userId: 1});
```

### Use credits

This method use credit either of the current authenticated user or the one required in the `user`
parameter.

You MUST be authenticated to do this call.

```javascript
/**
 * @param {object} data
 * @param {Array<UseCreditRequest>} data.credits
 * @param {string} [data.userEmail] - If provided, will get this user's remaining credits.
 *   /!\ Only works if authenticated user is from keeex
 * @param {number} [data.userId] - same as userEmail
 */
// use own credits
await api.useCredits({credits: [CreditTypes.keeex, CreditTypes.bitcoin]});
// use own credits
await api.useCredits({
  credits: [
    {type: CreditTypes.keeex, count: 1},
    {type: CreditTypes.timestamp, count: 1},
  ],
});
// use credits for another user
await api.useCredits({
  credits: [CreditTypes.keeex, CreditTypes.timestamp],
  userId: 1,
});
```

### Timestamp an idx

This method send timestamp request and consume either current authenticated user's credits or thoses
of the required user in `user` parameter.

Unless you really need the out, you should do this call asynchronously for performance reason.

You MUST be authenticated to do this call.

```javascript
/**
 * @param {TimestampParams} data
 * @param {string} data.idx
 * @param {boolean} [data.asynchronous] - default to true
 * @param {string} [data.btcId]
 * @param {boolean} [data.countKeeexing]
 * @param {Array<CreditTypes>} [data.credits] - CAN NOT includes CreditTypes.keeex
 * @param {string} [data.userEmail] - If provided, will get this user's remaining credits.
 *   /!\ Only works if authenticated user is from keeex
 * @param {number} [data.userId] - same as userEmail
 */
// timestamp idx and consume own timestamp credit
await api.timestamp({idx: "zuzi-ntinen"});
// timestamp idx and consume another user credits, send along a btcId and do it asynchronously
await api.timestamp(
  {
    idx: "zuzi-ntinen",
    btcId: "<btcId>",
    countKeeexing: true,
    credits: [CreditTypes.bitcoin, CreditTypes.rfc3161Keeex, CreditTypes.ethereumKeeex],
  },
  1,
);
```

### Get After string

This method return an after string containing a blockchain latest known block hash. As of writing
this, it will be either ethereum or bitcoin blockchain.

You MUST be authenticated to do this call;

```javascript
const afterString = await api.getAfterString();
```

## Persistent authentication

By providing an old `authToken` it is possible to persist authentication across sessions.
To get the new `authToken` obtained after the authentication process, the caller can provide a
callback function that will be called everytime a new token is obtained.
This callback must be provided as the `newAuthTokenCB` property of the `options` argument.

## Build issue with webpack

The library tries to detect if it should use our certificate or not.
When this detection fails, the module is not imported.
Webpack can not know that ahead of time however, so it is necessary to add a few exclusion
depending on your environment.

The following dependencies can be overloaded with nothing without issue:

- `https`
- `socks-proxy-agent`
- `https-proxy-agent`

Add this:

```JavaScript
{
  resolve: {fallback: {"https": false}},
  externals: {"socks-proxy-agent": "false", "https-proxy-agent": "false"}
}
```

To webpack configuration.

---
_Source: https://npm.io/package/@keeex/keeex-api-sdk · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
