0.2.1 • Published 9 months ago

@maten/amnis-sdk v0.2.1

Weekly downloads
-
License
MIT
Repository
github
Last release
9 months ago

amnis-sdk

This is a Javascript (Node & Web) API wrapper SDK for Amnis Treasury's public API. The purpose is to wrap the API and provide a fully typed Typescript interface around it.

Installation

Install with npm

npm install --save @maten/amnis-sdk

Or with yarn

yarn add @maten/amnis-sdk

Examples

Initialize the client

import { AmnisClient } from "@maten/amnis-sdk";

const client = new AmnisClient({
    client_id: "id",
    client_secret: "secret",
});
ParameterTypeDescription
client_idstringRequired. Your amnis api client id
client_secretstringRequired. Your amnis api client secret

Get a resource collection

const transactions = await client.transactions.getAllResources();

Collections are are always paginated. The response contains all the pagination info. By default the itemsPerPageis set to 30 by the API, it can be overwritten by providing parameters for the method, eg:

const transaction = await client.transactions.getAllResources({
    itemsPerPage: 5,
    page: 1,
});

Collections can be requested with provided filters too. The filters are different for each resource types, although they are always the same as the public API has them, and the options are provided by Typescript types.

Example filters for transactions collection

// Filter for transactions with amount greater than 1000
const transaction = await client.transactions.getAllResources({
    abs_amount: {
      gt: '1000.00'
    }    
});

// Filter for transactions that are executed
const transaction = await client.transactions.getAllResources({
    executed: true 
});

Get a single resource

const transaction = await client.transactions.getResourceById(1);

Every resource request (both collections and single) is returning with a Promise, so you can use .then().catch() on them, or async/await.

All the available resource types are fully typed, and available through the client object.

For full API documentation, please refer to the original API docs.

0.2.1

9 months ago

0.2.0

9 months ago

0.1.4

1 year ago

0.1.3

1 year ago

0.1.2

1 year ago

0.1.1

1 year ago

0.1.0

1 year ago

0.0.1

1 year ago

1.1.0

1 year ago

1.0.0

1 year ago