A complete and heavily tested wrapper with typings for the zapper.fi API.

Overview

Zapperfi API

Unofficial wrapper for the Zapperfi API

Don't forget to leave a ⭐ if you found this useful.

Test npm npm Lines

Install

# use npm
$ npm i zapperfi-api

# use yarn
$ yarn add zapperfi-api

# use pnpm
$ pnpm add zapperfi-api

API

before using the zapperfi-api, you need to request a zapperfi api_key first

the zapperfi v2 api have been wrapped.

Usage

Creating a client

To create a client, simply provide an object with your apiKey

NOTE: If you're using zapperfi-api in a browser, you'll need to proxy your requests through your server with credentials, to keep the apiKey confidential. I will provide a convenient way to do this soon.

import { V2Client } from 'zapperfi-api'

const client = new V2Client({
  apiKey: '<your-api-key>',
})

Make a request

All methods have 2 arguments: the first one includes all of the parameters for particular method. And the second one is a callback function, it's optional, if you don't provide it, the request will return a promise instead. All the parameters and responses types are already defined, so you can use them directly with safe type.

// callback style
client.misc.getGasPrices(parameters, callback)

// async/await style
const response = await client.misc.getGasPrices(parameters)

Examples

get wallet tokens breakdown

import { V2Client, V2Models } from 'zapperfi-api'

const client = new V2Client({
  apiKey: process.env.ZAPPER_API_KEY,
})

const parameters = {
  networks: [V2Models.Network.ETHEREUM_MAINNET],
  addresses: ['0x7a250d5630B4cF539739dF2C5dAcb4c659F2488D'],
}

await client.balances.getAppBalance({ addresses, network, appId: 'tokens' })

get addresses balances

import { V2Client, V2Models } from 'zapperfi-api'

const client = new V2Client({
  apiKey: process.env.ZAPPER_API_KEY
})

const parameters = {
  networks: [V2Models.Network.ETHEREUM_MAINNET],
  addresses: ['0x7a250d5630B4cF539739dF2C5dAcb4c659F2488D'],
}

// use callback style
const callback = (err, data) => {
  if (err) throw err

  const { type, payload } = data

  if (type === 'partial') {
    // process payload with every incoming message payload
    // faster than full payload, but payload is not full
    ...
  }

  if (type === 'full') {
    // or, just process the final payload
    // slower than partial payload, but payload is full
    ...
  }
}
client.balances.get(parameters, callback)


// or, use async/await style
// but it only return the final full payload
const balances = await client.balances.get(parameters)

Client Methods

apps


Get supported applications.

apps.getPositions(parameters, callback?)

Retrieve positions (non-tokenized) for a given application

apps.getTokens(parameters, callback?)

Retrieve tokens for a given application

apps.supported(callback?)

Retrieve all supported applications info

apps.get(parameters, callback?)

Retrieve application info by appId

balances


balances.get(parameters, callback?)

Gets the balances for given addresses.

balances.getAppBalance(parameters, callback?)

get wallets balance by appId

balances.supported(parameters, callback?)

get all the apps info have participated for given addresses

exchange


Returns an easy to submit transaction for exchanging assets.

exchange.getPrice(parameters, callback?)

Returns data about the amount received if a trade would be made. Should be called whenever a price needs to be calculated.

exchange.getQuote(parameters, callback?)

Returns both the relative price for a trade as well as the call data used to submit a transaction for a trade.Should only be called when a trade is ready to be submitted.

exchange.supported(callback?)

Returns the exchanges supported by Zapper API.

misc


Miscellaneous Data Endpoints

misc.prices(parameters, callback?)

Retrieve supported tokens and their prices

misc.getTokenPrices(parameters, callback?)

Retrieve given token and its prices

misc.getGasPrices(parameters, callback?)

Retrieve a gas price aggregated from multiple different sources

transactions


Historical Transactions. Data on past transactions for a specific address.

transactions.get(parameters, callback?)

Data on past transactions for addresses

zapIn


Endpoints for creating transactions for adding liquidity to different applications.

zapIn.supported(parameters, callback?)

Provides a list of networks to app IDs that are supported by the Zap In routes.

zapIn.getApprovalState(parameters, callback?)

Retrieves an ERC20 approval status for an application zap-in

zapIn.getApprovalTransaction(parameters, callback?)

Builds an ERC20 approval transaction for an application zap-in

zapOut


Endpoints for creating transactions for removing liquidity from an application.

zapOut.supported(parameters, callback?)

Provides a list of networks to app IDs that are supported by the Zap Out routes.

zapOut.getApprovalState(parameters, callback?)

Retrieves an ERC20 approval status for an application zap-out.

zapOut.getApprovalTransaction(parameters, callback?)

Builds an ERC20 approval transaction for an application zap-out.

nft


Get Ethereum NFT balances for addresses.

nft.getNetWorth(parameters, callback?)

nft.getCollections(parameters, callback?)

nft.getCollectionsTotals(parameters, callback?)

