DeFI APIs

Easiest way to read defi data on Solana.

Defi data on Solana is scattered across multiple dexes, making it very difficult to work with. In order to read, one needs to handle each DEX separately, either through its SDK or raw RPC calls. Some functionality is notoriously slow since we need to use `getProgramAccounts` RPC call.

Enter Shyft Defi APIs

Accurate defi data across multiple dexes at blazingly fast speeds.

A simple call to fetch all pools of a token can take ~10 seconds or more, with the new Defi APIs it be done in under 500ms. Moreover all pools are returned in a parsed format, so you don't have to deal with IDLs on your end.

Following DEXs are supported by DeFi APIs currently.

DEX NameAddress

fluxbeam

FLUXubRmkEi2q6K3Y9kBPg9248ggaZVsoSFhtJHSrm1X

meteoraAmm

Eo7WjKq67rjJQSZxS6z3YkapzY3eMj6Xy8X5EQVn5UaB

meteoraDlmm

LBUZKhRxPF3XUpBCjp4YzTKgLccjZhTSDM9YuVaPwxo

openbookV2

opnb2LAfJYbRMAHHvqjCwQxanZn7ReEHp1k81EohpZb

orca

whirLbMiicVdio4qvUfM5KAg6Ct8VwpYzGff3uctyCc

raydiumAmm

675kPX9MHTjS2zt1qfr1NYHuzeLXfQM9H24wFSUt1Mp8

raydiumClmm

CAMMCzo5YL8w4VFF8KVHrK22GGUsp5VTaW7grrKgrWqK

raydiumCpmm

CPMMoo8L3F4NbTegBCKVNunggL7H1ZpdTHKxQB5qKP1C

Base URL for DeFi APIs: https://defi.shyft.to

Get Pool By Address

Accepts a pool address and returns all pool details including the DEX to which it belongs to.

GET /v0/pools/get_by_address

Query Params:

  • address: Address of the pool for which we want to fetch data. We automatically detect which dex this pools belongs to and parse accordingly.

const myHeaders = new Headers();
myHeaders.append("accept", "application/json");
myHeaders.append("x-api-key", "<YOUR-API-KEY>");

const requestOptions = {
  method: "GET",
  headers: myHeaders,
  redirect: "follow"
};

fetch("https://defi.shyft.to/v0/pools/get_by_address?address=cHR79RPHM8PKMN1vkoetC3PSofXCUXnd92nPeKvhvom", requestOptions)
  .then((response) => response.text())
  .then((result) => console.log(result))
  .catch((error) => console.error(error));

Get Pools by Token Pair

Takes a pair of token addresses and returns all pools across DEXs with the specified liquidity pair. This API supports pagination and can also filter pools to a specific DEX if needed.

GET /v0/pools/get_by_pair

Query Params:

  • tokenA: Address of one of the Tokens in the Pair.

  • tokenB: Address of the other Token in the Liquidity Pair. The order of the token does not matter.

  • dex: (optional) Specifies an array of DEXes (string names) for which we will be receiving the pools.

  • limit: (optional) Specifies the number of items to display per page. The default value is 100.

  • page: (optional) Specifies the page number when displaying items specified by limit.

Let's say we want to fetch 50 pools from a particular DEX. We would set the limit parameter to 50 and the page parameter to 1. To get the next 50 pools, we would keep the limit at 50 but increase the page to 2.

To get the 5th set of 50 pools, we'd set the limit to 50 and the page to 5.

If a DEX doesn't have enough pools for a specific page, it will return an empty response.

const myHeaders = new Headers();
myHeaders.append("accept", "application/json");
myHeaders.append("x-api-key", "<YOUR-API-KEY>");

const requestOptions = {
  method: "GET",
  headers: myHeaders,
  redirect: "follow"
};

fetch("https://defi.shyft.to/v0/pools/get_by_pair?tokenA=So11111111111111111111111111111111111111112&tokenB=EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v&page=1&limit=10", requestOptions)
  .then((response) => response.text())
  .then((result) => console.log(result))
  .catch((error) => console.error(error));

Get All Pools For a Token

Accepts a single token address, and fetche all pools for that particular token across supported DEXes. This API also supports pagination.

GET /v0/pools/get_by_token

Query Params:

  • token: Address of the token for which we are fetching pools.

  • limit: (optional) Specifies the number of items to display per page. The default value is 100.

  • page: (optional) Specifies the page number when displaying items specified by limit.

Let's say we want to fetch 50 pools from a particular DEX. We would set the limit parameter to 50 and the page parameter to 1. To get the next 50 pools, we would keep the limit at 50 but increase the page to 2.

To get the 5th set of 50 pools, we'd set the limit to 50 and the page to 5. If a DEX doesn't have enough pools for a specific page, it will return an empty response.

const myHeaders = new Headers();
myHeaders.append("accept", "application/json");
myHeaders.append("x-api-key", "<YOUR-API-KEY>");

const requestOptions = {
  method: "GET",
  headers: myHeaders,
  redirect: "follow"
};

fetch("https://defi.shyft.to/v0/pools/get_by_token?token=EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v&page=1&limit=10", requestOptions)
  .then((response) => response.text())
  .then((result) => console.log(result))
  .catch((error) => console.error(error));