Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/zeriontech/defi-sdk-js
JavaScript/TypeScript wrapper for DeFi SDK
https://github.com/zeriontech/defi-sdk-js
dapp defi defi-sdk ethereum
Last synced: about 13 hours ago
JSON representation
JavaScript/TypeScript wrapper for DeFi SDK
- Host: GitHub
- URL: https://github.com/zeriontech/defi-sdk-js
- Owner: zeriontech
- License: mit
- Created: 2020-03-24T16:22:00.000Z (over 4 years ago)
- Default Branch: master
- Last Pushed: 2024-04-25T19:20:53.000Z (7 months ago)
- Last Synced: 2024-04-26T19:25:21.832Z (7 months ago)
- Topics: dapp, defi, defi-sdk, ethereum
- Language: TypeScript
- Homepage: https://docs.zerion.io
- Size: 3.84 MB
- Stars: 47
- Watchers: 9
- Forks: 21
- Open Issues: 5
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# defi-sdk
A JS client for interacting with [Zerion API](https://github.com/zeriontech/zerion-api)
## Install
```sh
npm install defi-sdk
```## Getting Started
```js
import { client } from "defi-sdk";client.configure({ url: endpoint, apiToken: API_TOKEN });
```## API
### General usage
### client.subscribe(options)
```js
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`: a [`Namespace`](https://docs.zerion.io/websockets/namespaces) string
- `event`: one of `received | changed | appended | removed`, see [Zerion Docs](https://docs.zerion.io/websockets/websocket-api-overview)
- `body`: a [`Request`](#Request) object
- `data`: a [`Response`](#Response) object## Domain Helpers
Instead of calling `client.subscribe` and passing type information manually, the SDK provides helpers for most of the existing request [scopes](https://docs.zerion.io/websockets/websocket-api-overview#request)
### `addressAssets`
```js
import { client } from "defi-sdk";client.addressAssets({
payload: { asset_codes: ["eth"], currency: "usd" },
onData: data => {
/* handle data */
}
});
```## Types
### Request
```ts
interface Request {
scope: ScopeName[];
payload: T;
}
```### Response
```ts
interface Response {
meta: any;
payload: T;
}
```See `Response` in [Zerion Docs](https://docs.zerion.io/websockets/websocket-api-overview#response)
## License
MIT License, see the included [LICENSE](LICENSE) file.