Skip to main content

a wrapper around osrs api's

Project description

The project

The goal is to make a wrapper around the various oldschool runescape api's.

osrs hiscores

import asyncio

from aiohttp import ClientSession

from osrs.async_api.osrs.hiscores import Mode, PlayerStats, Hiscore, RateLimiter
from osrs.exceptions import PlayerDoesNotExist


async def main():
    # 100 calls per minute
    limiter = RateLimiter(calls_per_interval=100, interval=60)
    hiscore_instance = Hiscore(proxy="", rate_limiter=limiter)
    
    async with ClientSession() as session:
        player_stats = await hiscore_instance.get(
            mode=Mode.OLDSCHOOL,
            player="extreme4all",
            session=session,
        )
        print(player_stats)


loop = asyncio.get_running_loop()
await loop.create_task(main())
import asyncio
from aiohttp import ClientSession
from osrs.async_api.osrs.itemdb import Mode, Catalogue, Graph, RateLimiter

async def main():
    # Initialize the Catalogue with optional proxy and rate limiter
    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_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_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 graph_instance.get_graph(
            session, 
            item_id=item_id, 
            mode=Mode.OLDSCHOOL
        )
        print("Trade History:", trade_history)

# Run the asynchronous main function
asyncio.run(main())

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

osrs-0.0.11.tar.gz (7.5 kB view details)

Uploaded Source

Built Distribution

osrs-0.0.11-py3-none-any.whl (8.1 kB view details)

Uploaded Python 3

File details

Details for the file osrs-0.0.11.tar.gz.

File metadata

  • Download URL: osrs-0.0.11.tar.gz
  • Upload date:
  • Size: 7.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/5.1.1 CPython/3.12.7

File hashes

Hashes for osrs-0.0.11.tar.gz
Algorithm Hash digest
SHA256 b352a5e71f44fc693267676a0244a177b69bd87567ac642351edf6cd61cfa33d
MD5 727c8ce8ab27eba29ea8a6b41e7b4fec
BLAKE2b-256 84e63d99bb107883c8993626a785111c87b28c0eed456f8e3e9162383d8aa820

See more details on using hashes here.

Provenance

File details

Details for the file osrs-0.0.11-py3-none-any.whl.

File metadata

  • Download URL: osrs-0.0.11-py3-none-any.whl
  • Upload date:
  • Size: 8.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/5.1.1 CPython/3.12.7

File hashes

Hashes for osrs-0.0.11-py3-none-any.whl
Algorithm Hash digest
SHA256 e1fb549f57667392756b1e6f087abc32b6b7748207168c6f070bfca6a8089ae1
MD5 c28a4dddfbd8cb5cfea0c3d7b4c30863
BLAKE2b-256 f2edfdf4cd414b1d7ae0bc66aa2596af80684c2d0f8e7df6f92d3823ea2cc98a

See more details on using hashes here.

Provenance

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page