it isn't a bug the balance is returned in weis not in The Ethers.
chek one of many conversion tools: https://etherconverter.online/
268705.32703842675 Ether = 268705327038426745609145 wei
the ","
is used to separate three digits (look at the amount in $).
(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.
Best Answer
The Ethereum blockchain was designed to be entirely deterministic. This means, that if I took the whole history of the network, then replayed it on my computer, I should always end up with the correct state.
Since the internet is non-deterministic and changes over time, then every time I replayed all of the transactions on the network, I would receive a different answer.
Determinism is important so that nodes can come to a consensus. If there were a contract that required the number of upvotes on this question, the value could differ from time to time or even place to place, causing nodes in the future or without access to this site to reach different conclusions about the state of the network, thus breaking the consensus.
By requiring that every data input is initiated through an external transaction, we can be sure that the blockchain itself contains all of the information required to verify itself. This process of gathering off-chain data and then pasting it to the blockchain, is known as working with an oracle.
There are several oracle services which allow for a smart-contract to look like it's making an API call, however the oracle is actually making the API calls off-chain and posting the result on-chain for smart contracts to use. Some of these include Chainlink, Provable, BandChain, and Tellor.