mirror of
https://github.com/bohd4nx/FragmentAPI.git
synced 2026-07-25 06:14:29 +00:00
chore: update examples and README for improved clarity and consistency; streamline print statements and descriptions
This commit is contained in:
@@ -8,6 +8,7 @@ Use next_offset for pagination.
|
||||
"""
|
||||
|
||||
import asyncio
|
||||
import json
|
||||
|
||||
from pyfragment import FragmentClient, GiftsResult
|
||||
|
||||
@@ -28,16 +29,10 @@ FILTER = "" # "", "auction", "sale", "sold" — or omit
|
||||
|
||||
async def main() -> None:
|
||||
async with FragmentClient(seed=SEED, api_key=API_KEY, cookies=COOKIES) as client:
|
||||
result: GiftsResult = await client.search_gifts(
|
||||
QUERY, collection=COLLECTION, sort=SORT, filter=FILTER
|
||||
)
|
||||
result: GiftsResult = await client.search_gifts(QUERY, collection=COLLECTION, sort=SORT, filter=FILTER)
|
||||
|
||||
print(f"Found {len(result.items)} result(s):")
|
||||
for item in result.items:
|
||||
price = f"{item['price']} TON" if item["price"] else "n/a"
|
||||
print(
|
||||
f" {item['name']:30s} {item['status'] or '':15s} {price:12s} {item['date'] or '—'}"
|
||||
)
|
||||
print(json.dumps(result.items, indent=2))
|
||||
|
||||
if result.next_offset:
|
||||
print(f"\nMore results available — next page offset: {result.next_offset}")
|
||||
|
||||
@@ -7,6 +7,7 @@ Use next_offset_id for pagination.
|
||||
"""
|
||||
|
||||
import asyncio
|
||||
import json
|
||||
|
||||
from pyfragment import FragmentClient, NumbersResult
|
||||
|
||||
@@ -26,21 +27,13 @@ FILTER = "" # "", "auction", "sale", "sold" — or omit
|
||||
|
||||
async def main() -> None:
|
||||
async with FragmentClient(seed=SEED, api_key=API_KEY, cookies=COOKIES) as client:
|
||||
result: NumbersResult = await client.search_numbers(
|
||||
QUERY, sort=SORT, filter=FILTER
|
||||
)
|
||||
result: NumbersResult = await client.search_numbers(QUERY, sort=SORT, filter=FILTER)
|
||||
|
||||
print(f"Found {len(result.items)} result(s):")
|
||||
for item in result.items:
|
||||
price = f"{item['price']} TON" if item["price"] else "n/a"
|
||||
print(
|
||||
f" {item['name']:20s} {item['status'] or '':15s} {price:10s} {item['date'] or '—'}"
|
||||
)
|
||||
print(json.dumps(result.items, indent=2))
|
||||
|
||||
if result.next_offset_id:
|
||||
print(
|
||||
f"\nMore results available — next page offset: {result.next_offset_id}"
|
||||
)
|
||||
print(f"\nMore results available — next page offset: {result.next_offset_id}")
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
|
||||
@@ -7,6 +7,7 @@ Use next_offset_id for pagination.
|
||||
"""
|
||||
|
||||
import asyncio
|
||||
import json
|
||||
|
||||
from pyfragment import FragmentClient, UsernamesResult
|
||||
|
||||
@@ -26,21 +27,13 @@ FILTER = "auction" # "", "auction", "sale", "sold" — or omit
|
||||
|
||||
async def main() -> None:
|
||||
async with FragmentClient(seed=SEED, api_key=API_KEY, cookies=COOKIES) as client:
|
||||
result: UsernamesResult = await client.search_usernames(
|
||||
QUERY, sort=SORT, filter=FILTER
|
||||
)
|
||||
result: UsernamesResult = await client.search_usernames(QUERY, sort=SORT, filter=FILTER)
|
||||
|
||||
print(f"Found {len(result.items)} result(s):")
|
||||
for item in result.items:
|
||||
price = f"{item['price']} TON" if item["price"] else "n/a"
|
||||
print(
|
||||
f" {item['name']:20s} {item['status'] or '':15s} {price:10s} {item['date'] or '—'}"
|
||||
)
|
||||
print(json.dumps(result.items, indent=2))
|
||||
|
||||
if result.next_offset_id:
|
||||
print(
|
||||
f"\nMore results available — next page offset: {result.next_offset_id}"
|
||||
)
|
||||
print(f"\nMore results available — next page offset: {result.next_offset_id}")
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
|
||||
Reference in New Issue
Block a user