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)

# Run the asynchronous main function
if __name__ == "__main__":
    asyncio.run(main())

osrs itemdb (Catalogue & Grand Exchange)

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
        item_id = 4151  # Example item ID (Abyssal whip in OSRS)
        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
if __name__ == "__main__":
    asyncio.run(main())
import asyncio
from aiohttp import ClientSession
from osrs.async_api.wiki.prices import WikiPrices, AveragePrices, LatestPrices, TimeSeries, ItemMapping

async def main():
    wiki_prices_instance = WikiPrices(user_agent="Your User Agent")

    async with ClientSession() as session:
        # Fetch item mappings
        mappings = await wiki_prices_instance.get_mapping(session=session)
        print("Item Mappings:", mappings)

        # Fetch latest prices
        latest_prices = await wiki_prices_instance.get_latest_prices(session=session)
        print("Latest Prices:", latest_prices)

        # Fetch average prices
        average_prices = await wiki_prices_instance.get_average_prices(session=session, interval=Interval.FIVE_MIN)
        print("Average Prices:", average_prices)

        # Fetch time series data
        item_id = 4151  # Example item ID (Abyssal whip in OSRS)
        time_series = await wiki_prices_instance.get_time_series(session=session, item_id=item_id, timestep=Interval.ONE_HOUR)
        print("Time Series Data:", time_series)

# Run the asynchronous main function
if __name__ == "__main__":
    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.12.tar.gz (9.9 kB view details)

Uploaded Source

Built Distribution

osrs-0.0.12-py3-none-any.whl (10.5 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: osrs-0.0.12.tar.gz
  • Upload date:
  • Size: 9.9 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.12.tar.gz
Algorithm Hash digest
SHA256 3b35b2286e8aa95679481596bafaa83186edbbe0fb903516680473a6943dbdba
MD5 0124d5537618e2b950412ce73c8859f5
BLAKE2b-256 ba40ed62511c264e874d23c927df5b01034ac84081326591e3555b021685bbb6

See more details on using hashes here.

Provenance

File details

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

File metadata

  • Download URL: osrs-0.0.12-py3-none-any.whl
  • Upload date:
  • Size: 10.5 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.12-py3-none-any.whl
Algorithm Hash digest
SHA256 56538a726ac93c15590a562ed35d40fb2e0c42633dd8de062d2ab72b22ad9784
MD5 853e087c8d0159d95bc08b0de376e066
BLAKE2b-256 a8a06c748ffaa14db5f5149c49ce3daaa76cbda7c02e98a699c69c90b4ed6f2c

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