Skip to content

Commit

Permalink
update documentation & increase version
Browse files Browse the repository at this point in the history
  • Loading branch information
extreme4all committed Oct 27, 2024
1 parent 0e81b11 commit 150c5b5
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 6 deletions.
26 changes: 21 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,27 +31,43 @@ await loop.create_task(main())
```py
import asyncio
from aiohttp import ClientSession
from osrs.catalogue import Catalogue, Mode # Assuming this is the file/module name for your code
from osrs.async_api.osrs.itemdb import Mode, Catalogue, Graph, RateLimiter

async def main():
# Initialize the Catalogue with optional proxy and rate limiter
catalogue = Catalogue(proxy="")
limiter = RateLimiter(calls_per_interval=100, interval=60)
catalogue_instance = Catalogue(proxy="", rate_limiter=limiter)
graph_instance = Graph(proxy="", rate_limiter=limiter)

async with ClientSession() as session:
# Example 1: Fetching items by alphabetical filter
alpha = "A" # Items starting with "A"
page = 1 # First page of results
category = 1 # Category identifier, for OSRS there is only 1 category
items = await catalogue.get_items(session, alpha=alpha, page=page, mode=Mode.OLDSCHOOL, category=category)
items = await catalogue_instance.get_items(
session,
alpha=alpha,
page=page,
mode=Mode.OLDSCHOOL,
category=category
)
print("Fetched Items:", items)

# Example 2: Fetching detailed information for a specific item
item_id = 4151 # Example item ID (Abyssal whip in OSRS)
item_detail = await catalogue.get_detail(session, item_id=item_id, mode=Mode.OLDSCHOOL)
item_detail = await catalogue_instance.get_detail(
session,
item_id=item_id,
mode=Mode.OLDSCHOOL
)
print("Item Detail:", item_detail)

# Example 3: Fetching historical trade data (price graph) for a specific item
trade_history = await catalogue.get_graph(session, item_id=item_id, mode=Mode.OLDSCHOOL)
trade_history = await graph_instance.get_graph(
session,
item_id=item_id,
mode=Mode.OLDSCHOOL
)
print("Trade History:", trade_history)

# Run the asynchronous main function
Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[project]
name = "osrs"
version = "0.0.10"
version = "0.0.11"
authors = [
{ name="extreme4all"},
]
Expand Down

0 comments on commit 150c5b5

Please sign in to comment.