2

Simple question: It seems like ethplorer doesn't expose the ETH price via their public api:

https://github.com/EverexIO/Ethplorer/wiki/Ethplorer-API

Am I missing anything, or do I have to rely on another API for this information?

0

3 Answers 3

6

(The Ethplorer API is specific to ERC-20 tokens, so won't give you what you want.)

Price is subjective, and different exchanges will trade at different rates depending on the markets that use them.

If you want an average price you'll need to either use several APIs - from those exchanges you care about - and take an average, or use a service that automatically averages across all exchanges. (Also, if you use the first method, you might want to think about weighting the average by the trade volume on the exchanges.)

I think the CoinMarketCap API does the averaging and weighting across the exchanges it knows about:

https://api.coinmarketcap.com/v1/ticker/ethereum/

Output:

[
    {
        "id": "ethereum", 
        "name": "Ethereum", 
        "symbol": "ETH", 
        "rank": "2", 
        "price_usd": "472.07", 
        "price_btc": "0.0499671", 
        "24h_volume_usd": "1350430000.0", 
        "market_cap_usd": "45310507324.0", 
        "available_supply": "95982603.0", 
        "total_supply": "95982603.0", 
        "max_supply": null, 
        "percent_change_1h": "-3.34", 
        "percent_change_24h": "2.34", 
        "percent_change_7d": "31.86", 
        "last_updated": "1511776452"
    }
]

If you want a different quote currency, rather than USD or BTC, then you can do that, too.

2

Doesn't look like it, seems you'll have to use another API. Coinbase seems to have one available you can check out.

https://developers.coinbase.com/api/v2#authentication

0

If you are interested in an all encompassing api, Amberdata.io now has market data in addition to their blockchain data.

They also have the option to return market data with some of their blockchain data endpoints. For instance, you can get transaction data along with the value of the transaction in a currency. In this case usd.

Like so:

Request

curl --request GET \
  --url 'https://web3api.io/api/v1/transactions/0x0814c4dbca0922963384aaf9c756ea64817bf55971d743bd3c700e983bc0c7e2?includePrice=true' \
  --header 'x-api-key: UAK000000000000000000000000demo0001'

Note: includePrice=true is the key here.

Response

{
  "status": 200,
  "title": "OK",
  "description": "Successful request",
  "payload": {
    "blockNumber": "7581391",
    "contractAddress": "null",
    "cumulativeGasUsed": "107517",
    "from": "0x5bcbdfb6cc624b959c39a2d16110d1f2d9204f72",
    "gas": "300000",
    "gasPrice": "41800000000",
    "gasUsed": "21000",
    "hash": "0x0814c4dbca0922963384aaf9c756ea64817bf55971d743bd3c700e983bc0c7e2",
    "index": 2,
    "input": "0x",
    "logsBloom": "0x000000...",
    "nonce": "22559",
    "publicKey": "",
    "r": "0x88fd625232065e89c239f205d4b70ef676a8942a3db2b4d4c388613e35ef3fd",
    "raw": "",
    "root": "",
    "s": "0x2e009cad05f24fdef33f49558a590cec82d150942ce99e0290ddc7282ebbab5d",
    "status": "0x1",
    "timestamp": "2019-04-16T21:44:20.000Z",
    "to": [
      "0x2c7039efa647fc5ca1968c73a67aa6032789e719"
    ],
    "v": "37",
    "value": "110000000000000000",
    "price": {
      "value": {
        "currency": "usd",
        "quote": "167.231494236",
        "total": "18.39546436596000000000000000000" <- The value of the transfer
      }
    }
  }
}

If you look at their docs, any endpoint with includePrice option will do just that.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.