Code Monkey home page Code Monkey logo

openfort-node's Introduction

Openfort Node.js Library

Version

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 for Node.js.

Requirements

Node 14 or higher.

Installation

npm install @openfort/openfort-node
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. Require it with the key's value:

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:

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.

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.

openfort-node's People

Contributors

tsviatkov avatar jamalavedra avatar robbyuitbeijerse avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.