Unofficial wrapper for the Zapperfi API
Don't forget to leave a ⭐ if you found this useful.
# use npm
$ npm i zapperfi-api
# use yarn
$ yarn add zapperfi-api
# use pnpm
$ pnpm add zapperfi-api
before using the zapperfi-api, you need to request a zapperfi api_key first
the zapperfi v2 api have been wrapped.
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>',
})
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)
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' })
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)
Get supported applications.
Retrieve positions (non-tokenized) for a given application
Retrieve tokens for a given application
Retrieve all supported applications info
Retrieve application info by appId
Gets the balances for given addresses.
get wallets balance by appId
get all the apps info have participated for given addresses
Returns an easy to submit transaction for exchanging assets.
Returns data about the amount received if a trade would be made. Should be called whenever a price needs to be calculated.
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.
Returns the exchanges supported by Zapper API.
Miscellaneous Data Endpoints
Retrieve supported tokens and their prices
Retrieve given token and its prices
Retrieve a gas price aggregated from multiple different sources
Historical Transactions. Data on past transactions for a specific address.
Data on past transactions for addresses
Endpoints for creating transactions for adding liquidity to different applications.
Provides a list of networks to app IDs that are supported by the Zap In routes.
Retrieves an ERC20 approval status for an application zap-in
Builds an ERC20 approval transaction for an application zap-in
Endpoints for creating transactions for removing liquidity from an application.
Provides a list of networks to app IDs that are supported by the Zap Out routes.
Retrieves an ERC20 approval status for an application zap-out.
Builds an ERC20 approval transaction for an application zap-out.
Get Ethereum NFT balances for addresses.
Feel free to use the GitHub Sponsor button to donate towards my work if you think this project is helpful. 🤗