[SOLVED] BSC explorer Json data

Hy guys, i’m afraid i’m very unexperienced in this domain and i would need help on how to explore the binance smart chain and get data about tokens by contract address.
Like, price, total supply, circulating supply, and so on.
Any help is appreciated. Thank you.
I do have a moralis account and a live server on main net … if this means anything.
But i’m stuck there.

PS, i found the Deep index api and i selected chain to query to BSC and Mainnet but,
i get this error:

Code Details
401

Undocumented|Error:

Response body

Download

"JWT missing"
Response headers|

I tried different token addresses and i get the same thing

1 Like

Hi inebunit,

When using the Deep Index API from your Dashboard you need to provide the master key to authorize the calls. See the Deep Index docs here:
https://docs.moralis.io/moralis-server/deep-index-api

You can also use the Convenience Functions plugs to get token and NFT balances for any address
https://docs.moralis.io/moralis-sdk/crypto-common-functions

In the future we’ll have some sort of built in way to get token price data, but for now the simplest way is to use the CoinGecko API. See their docs here:
https://www.coingecko.com/api/documentations/v3

Hope that helps.

thanks for the answer but i need prices data from the BSC tokens… all of them .
Coingeko doesn’t provide this.

We will offer onchain prices soon (probably in July)

thanks. looking forward to it

Update:
the https://docs.moralis.io/moralis-server/deep-index-api
seems to not exist anymore.
I am still trying to get token price from BSC and i get this error:
{“message”:“API KEY missing from x-api-key header”}
would appreciate any help.
I need to post prices from BSC on my website.
Thank you.

Hi,
Try to go to https://admin.moralis.io/web3Api and there try a simple API from that list.

that’s what i did and it came up with this link:
https://deep-index.moralis.io/api/v2/erc20/0x8e428aA75b271EbF905DB7e3F2970453E976481e/price?chain=bsc

Also, i don’t know what ProviderUrl means.

I used the /erc20/{address}/price
Choose BSC chain

You can ignore provider url for now.
I get this output:

{
  "nativePrice": {
    "value": "12738528727",
    "decimals": 18,
    "name": "Binance Coin",
    "symbol": "BNB"
  },
  "usdPrice": 0.00000474682112594,
  "exchangeAddress": "0xcA143Ce32Fe78f1f7019d7d551a6402fC5350c73",
  "exchangeName": "PancakeSwap v2"
}

i get this:
{“message”:“API KEY missing from x-api-key header”}

Also, the token name is not Binance coin … but that’s less important. Im mostly interested in the price.
https://poocoin.app/tokens/0x8e428aa75b271ebf905db7e3f2970453e976481e

Ok, try to refresh the page few times, it looks like it is a problem with generating the API key for your account. If the problem still persists, we’ll need to take a look at your account.

refreshed it like 5 times. Maybe i didn’t set something right?
I have to mention that i’m a noob so, don’t expect any system problems. Most probably it’s my fault.

What you see for the curl command?
I see something like this:

curl -X 'GET' \
  'https://deep-index.moralis.io/api/v2/erc20/0x8e428aA75b271EbF905DB7e3F2970453E976481e/price?chain=bsc' \
  -H 'accept: application/json' \
  -H 'X-API-Key: MY_API_KEY_HERE'
curl -X 'GET' \
  'https://deep-index.moralis.io/api/v2/erc20/0x8e428aa75b271ebf905db7e3f2970453e976481e/price?chain=bsc' \
  -H 'accept: application/json' \
  -H 'X-API-Key: <here is an apy key>
Should i post the api key also?

Also, i get this response in my moralis account:

{
  "nativePrice": {
    "value": "12651542928",
    "decimals": 18,
    "name": "Binance Coin",
    "symbol": "BNB"
  },
  "usdPrice": 0.00000475001883575,
  "exchangeAddress": "0xcA143Ce32Fe78f1f7019d7d551a6402fC5350c73",
  "exchangeName": "PancakeSwap v2"
}

But when i access the link in another browser tab,
https://deep-index.moralis.io/api/v2/erc20/0x8e428aa75b271ebf905db7e3f2970453e976481e/price?chain=bsc
i get this:
{“message”:“API KEY missing from x-api-key header”}

Ok, got it now, you can not use only that link to get the data, you also have to send the API key in the header request.

yes, i tested the curl here https://reqbin.com/req/c-vdhoummp/curl-get-json-example
and realized i’m way too noob for this. Thank you for your patience. I’ll try to integrate it in my website.

1 Like