Библиотека для работы с "api" сервиса bestchange.ru
Project description
BestChange API
Библиотека для работы с "api" сервиса bestchange.ru предоставит Вам возможность получить:
- курсы со всех направлений;
- валюты;
- обменные пункты;
- города;
- а так же кеширование всех этих данных.
Установка:
pip install bestchange-api
Пример использования:
from bestchange_api import BestChange
api = BestChange()
exchangers = api.exchangers().get()
dir_from = 93
dir_to = 42
rows = api.rates().filter(dir_from, dir_to)
title = 'Exchange rates in the direction (https://www.bestchange.ru/index.php?from={}&to={}) {} : {}'
print(title.format(dir_from, dir_to, api.currencies().get_by_id(dir_from), api.currencies().get_by_id(dir_to)))
for val in rows[:3]:
print('{} {}'.format(exchangers[val['exchange_id']]['name'], val))
Для обменных пунктов есть возможность сразу получить количество отзывов о них (работает, только если у обменника есть хоть одно направление на BestChange):
from bestchange_api import BestChange
api = BestChange(exchangers_reviews=True)
Все методы, реализованные на данный момент:
from bestchange_api import BestChange
api = BestChange(cache=True, cache_seconds=300, cache_path='/home/user/tmp/')
api.is_error() # Возвращает False, если данные успешно загружены, иначе текст ошибки
api.currencies().get() # Получить список всех валют
api.currencies().get_by_id(1) # Получить название или словарь определенной валюты
api.currencies().search_by_name('text') # Поиск валют по подстроке
api.exchangers().get() # Получить список всех обменных пунктов
api.exchangers().get_by_id(1) # Получить название или словарь обменного пункта
api.exchangers().search_by_name('text') # Поиск обменных пунктов по подстроке
api.cities().get() # Получить список всех городов
api.cities().get_by_id(1) # Получить название или словарь города
api.cities().search_by_name('text') # Поиск городов по подстроке
api.rates().filter(1, 2) # Возвращает курсы, отфильтрованный и отсортированных по направлению
# Раздел "Популярное"
currencies = api.currencies().get()
for val in api.top().get():
print(currencies[val['give_id']]['name'], '->', currencies[val['get_id']]['name'], ':', round(val['perc'], 2))
Работа с прокси:
from bestchange_api import BestChange
proxy = {'http': '127.0.0.1', 'https': '127.0.0.1'}
api = BestChange(proxy=proxy)
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file bestchange_api-3.1.0.0.tar.gz.
File metadata
- Download URL: bestchange_api-3.1.0.0.tar.gz
- Upload date:
- Size: 6.5 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.1 CPython/3.10.6
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
c52de9e97d8102bd57e1385ff97160508c7e5f8e5bb7429aa09188bb93dfdcfa
|
|
| MD5 |
a141c6733f33dfb9c4e5181d93ae1bcd
|
|
| BLAKE2b-256 |
af84d54a5257c23e6d953d84df62cce55530f1ff0d76e0c2f4f5ce7d1ddbf849
|
File details
Details for the file bestchange_api-3.1.0.0-py3-none-any.whl.
File metadata
- Download URL: bestchange_api-3.1.0.0-py3-none-any.whl
- Upload date:
- Size: 7.9 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.1 CPython/3.10.6
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
f7a8e4d8680aba8942548613821e659250333cb1ab0a7fa73407b30d72f9ae99
|
|
| MD5 |
c56d6f555a71cedf3b5733fc79f9da18
|
|
| BLAKE2b-256 |
d4259aa043fa52702e4f43a2eec6e010494646935459d86fbb15a598eabecf32
|