LogoLogo
  • 👋Introduction
    • Welcome
      • Actived Aggregators
      • Supported Chains
    • Vision
    • Upcoming development
    • Tokenomics
  • 📖User Guide
    • Get Started
      • How to connect a wallet
      • How to swap tokens
      • How to switch chains
    • FAQ
    • Disclaimer
  • 🤖Features
    • Staking
    • Trading Signals
    • Referral Program
    • Cross-chain Swap
    • LSD Aggregator
  • AMBASSADOR
    • Community Ambassador
      • Application Form
    • Trading Ambassador
      • Application Form
  • Widget
    • Getting Started
    • Example Themes
    • Widget Config Reference
  • SDK
    • Quick Start
    • SDK API
    • SDK Swap
  • API
    • Best Practice
    • API Reference
    • Cross Chain API
  • APPENDIX
    • 0xGen Wallet
    • Fee Overview
    • Media Kit
  • MORE
    • Github
    • Discord
    • Telegram
    • Twitter
    • Blog
Powered by GitBook
On this page
  • getGasPrice
  • getTokenPrice
  • getTokenList
  • quote
  • swapQuote
  1. SDK

SDK API

Api module, method through HTTP interface query data

PreviousQuick Start NextSDK Swap

Last updated 9 months ago

Go to the detailed interface documentation

// Base code block
import { GenSdk } from '@gen-io/gen-sdk';
const genSdk = new GenSdk({
  apiUrl: "https://api.0xgen.io",
});
const { api } = genSdk

getGasPrice

let data = await api.getGasPrice({
   chain: 'bsc'
})

getTokenPrice

let data = api.getTokenPrice({
       ids: 'bitcoin',
       vs_currencies: 'usd'
})
       

getTokenList

let data=awit api.getTokenList({
    chain: 'BSC',
})

quote

let gasPrice = await api.getGasPrice({
  chain: 'bsc',
})
let quoteData = await api.quote({
  chain: 'bsc',
  inTokenAddress: '0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE',
  outTokenAddress: '0x55d398326f99059ff775485246999027b3197955',
  amount: '5',
  gasPrice: gasPrice.data.gasPrice,
  slippage: 3,
})

swapQuote

dex: 1inch,matcha、openocean、jupiter

slippage: 3=3%

let gasPrice = await api.getGasPrice({
  chain: 'bsc',
})
let swapData = await swapSdk.swapQuote({
  chain: 'bsc',
  dex: 'openOcean',
  inTokenAddress: '0x55d398326f99059ff775485246999027b3197955',
  outTokenAddress: '0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE',
  amount: '0.1',
  gasPrice: gasPrice.data.gasPrice,
  slippage: 3,
  account: 'The address of your wallet',
})
https://docs.0xgen.io/api/api