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 timestampsAveragePrice- Average prices with volumesItemMapping- Item metadata (name, examine, alch values, etc.)TimeseriesDataPoint- Historical price point
Exceptions
OSRSPricesError- Base exceptionAPIError- API returned an errorRateLimitError- 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
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
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
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
a45a817c05e28a860649c584f7ab9301d1d57ca85294c56aee950fc067f94c20
|
|
| MD5 |
e05e5554c8d609186d3a81df506c2528
|
|
| BLAKE2b-256 |
f4ff602abaf159f4fda14e963c0e8302788c5e44b79b364bef7f91614c0d8553
|
Provenance
The following attestation bundles were made for osrs_prices-1.0.0.tar.gz:
Publisher:
release-please.yml on mattflow/osrs-prices
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
osrs_prices-1.0.0.tar.gz -
Subject digest:
a45a817c05e28a860649c584f7ab9301d1d57ca85294c56aee950fc067f94c20 - Sigstore transparency entry: 898236321
- Sigstore integration time:
-
Permalink:
mattflow/osrs-prices@dcd5dcbe9305049de6d8697c16875fef30fa0e51 -
Branch / Tag:
refs/heads/main - Owner: https://github.com/mattflow
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release-please.yml@dcd5dcbe9305049de6d8697c16875fef30fa0e51 -
Trigger Event:
push
-
Statement type:
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
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
6c46231862004bc16ab01792c9a353ff33112c05eba7e0b3980e58afe1528fb4
|
|
| MD5 |
7a8f71f9ae4a93a9d83e58d79a7406e5
|
|
| BLAKE2b-256 |
267d6a090ea773ea1e2dec8a2deeca943cc20c4e641dd9fa9c3c4083d318e750
|
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
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
osrs_prices-1.0.0-py3-none-any.whl -
Subject digest:
6c46231862004bc16ab01792c9a353ff33112c05eba7e0b3980e58afe1528fb4 - Sigstore transparency entry: 898236349
- Sigstore integration time:
-
Permalink:
mattflow/osrs-prices@dcd5dcbe9305049de6d8697c16875fef30fa0e51 -
Branch / Tag:
refs/heads/main - Owner: https://github.com/mattflow
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release-please.yml@dcd5dcbe9305049de6d8697c16875fef30fa0e51 -
Trigger Event:
push
-
Statement type: