PiperX Docs
  • 🌎Welcome
  • 📜Terms of Use
  • Introduction
    • 🎬What is PiperX
    • 📽️What is IPFi
    • 🤖DeFAI
  • User Guide
    • 🏫User Guide One Pager
    • 🌀How to Swap
    • ➕How to Add Liquidity
      • 🎯How to Claim LP Rewards
      • 🆕How to Create a New Pool
      • 👀How to Remove Liquidity
    • 💰How to Farm
  • Developer
    • 📚Smart Contracts
      • Mainnet
      • Aeneid
    • 🧰Integrations (TypeScript)
      • Swap
    • 📗APIs
  • Resources
    • 🔗Links
    • 💽Media Kit
    • ☎️Community Support
    • 🐸OG Program
Powered by GitBook
On this page
  • Requirement
  • DEX Stats
  • Recent Transactions
  • Get All Tokens
  • Token Historical Prices
  1. Developer

APIs

PreviousSwapNextLinks

Last updated 2 months ago

Requirement

The PiperX APIs provide a way to query PiperX standard (v2) and concentrated pools (v3) status. The below examples demonstrated how to query them. Note that PiperX API implemented . Therefore, if you want to use PiperX APIs from your deployed site (https://example.xyz), you need to contact PiperX team first to add your site.

DEX Stats

Get TVL and Volume of PiperX

Example query

curl https://piperxdb.piperxprotocol.workers.dev/api/piperxapi/tvl

Example output

{
  "dex": {
    "id": "piperx",
    "name": "PiperX",
    "totalVolumeUSD": "49432841143971", // decimal 6 for USD
    "totalVolumeNative": "15038256415533119426220899", // decimal 18 for native token
    "tvlUSD": "6979210444605",
    "tvlNative": "1034401251952740102208458"
  }
}

Recent Transactions

Recent swap transactions on a list of pools

Example query

curl -X POST \
-H "Content-Type: application/json"
-d '{"pairAddresses": ["0x4a170A20Dd1ff838C99d49Ac18b517a339206E83"]}'
https://piperxdb.piperxprotocol.workers.dev/api/piperxapi/recentSwaps

Example output

{
  "tokenSwaps": [
    {
      "timestamp": "1740996085000000",
      "token0Amount": "29425453054133087415",
      "token1Amount": "200000000",
      "zeroForOne": false,
      "amountUSD": "200000000", // decimal 6 for USD
      "account": {
        "id": "0xd49eeafa6bdbcc551f462c5a582959a9b7a2efdb"
      }
    },
    {
      "timestamp": "1740996059000000",
      "token0Amount": "10005484788346883",
      "token1Amount": "67988",
      "zeroForOne": false,
      "amountUSD": "67988",
      "account": {
        "id": "0x7e093ba1474b79481f9b87d66c99a819f25e82e2"
      }
    }]
}

Get All Tokens

Fetch all tokens and their price on PiperX V2 and V3 pool, including those tokens without transactions (price = 0)

Example query

curl https://piperxdb.piperxprotocol.workers.dev/api/piperxapi/getAllTokens

Example output

{
  "tokens": [
    {
      "id": "0x0149d87e919967148b18b09f3ef6fd87ad55ad6f",
      "name": "Test",
      "symbol": "TESTT",
      "decimals": 18,
      "latestPriceUSD": "0", // token without any transactions
      "latestPriceNative": "0"
    },
    {
      "id": "0x1514000000000000000000000000000000000000",
      "name": "Wrapped IP",
      "symbol": "WIP",
      "decimals": 18,
      "latestPriceUSD": "6757786", // to convert to real price, use latestPriceUSD /1e(24-decimals), i.e., 1 IP = 6.7577 USD
      "latestPriceNative": "1000000000000000000" // to convert to real price, use latestPriceNative /1e(36-decimals), i.e., 1 IP = 1 IP
    }
}

Token Historical Prices

Fetch a list of tokens' historical price

Example query

curl -X POST \
-H "Content-Type: application/json" 
-d '{"addresses": ["0x1514000000000000000000000000000000000000"]}' 
https://piperxdb.piperxprotocol.workers.dev/api/piperxapi/getAllTokenPrices

Example output

{
  "tokens": {
    "0x1514000000000000000000000000000000000000": {
      "symbol": "WIP",
      "now": "6750764", // to convert to real price, use latestPriceUSD /1e(24-decimals), i.e., 1 IP = 6.7507 USD
      "1h": "6791570",
      "2h": "6550901",
      "3h": "6486282",
      "4h": "6383945",
      "5h": "6633336",
      "6h": "6615643",
      "7h": "6405588",
      "8h": "6318354",
      "9h": "6235073",
      "10h": "6025256",
      "11h": "6211376",
      "12h": "6141735",
      "13h": "5987886",
      "14h": "6007658",
      "15h": "6231028",
      "16h": "6081970",
      "17h": "6185649",
      "18h": "6038601",
      "19h": "6071700",
      "20h": "6223667",
      "21h": "6296334",
      "22h": "6224512",
      "23h": "5875464",
      "24h": "5743224",
      "1d": "6211376",
      "2d": "5172550",
      "3d": "5522474",
      "4d": "5647480",
      "5d": "7037623",
      "6d": "5719907",
      "7d": "4506535"
    }
  },
  "timestamp": 1740996939976
}
📗
CORS Policy