Skip to main content

Python client for the OSRS Real-time Prices API

Project description

osrs-prices

A typed Python client for the OSRS Real-time Prices API.

Installation

pip install osrs-prices

# With pandas support
pip install osrs-prices[pandas]

Quick Start

from osrs_prices import Client

with Client(user_agent="my-app/1.0 contact@example.com") as client:
    # Get item metadata
    mapping = client.get_mapping()
    print(f"Loaded {len(mapping.items)} items")

    # Get latest prices
    latest = client.get_latest(item_id=4151)  # Abyssal whip
    whip = latest.data[4151]
    print(f"Abyssal whip: {whip.high:,} gp (instant-buy)")

    # Get price averages
    averages = client.get_5m_average()

    # Get historical data
    timeseries = client.get_timeseries(item_id=4151, timestep="1h")

DataFrame Support

Convert any response to a pandas DataFrame (requires pip install osrs-prices[pandas]):

from osrs_prices import Client
from osrs_prices.pandas import to_dataframe

with Client(user_agent="my-app/1.0") as client:
    mapping = client.get_mapping()
    df = to_dataframe(mapping)
    print(df.head())

API Reference

Client Methods

Method Description
get_latest(item_id=None) Current instant-buy/sell prices
get_mapping(force_refresh=False) Item metadata (cached 1 hour)
get_5m_average(timestamp=None) 5-minute price averages
get_1h_average(timestamp=None) 1-hour price averages
get_timeseries(item_id, timestep) Historical data (timestep: "5m", "1h", "6h", "24h")
get_item_by_name(name) Find item by exact name

Models

  • LatestPrice - Instant buy/sell prices with timestamps
  • AveragePrice - Average prices with volumes
  • ItemMapping - Item metadata (name, examine, alch values, etc.)
  • TimeseriesDataPoint - Historical price point

Exceptions

  • OSRSPricesError - Base exception
  • APIError - API returned an error
  • RateLimitError - Rate limit exceeded (429)
  • ValidationError - Invalid input (e.g., blocked user agent)

User-Agent Requirement

The API requires a descriptive User-Agent. Generic agents like python-requests are blocked. Use a format like:

my-app/1.0 contact@example.com

Development

# Install dependencies
uv sync

# Run tests
uv run pytest

# Run type checking
uv run mypy src/

# Run integration tests (hits real API)
uv run pytest -m integration

License

MIT

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_prices-1.0.0.tar.gz (7.7 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

osrs_prices-1.0.0-py3-none-any.whl (14.2 kB view details)

Uploaded Python 3

File details

Details for the file osrs_prices-1.0.0.tar.gz.

File metadata

  • Download URL: osrs_prices-1.0.0.tar.gz
  • Upload date:
  • Size: 7.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for osrs_prices-1.0.0.tar.gz
Algorithm Hash digest
SHA256 a45a817c05e28a860649c584f7ab9301d1d57ca85294c56aee950fc067f94c20
MD5 e05e5554c8d609186d3a81df506c2528
BLAKE2b-256 f4ff602abaf159f4fda14e963c0e8302788c5e44b79b364bef7f91614c0d8553

See more details on using hashes here.

Provenance

The following attestation bundles were made for osrs_prices-1.0.0.tar.gz:

Publisher: release-please.yml on mattflow/osrs-prices

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file osrs_prices-1.0.0-py3-none-any.whl.

File metadata

  • Download URL: osrs_prices-1.0.0-py3-none-any.whl
  • Upload date:
  • Size: 14.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for osrs_prices-1.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 6c46231862004bc16ab01792c9a353ff33112c05eba7e0b3980e58afe1528fb4
MD5 7a8f71f9ae4a93a9d83e58d79a7406e5
BLAKE2b-256 267d6a090ea773ea1e2dec8a2deeca943cc20c4e641dd9fa9c3c4083d318e750

See more details on using hashes here.

Provenance

The following attestation bundles were made for osrs_prices-1.0.0-py3-none-any.whl:

Publisher: release-please.yml on mattflow/osrs-prices

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

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