-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathexample.py
More file actions
42 lines (34 loc) · 2.11 KB
/
example.py
File metadata and controls
42 lines (34 loc) · 2.11 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
import asyncio
from fixprice_api import FixPriceAPI
async def main():
async with FixPriceAPI() as api:
assert api is not None
# Catalog
tree = (await api.Catalog.tree()).json()
print(f"Первая категория: {tree[next(iter(tree))]['alias']}")
products_list = (await api.Catalog.products_list(category_alias=tree[next(iter(tree))]["alias"])).json()
print(f"Первый товар: {products_list[0]['title']}")
balance = (await api.Catalog.Products.balance(product_id=products_list[0]["id"])).json()
print(f"Первый баланс: {balance[0]['address']}; {balance[0]['count']} шт")
info = (await api.Catalog.Products.info(url=products_list[0]["url"])).json()
print(f"Информация о товаре: {info['title']}")
# Geolocation
first_country = (await api.Geolocation.countries_list()).json()
print(f"Первая страна: {first_country[0]['title']}")
regions = (await api.Geolocation.regions_list()).json()
print(f"Первый регион: {regions[0]['title']}")
cities = (await api.Geolocation.cities_list(country_id=first_country[1]["id"])).json()
print(f"Первый город: {cities[0]['name']}")
city_info = (await api.Geolocation.city_info(city_id=cities[0]["id"])).json()
print(f"Информация о городе: {city_info['name']} ({city_info['fiasid']})")
search = (await api.Geolocation.search(country_id=first_country[0]["id"], city_id=cities[0]["id"])).json()
print(f"Первый магазин: {search[0]['address']}")
# Advertising
home_brands = (await api.Advertising.home_brands_list()).json()
print(f"Первая рекламная запись: {home_brands[0]['title']} {home_brands[0]['updatedAt']}")
# General
# Загрузка изображения по прямой ссылке.
download_image = (await api.General.download_image(url=products_list[0]["images"][0]["src"])).image()
_ = download_image
if __name__ == "__main__":
asyncio.run(main())