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")

Enriched Responses

Combine price data with item metadata in a single call:

from osrs_prices import Client

with Client(user_agent="my-app/1.0") as client:
    # Get prices with item names, limits, alch values, etc.
    enriched = client.get_latest_with_mapping()
    for item in enriched.items:
        print(f"{item.name}: {item.high} gp (limit: {item.limit})")

    # Or enrich an existing response
    latest = client.get_latest()
    enriched = client.enrich(latest)

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
get_latest_with_mapping(item_id=None) Latest prices with item metadata
get_5m_average_with_mapping(timestamp=None) 5-minute averages with item metadata
get_1h_average_with_mapping(timestamp=None) 1-hour averages with item metadata
get_timeseries_with_mapping(item_id, timestep) Timeseries with item metadata
enrich(response) Add item metadata to an existing response

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
  • EnrichedLatestPrice - Latest price combined with item metadata
  • EnrichedAveragePrice - Average price combined with item metadata
  • EnrichedTimeseriesResponse - Timeseries with item metadata attached

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 --all-extras

# 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.1.0.tar.gz (9.5 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.1.0-py3-none-any.whl (16.5 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: osrs_prices-1.1.0.tar.gz
  • Upload date:
  • Size: 9.5 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.1.0.tar.gz
Algorithm Hash digest
SHA256 d187118c15c3e83a7f347498c90f4deb56c4dbd29ba8d27c26e34b1f1daeb233
MD5 8559267346437874f91eaf824eadfbcf
BLAKE2b-256 d810723dd1d70d0176530fb53d10a6a5204a7f5fb93d7708b35fd1ff466b7d81

See more details on using hashes here.

Provenance

The following attestation bundles were made for osrs_prices-1.1.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.1.0-py3-none-any.whl.

File metadata

  • Download URL: osrs_prices-1.1.0-py3-none-any.whl
  • Upload date:
  • Size: 16.5 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.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 a1c2f6bdd4aa95227ca1c09ae16f8e5496be9fe37e6e2c501f9f4d5c90d1c7b2
MD5 5a70d48776d2c2ca170dc1dc1d804d53
BLAKE2b-256 58917fa50ad1d549ebdff54e212354008077abd7244ae8f3f7b00bfd57e38354

See more details on using hashes here.

Provenance

The following attestation bundles were made for osrs_prices-1.1.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