[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


Response body


"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:

You can also use the Convenience Functions plugs to get token and NFT balances for any address

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:

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

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.

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:

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.

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' \
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,
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

Hey there, I am having a similar issue - I can get a good response in some apps, but not all. Here’s what it looks like in Xcode:

Any ideas? Thanks.

I don’t know how did you set that http header there. You can find here an example on how you should set that header value in curl: https://admin.moralis.io/web3Api after you try there a function.

this is how i used mine

//cURL price data from JSON				
$url = "https://deep-index.moralis.io/api/v2/erc20/" . $contract . "/price?chain=" . $network . "";

$curl = curl_init($url);
curl_setopt($curl, CURLOPT_URL, $url);
curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);

$headers = array(
   "accept: application/json",
   "X-API-Key: <your api key here>",
curl_setopt($curl, CURLOPT_HTTPHEADER, $headers);

$resp = curl_exec($curl);

$yummy = json_decode($resp);
$usdprice = @$yummy->usdPrice;
//end cURL price data from JSON	

i’m getting data from 2 chains. by contract.
also, gettin g data for each crypto in real time will make your site unbearable slow.
What i did was to set up a cron-job to run once an hour and populate database with the data for each crypto then pull data from data base with 1h term.

1 Like