Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/openfort-xyz/openfort-node
https://github.com/openfort-xyz/openfort-node
sdk typescript
Last synced: about 2 months ago
JSON representation
- Host: GitHub
- URL: https://github.com/openfort-xyz/openfort-node
- Owner: openfort-xyz
- Created: 2023-05-16T21:02:57.000Z (over 1 year ago)
- Default Branch: main
- Last Pushed: 2024-10-29T09:02:29.000Z (2 months ago)
- Last Synced: 2024-10-29T10:06:01.081Z (2 months ago)
- Topics: sdk, typescript
- Language: TypeScript
- Size: 2.8 MB
- Stars: 5
- Watchers: 0
- Forks: 6
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
- awesome-account-abstraction - openfort-xyz/openfort-node
README
![Illustration_04 1-min](https://github.com/user-attachments/assets/84796219-8196-40fb-a28a-6ca24a388818)
# Openfort Node.js Library
[![Version](https://img.shields.io/npm/v/@openfort/openfort-node.svg)](https://www.npmjs.org/package/@openfort/openfort-node)
The Openfort Node library provides convenient access to the Openfort API from applications written in server-side JavaScript.
## Documentation
See the [`openfort-node` API docs]([https://openfort.xyz/docs/api?lang=node](https://www.openfort.xyz/docs/reference/api/introduction)) for Node.js.
## Requirements
Node 14 or higher.
## Installation
```shell
npm install @openfort/openfort-node
``````shell
yarn add @openfort/openfort-node
```## Usage
The package needs to be configured with your account's secret key, which is
available in the [Openfort Dashboard][api-keys]. Require it with the key's
value:```js
const openfort = require('@openfort/openfort-node')('sk_test_...');openfort.players.create({
name: 'Joan McCoain',
description: 'API created player'
})
.then(player => console.log(player.id))
.catch(error => console.error(error));
```Or using ES modules and `async`/`await`:
```js
import Openfort from '@openfort/openfort-node';
const openfort = new Openfort('sk_test_...');const player = await openfort.players.create({
name: '[email protected]',
description: 'API created player'
});console.log(player.id);
```Below code snippet shows exemplary usage of the configuration and the API.
```typescript
import Openfort from "@openfort/openfort-node";async function example() {
const openfort = new Openfort("sk_test_XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX");
const players = await openfort.players.list();
for (const player of players.data) {
console.log(player.id);
}const newPlayer = await openfort.players.create({name: "Test"});
console.log(newPlayer.id)const transactionIntents = await openfort.transactionIntents.list();
for (const intent of transactionIntents.data) {
console.log(`Intent ${intent.id} by ${intent.player.name}`);
}
}example().catch((e) => console.error(e));
```## Support
New features and bug fixes are released on the latest major version of the `openfort` package. If you are on an older major version, we recommend that you upgrade to the latest in order to use the new features and bug fixes including those for security vulnerabilities. Older major versions of the package will continue to be available for use, but will not be receiving any updates.
[api-keys]: https://dashboard.openfort.xyz/api-keys