Donations

Feel free to use the GitHub Sponsor button to donate towards my work if you think this project is helpful. πŸ€—

Comments
Owner
izayl
izayl
Harrison Njuguna 5 Nov 11, 2022
Automatically document all of your Remix loaders and actions typings per each route. πŸ“š

About remix-docs-gen parses all of your Remix loaders and actions and automatically documents all the typings per each route. Installation First, you

Stratulat Alexandru 50 Nov 9, 2022
Grupprojekt fΓΆr kurserna 'Javascript med Ramverk' och 'Agil Utveckling'

JavaScript-med-Ramverk-Laboration-3 Grupprojektet fΓΆr kurserna Javascript med Ramverk och Agil Utveckling. Utvecklingsguide FΓΆr information om hur utv

Svante Jonsson IT-HΓΆgskolan 3 May 18, 2022
Elegant jest.expect typings for a more civilized age

typed-jest-expect Elegant jest.expect typings for a more civilized age Why? By default, the expect utility of jest is very broadly typed, which makes

Elie Rotenberg 4 Feb 25, 2022
Hemsida fΓΆr personer i Sverige som kan och vill erbjuda boende till mΓ€nniskor pΓ₯ flykt

Getting Started with Create React App This project was bootstrapped with Create React App. Available Scripts In the project directory, you can run: np

null 4 May 3, 2022
Kurs-repo fΓΆr kursen Webbserver och Databaser

Webbserver och databaser This repository is meant for CME students to access exercises and codealongs that happen throughout the course. I hope you wi

null 14 Jan 3, 2023
Keep your sensitive information out of chat logs, emails, and more with heavily encrypted secrets.

Free encrypted secret sharing for everyone! This application is to be used to share encrypted secrets cross organizations, or as private persons. Hemm

Hemmelig 246 Dec 31, 2022
At BlackBox Vision we use heavily React Admin to build internal systems for our clients.

?? RA Firebase Starter ?? At BlackBox Vision we use heavily React Admin to build internal systems for our clients. Also, we rely on firebase a lot for

BlackBox Vision 2 Jun 7, 2022
Data structures & algorithms implementations and coding problem solutions. Written in Typescript and tested with Jest. Coding problems are pulled from LeetCode and Daily Coding Problem.

technical-interview-prep Data structures & algorithms implementations and coding problem solutions. Written in Typescript and tested with Jest. Coding

Lesley Chang 7 Aug 5, 2022
jQuery based scrolling Bar, for PC and Smartphones (touch events). It is modern slim, easy to integrate, easy to use. Tested on Firefox/Chrome/Maxthon/iPhone/Android. Very light <7ko min.js and <1Ko min.css.

Nice-Scrollbar Responsive jQuery based scrolling Bar, for PC and Smartphones (touch events). It is modern slim, easy to integrate, easy to use. Tested

Renan LAVAREC 2 Jan 18, 2022
Web-pack based Todo-List Website built using HTML, CSS and JavaScript. Tested Using Jest.

To-DO List Live Link Additional description about the project and its features: Built With HTML and CSS Javascript HTML & CSS3 & JavaScript Linters Gi

Saadat Ali 8 Mar 31, 2022
An interactive list of tasks where you can add, remove, edit, mark as completed and clear all done tasks. Tested with Jest.

To do List This project its an interactive list of task where you can add and remove tasks dinamically Project Images Add new Tasks Edit Existing Task

Alex Puente 7 Nov 9, 2022
The SheetJS Community Edition offers battle-tested open-source solution

The SheetJS Community Edition offers battle-tested open-source solutions for extracting useful data from almost any complex spreadsheet and generating new spreadsheets that will work with legacy and modern software alike.

SheetJS 32k Dec 29, 2022
Well-tested utility functions dealing with async iterables

aitertools This library provides a well-tested collection of small utility functions dealing with async iterables. You can think of it as LINQ or aite

Hong Minhee (ζ΄ͺ 民憙) 11 Aug 15, 2022
πŸš€ Battle-tested Next.js TypeScript Prisma template with an opinionated architecture. πŸ”‹ Included ℒ️

?? The Ultimate Next.js Starter Pack Next.js ^12 + TypeScript + Prisma + Chakra UI starter packed with useful development features. I've adopted indus

Nam 7 Dec 10, 2022
An open source API wrapper for TechHost API.

TechHost API Wrapper An open source API wrapper for TechHost API. Badges Installation Install techhost-api-wrapper with npm. npm install techhost-api-

Eight∞ 4 Jun 23, 2022
News API Wrapper for Violetics API News

News API Wrapper for Violetics API News

Violetics 3 Mar 23, 2022
A wrapper for valorant-api, a third-party API for getting data within Valorant. Available on npm

valorant-wrapper A wrapper for the third-party valorant-api How to Use All endpoints can be accessed off the ValAPI class. import { ValAPI } from 'val

Aircraft Overviewer 5 Nov 7, 2022