defi-sdk
v0.1.9
Published
Zerion API Client for JS
Downloads
1,222
Readme
defi-sdk
A JS client for interacting with Zerion API
Install
npm install defi-sdk
Getting Started
import { client } from "defi-sdk";
client.configure({ url: endpoint, apiToken: API_TOKEN });
API
General usage
client.subscribe(options)
import { client } from "defi-sdk";
client.subscribe({
namespace: "assets",
body: {
scope: ["prices"],
payload: { asset_codes: ["eth"], currency: "usd" }
},
onMessage: (event: Event, data: Response) => {
/* handle data */
}
});
namespace
: aNamespace
stringevent
: one ofreceived | changed | appended | removed
, see Zerion Docsbody
: aRequest
objectdata
: aResponse
object
Domain Helpers
Instead of calling client.subscribe
and passing type information manually, the SDK provides helpers for most of the existing request scopes
addressAssets
import { client } from "defi-sdk";
client.addressAssets({
payload: { asset_codes: ["eth"], currency: "usd" },
onData: data => {
/* handle data */
}
});
Types
Request
interface Request<T, ScopeName extends string> {
scope: ScopeName[];
payload: T;
}
Response
interface Response<T> {
meta: any;
payload: T;
}
See Response
in Zerion Docs
License
MIT License, see the included LICENSE file.