V
V
Viktor Vedernikov2021-02-08 23:31:18
Python
Viktor Vedernikov, 2021-02-08 23:31:18

How to use API in python for parsing?

There is an open API, it gives access to updated information from the game about the exchange rate for gold. I am new to programming and would like to write a program in python that would help me find out every 2-3 minutes how much the price has increased or fallen relative to the average per day. Help good people. Here is the site itself with this API

Answer the question

In order to leave comments, you need to log in

1 answer(s)
S
Sergey Karbivnichy, 2021-02-09
@Durik921

There api is simple, like 2 kopecks.
Here is an example of how to get the gold price:

import requests
import json

url = 'https://www.albion-online-data.com/api/v2/stats/Gold'

response = requests.get(url)
json_data = json.loads(response.text)

for data in json_data:
  price = data['price']
  timestamp = data['timestamp']
  print(f'Дата: {timestamp} - Цена: {price}')

Дата: 2021-01-09T21:00:00 - Цена: 3007
Дата: 2021-01-09T22:00:00 - Цена: 3006
Дата: 2021-01-09T23:00:00 - Цена: 3004
Дата: 2021-01-10T00:00:00 - Цена: 3003
Много много много строк
...
...
...
...

PS: I don't know what kind of game this is and what this api means. If you play this game, then I think it's easier for you to figure it out.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question