The API response for /tokens and /hist is an array of objects. for /tokens/kai or /hist/kai will be an object since you are only requesting for kai.
The API is rate limited to 600 requests every 10 minutes to ensure that spamming does not occur.
Example usage (Js):
//create tokens variable (array of objects)var tokens=[];//function that updates the tokens variable whenever calledasyncfunctiongetTokens() {var res =awaitfetch('https://api.kardiainfo.com/tokens'); res =awaitres.json(); tokens =res.tokens;console.log(tokens)}//runs the getTokens() functiongetTokens();
After running this code the output in the console should look something like this:
Let's now look deeper into the tokens array and understand how we can use it. Within the array you can use a filter function to get a specific token by its id, name, symbol or contract address, it includes every single token traded on kaidex - at the time of writing this - 27 tokens.
Each of the tokens is an object which includes several fields - lets take a look at the example - SEN:
var sen;asyncfunctiongetSen() {var res =awaitfetch('https://api.kardiainfo.com/tokens/sen'); sen =awaitres.json();console.log(sen)}getSen();
as a result of making this request we can just get the sen object on its own. and here is how this response looks:
sen = {//The lower case SEN contract address contract:"0xb697231730c004110a86f51bff4b8dd085c0cb28"//The contract which is both upper and lower cased id: "0xb697231730C004110A86f51BfF4B8DD085c0CB28"//SEN's name name: "sleepearn.finance"//sleapearn.finance's symbol symbol: "SEN"//A description of SEN description: "SleepEarn Finance is a Decentralized, Yield Optimizer platform on KardiaChain that allows its users to earn compound interest on thei…"
//Price for 1 SEN in USD price: 0.7407962294324505//SEN's price change in the last 24h in % dayChange: 3.1360070140112097//SEN's price change in the last 7d in % weekChange: -29.597013107980246//Total SEN supply supply: 1000000//Fully diluted Market cap (sen.mcap = sen.supply * sen.price) mcap: 741343.790775871//SEN's TVL (usd value locked in LPs) tvl: 242937.01145341157//SEN logo stored on kardia info an image 80x80 px logo: "https://api.kardiainfo.com/images/SEN.png"//SEN logo from KAI probably a larger size logoOriginal: "https://kardiachain-explorer.s3-ap-southeast-1.amazonaws.com/explorer.kardiachain.io/logo/b697231730C004110A86f51BfF4B8DD085c0CB28.png"
//SEN's main group chat on telegram chat: "https://t.me/sleepearn"//SEN's website website: "https://sleepearn.finance/"//SEN Historic data where sen.histData[0] is current price//sen.histData[167] the price 1 week ago//Each of the array entries are 1 hour long rounded to nearest hour//so if now is 15:33://sen.histData[0] is 15:33//sen.histData[1] is 15:00//sen.histData[2] is 14:00 and so on histData: [0.7407962294324505, 0.737528501928906, 0.7496378382877602, 0.7400697628733692, 0.7310618209793391, 0.7255699577425332, 0.716406554781029, 0.7143519168446483, 0.7179232100815036, 0.724873841561361, …] (168)
//24 Hour Volume Vol24h:17245.175515152547//7 day Volume Vol7d:122002.12921675538//30 day Volume Vol30d:648407.9780143534//180 day Volume Vol180d:20878715.588442195//Year Volume Vol365d:20878715.588442195//All Time Volume allVol:20878715.588442195//sen.pairs is an array of objects, SEN only has 1 pair.//sen.pairs[0] gives you the pair object at position 0 pairs:[ {//The ID of the pair pairID:"0x43951c209003A70dCA94c2a5b09342C9c84E58Ac"//The name of the pair pairName: "SEN-KAI"//TVL of the pair pairTVL: "485874.0229068231327736992264540405"//Address of token 1 (KAI) token1: "0xb697231730C004110A86f51BfF4B8DD085c0CB28"//Address of token 2(SEN) token2: "0xAF984E23EAA3E7967F3C5E007fbe397D8566D23d" } ]}
The same can be done with /hist and /lps they have descriptive names so it should be quite easy to use them. if you still have questions about the api contact me on telegram - @dima3553 and I will help you set everything up.