I’m working with an API that returns large integer values, but these values need to be displayed with a decimal point in a specific format on a website. I need help figuring out how to determine where the decimal point should be placed in these numbers.
For context I am making requests to an API that provides numbers without explicit decimal points. For example, the API might return a number like 98388300, but the website displays it as 0.0983883. It seems that the number 98388300 is being converted to 0.0983883 by placing the decimal point at a specific position.
This is the link to the website that I am trying to scrape data from
This is the command that I am using to get the data in the response.json file.
curl 'https://avascan.info/api/private/pvm/11111111111111111111111111111111LpoYY/address/P-avax1tahtyeq7x5pjumt3dp295ew5qj4ncp0n8ckt95/transactions?ecosystem=avalanche&limit=5000&count=true'
-H 'accept: */*'
-H 'accept-language: en-US,en;q=0.9'
-H 'baggage: sentry-environment=Production,sentry-release=XNHfD48t5Ptgw5yi8mzwj,sentry-public_key=c95b071724ef4f48aeca803b7e5873ec,sentry-trace_id=25e9673bbf0b4ca880788ab1d1173895,sentry-sample_rate=0.1,sentry-transaction=%2Fblockchain%2F%5Bchain%5D%2Faddress%2F%5Baddress%5D%2Ftransactions,sentry-sampled=false'
-H 'content-type: application/json'
-H 'cookie: routescan_api_jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpYXQiOjE3MjM5OTQyOTIsImV4cCI6MTcyNDE2NzA5MiwiaXNzIjoiUm91dGVzY2FuQXBpIiwic3ViIjoiOTkuMjI4LjE4LjE3OCJ9.GSmyimdE4ri8Dgf8nrMM6l79BUVPG6sG7nrS6lEVYDc'
-H 'priority: u=1, i'
-H 'referer: https://avascan.info/blockchain/p/address/P-avax1tahtyeq7x5pjumt3dp295ew5qj4ncp0n8ckt95/transactions'
-H 'sec-ch-ua: "Not)A;Brand";v="99", "Google Chrome";v="127", "Chromium";v="127"'
-H 'sec-ch-ua-mobile: ?0'
-H 'sec-ch-ua-platform: "Windows"'
-H 'sec-fetch-dest: empty'
-H 'sec-fetch-mode: cors'
-H 'sec-fetch-site: same-origin'
-H 'sentry-trace: 4914182e6b944763a9eebcf005dcde8b-823be275835b10d3-1'
-H 'user-agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/127.0.0.0 Safari/537.36' -o response.json
Here is a picture of the first row in the table: First row of table
The website value is 0.004367608 but it’s different in the JSON data snippet of the JSON data.
Here are more examples:
Website | JSON |
---|---|
0.004367608 | 4367608 |
0.0983883 | 98388300 |
0.001379072 | 1379072 |
3.361598801 | 3361598801 |
0.007819765 | 7819765 |
In all these cases, the decimal point is shifted either to the left or right. Since the decimal placement varies with each value, I assume there must be some indicator in the JSON data that specifies how far and in which direction the decimal should be moved. However, I’m unable to locate this information in the API response.
I initially attempted to use Selenium for this problem but realized that I might be able to retrieve all the necessary data with a single API request.
I have been searching for a value in the JSON data that would indicate how to adjust the decimal point, but I haven’t been able to locate it. Additionally, I searched for similar questions on this platform but couldn’t find any relevant information.
Gurple is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.