defi-sdk
v0.2.0
Published
Zerion API Client for JS
Readme
defi-sdk
A JS client for interacting with Zerion API
Install
npm install defi-sdkGetting 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: aNamespacestringevent: one ofreceived | changed | appended | removed, see Zerion Docsbody: aRequestobjectdata: aResponseobject
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.
