@maten/amnis-sdk
v0.2.1
Published
Javascript (Node & Web) SDK for Amnis Treasury's public API
Downloads
3
Readme
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",
});
| Parameter | Type | Description |
| :-------- | :------- | :------------------------- |
| client_id
| string
| Required. Your amnis api client id |
| client_secret
| string
| Required. 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 itemsPerPage
is 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.