Models¶
Pydantic models for API responses.
Price Models¶
osrs_prices.LatestPrice
pydantic-model
¶
Bases: OSRSBaseModel
Current instant-buy and instant-sell prices for an item.
Show JSON schema:
{
"description": "Current instant-buy and instant-sell prices for an item.",
"properties": {
"high": {
"anyOf": [
{
"type": "integer"
},
{
"type": "null"
}
],
"default": null,
"title": "High"
},
"highTime": {
"anyOf": [
{
"type": "integer"
},
{
"type": "null"
}
],
"default": null,
"title": "Hightime"
},
"low": {
"anyOf": [
{
"type": "integer"
},
{
"type": "null"
}
],
"default": null,
"title": "Low"
},
"lowTime": {
"anyOf": [
{
"type": "integer"
},
{
"type": "null"
}
],
"default": null,
"title": "Lowtime"
}
},
"title": "LatestPrice",
"type": "object"
}
Config:
frozen:Trueextra:ignorepopulate_by_name:True
Fields:
-
high(int | None) -
high_time(int | None) -
low(int | None) -
low_time(int | None)
osrs_prices.LatestResponse
pydantic-model
¶
Bases: OSRSBaseModel
Response from the /latest endpoint.
Show JSON schema:
{
"$defs": {
"LatestPrice": {
"description": "Current instant-buy and instant-sell prices for an item.",
"properties": {
"high": {
"anyOf": [
{
"type": "integer"
},
{
"type": "null"
}
],
"default": null,
"title": "High"
},
"highTime": {
"anyOf": [
{
"type": "integer"
},
{
"type": "null"
}
],
"default": null,
"title": "Hightime"
},
"low": {
"anyOf": [
{
"type": "integer"
},
{
"type": "null"
}
],
"default": null,
"title": "Low"
},
"lowTime": {
"anyOf": [
{
"type": "integer"
},
{
"type": "null"
}
],
"default": null,
"title": "Lowtime"
}
},
"title": "LatestPrice",
"type": "object"
}
},
"description": "Response from the /latest endpoint.",
"properties": {
"data": {
"additionalProperties": {
"$ref": "#/$defs/LatestPrice"
},
"title": "Data",
"type": "object"
}
},
"title": "LatestResponse",
"type": "object"
}
Fields:
-
data(dict[int, LatestPrice])
from_api
classmethod
¶
from_api(data: dict[str, Any]) -> LatestResponse
Create a LatestResponse from API data.
The API returns {"data": {"item_id": {...}, ...}}. Item IDs are strings in the JSON but we convert to int.
osrs_prices.AveragePrice
pydantic-model
¶
Bases: OSRSBaseModel
Average price data over a time period (5-minute or 1-hour).
Show JSON schema:
{
"description": "Average price data over a time period (5-minute or 1-hour).",
"properties": {
"avgHighPrice": {
"anyOf": [
{
"type": "integer"
},
{
"type": "null"
}
],
"default": null,
"title": "Avghighprice"
},
"highPriceVolume": {
"anyOf": [
{
"type": "integer"
},
{
"type": "null"
}
],
"default": null,
"title": "Highpricevolume"
},
"avgLowPrice": {
"anyOf": [
{
"type": "integer"
},
{
"type": "null"
}
],
"default": null,
"title": "Avglowprice"
},
"lowPriceVolume": {
"anyOf": [
{
"type": "integer"
},
{
"type": "null"
}
],
"default": null,
"title": "Lowpricevolume"
}
},
"title": "AveragePrice",
"type": "object"
}
Fields:
-
avg_high_price(int | None) -
high_price_volume(int | None) -
avg_low_price(int | None) -
low_price_volume(int | None)
osrs_prices.AverageResponse
pydantic-model
¶
Bases: OSRSBaseModel
Response from the /5m or /1h endpoints.
Show JSON schema:
{
"$defs": {
"AveragePrice": {
"description": "Average price data over a time period (5-minute or 1-hour).",
"properties": {
"avgHighPrice": {
"anyOf": [
{
"type": "integer"
},
{
"type": "null"
}
],
"default": null,
"title": "Avghighprice"
},
"highPriceVolume": {
"anyOf": [
{
"type": "integer"
},
{
"type": "null"
}
],
"default": null,
"title": "Highpricevolume"
},
"avgLowPrice": {
"anyOf": [
{
"type": "integer"
},
{
"type": "null"
}
],
"default": null,
"title": "Avglowprice"
},
"lowPriceVolume": {
"anyOf": [
{
"type": "integer"
},
{
"type": "null"
}
],
"default": null,
"title": "Lowpricevolume"
}
},
"title": "AveragePrice",
"type": "object"
}
},
"description": "Response from the /5m or /1h endpoints.",
"properties": {
"data": {
"additionalProperties": {
"$ref": "#/$defs/AveragePrice"
},
"title": "Data",
"type": "object"
},
"timestamp": {
"title": "Timestamp",
"type": "integer"
}
},
"required": [
"timestamp"
],
"title": "AverageResponse",
"type": "object"
}
Fields:
-
data(dict[int, AveragePrice]) -
timestamp(int)
from_api
classmethod
¶
from_api(data: dict[str, Any]) -> AverageResponse
Create an AverageResponse from API data.
The API returns {"data": {"item_id": {...}, ...}, "timestamp": ...}.
Item Models¶
osrs_prices.ItemMapping
pydantic-model
¶
Bases: OSRSBaseModel
Represents metadata for a single item.
Show JSON schema:
{
"description": "Represents metadata for a single item.",
"properties": {
"id": {
"title": "Id",
"type": "integer"
},
"name": {
"title": "Name",
"type": "string"
},
"examine": {
"anyOf": [
{
"type": "string"
},
{
"type": "null"
}
],
"default": null,
"title": "Examine"
},
"members": {
"title": "Members",
"type": "boolean"
},
"lowalch": {
"anyOf": [
{
"type": "integer"
},
{
"type": "null"
}
],
"default": null,
"title": "Lowalch"
},
"highalch": {
"anyOf": [
{
"type": "integer"
},
{
"type": "null"
}
],
"default": null,
"title": "Highalch"
},
"limit": {
"anyOf": [
{
"type": "integer"
},
{
"type": "null"
}
],
"default": null,
"title": "Limit"
},
"value": {
"anyOf": [
{
"type": "integer"
},
{
"type": "null"
}
],
"default": null,
"title": "Value"
},
"icon": {
"title": "Icon",
"type": "string"
}
},
"required": [
"id",
"name",
"members",
"icon"
],
"title": "ItemMapping",
"type": "object"
}
Fields:
-
id(int) -
name(str) -
examine(str | None) -
members(bool) -
lowalch(int | None) -
highalch(int | None) -
limit(int | None) -
value(int | None) -
icon(str)
osrs_prices.MappingResponse
pydantic-model
¶
Bases: OSRSBaseModel
Response from the /mapping endpoint.
Show JSON schema:
{
"$defs": {
"ItemMapping": {
"description": "Represents metadata for a single item.",
"properties": {
"id": {
"title": "Id",
"type": "integer"
},
"name": {
"title": "Name",
"type": "string"
},
"examine": {
"anyOf": [
{
"type": "string"
},
{
"type": "null"
}
],
"default": null,
"title": "Examine"
},
"members": {
"title": "Members",
"type": "boolean"
},
"lowalch": {
"anyOf": [
{
"type": "integer"
},
{
"type": "null"
}
],
"default": null,
"title": "Lowalch"
},
"highalch": {
"anyOf": [
{
"type": "integer"
},
{
"type": "null"
}
],
"default": null,
"title": "Highalch"
},
"limit": {
"anyOf": [
{
"type": "integer"
},
{
"type": "null"
}
],
"default": null,
"title": "Limit"
},
"value": {
"anyOf": [
{
"type": "integer"
},
{
"type": "null"
}
],
"default": null,
"title": "Value"
},
"icon": {
"title": "Icon",
"type": "string"
}
},
"required": [
"id",
"name",
"members",
"icon"
],
"title": "ItemMapping",
"type": "object"
}
},
"description": "Response from the /mapping endpoint.",
"properties": {
"items": {
"items": {
"$ref": "#/$defs/ItemMapping"
},
"title": "Items",
"type": "array"
}
},
"title": "MappingResponse",
"type": "object"
}
Fields:
-
items(list[ItemMapping])
from_list
classmethod
¶
from_list(data: list[dict[str, Any]]) -> MappingResponse
Create a MappingResponse from a list of item dicts.
The API returns a raw list, not a wrapped object.
Timeseries Models¶
osrs_prices.TimeseriesDataPoint
pydantic-model
¶
Bases: OSRSBaseModel
A single data point in a timeseries.
Show JSON schema:
{
"description": "A single data point in a timeseries.",
"properties": {
"timestamp": {
"title": "Timestamp",
"type": "integer"
},
"avgHighPrice": {
"anyOf": [
{
"type": "integer"
},
{
"type": "null"
}
],
"default": null,
"title": "Avghighprice"
},
"avgLowPrice": {
"anyOf": [
{
"type": "integer"
},
{
"type": "null"
}
],
"default": null,
"title": "Avglowprice"
},
"highPriceVolume": {
"anyOf": [
{
"type": "integer"
},
{
"type": "null"
}
],
"default": null,
"title": "Highpricevolume"
},
"lowPriceVolume": {
"anyOf": [
{
"type": "integer"
},
{
"type": "null"
}
],
"default": null,
"title": "Lowpricevolume"
}
},
"required": [
"timestamp"
],
"title": "TimeseriesDataPoint",
"type": "object"
}
Fields:
-
timestamp(int) -
avg_high_price(int | None) -
avg_low_price(int | None) -
high_price_volume(int | None) -
low_price_volume(int | None)
osrs_prices.TimeseriesResponse
pydantic-model
¶
Bases: OSRSBaseModel
Response from the /timeseries endpoint.
Show JSON schema:
{
"$defs": {
"TimeseriesDataPoint": {
"description": "A single data point in a timeseries.",
"properties": {
"timestamp": {
"title": "Timestamp",
"type": "integer"
},
"avgHighPrice": {
"anyOf": [
{
"type": "integer"
},
{
"type": "null"
}
],
"default": null,
"title": "Avghighprice"
},
"avgLowPrice": {
"anyOf": [
{
"type": "integer"
},
{
"type": "null"
}
],
"default": null,
"title": "Avglowprice"
},
"highPriceVolume": {
"anyOf": [
{
"type": "integer"
},
{
"type": "null"
}
],
"default": null,
"title": "Highpricevolume"
},
"lowPriceVolume": {
"anyOf": [
{
"type": "integer"
},
{
"type": "null"
}
],
"default": null,
"title": "Lowpricevolume"
}
},
"required": [
"timestamp"
],
"title": "TimeseriesDataPoint",
"type": "object"
}
},
"description": "Response from the /timeseries endpoint.",
"properties": {
"item_id": {
"anyOf": [
{
"type": "integer"
},
{
"type": "null"
}
],
"default": null,
"title": "Item Id"
},
"data": {
"items": {
"$ref": "#/$defs/TimeseriesDataPoint"
},
"title": "Data",
"type": "array"
}
},
"title": "TimeseriesResponse",
"type": "object"
}
Fields:
-
item_id(int | None) -
data(list[TimeseriesDataPoint])
from_api
classmethod
¶
from_api(
data: dict[str, Any], item_id: int | None = None
) -> TimeseriesResponse
Create a TimeseriesResponse from API data.
The API returns {"data": [{...}, ...]}.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
data
|
dict[str, Any]
|
The raw API response data. |
required |
item_id
|
int | None
|
The item ID this timeseries is for. |
None
|
Enriched Models¶
These models combine price data with item metadata for convenience.
osrs_prices.EnrichedLatestPrice
pydantic-model
¶
Bases: EnrichedItemBase
Latest price combined with item metadata.
Show JSON schema:
{
"description": "Latest price combined with item metadata.",
"properties": {
"id": {
"title": "Id",
"type": "integer"
},
"name": {
"title": "Name",
"type": "string"
},
"examine": {
"anyOf": [
{
"type": "string"
},
{
"type": "null"
}
],
"default": null,
"title": "Examine"
},
"members": {
"title": "Members",
"type": "boolean"
},
"lowalch": {
"anyOf": [
{
"type": "integer"
},
{
"type": "null"
}
],
"default": null,
"title": "Lowalch"
},
"highalch": {
"anyOf": [
{
"type": "integer"
},
{
"type": "null"
}
],
"default": null,
"title": "Highalch"
},
"limit": {
"anyOf": [
{
"type": "integer"
},
{
"type": "null"
}
],
"default": null,
"title": "Limit"
},
"value": {
"anyOf": [
{
"type": "integer"
},
{
"type": "null"
}
],
"default": null,
"title": "Value"
},
"icon": {
"title": "Icon",
"type": "string"
},
"high": {
"anyOf": [
{
"type": "integer"
},
{
"type": "null"
}
],
"default": null,
"title": "High"
},
"high_time": {
"anyOf": [
{
"type": "integer"
},
{
"type": "null"
}
],
"default": null,
"title": "High Time"
},
"low": {
"anyOf": [
{
"type": "integer"
},
{
"type": "null"
}
],
"default": null,
"title": "Low"
},
"low_time": {
"anyOf": [
{
"type": "integer"
},
{
"type": "null"
}
],
"default": null,
"title": "Low Time"
}
},
"required": [
"id",
"name",
"members",
"icon"
],
"title": "EnrichedLatestPrice",
"type": "object"
}
Fields:
-
id(int) -
name(str) -
examine(str | None) -
members(bool) -
lowalch(int | None) -
highalch(int | None) -
limit(int | None) -
value(int | None) -
icon(str) -
high(int | None) -
high_time(int | None) -
low(int | None) -
low_time(int | None)
osrs_prices.EnrichedLatestResponse
pydantic-model
¶
Bases: OSRSBaseModel
Response containing latest prices enriched with item metadata.
Show JSON schema:
{
"$defs": {
"EnrichedLatestPrice": {
"description": "Latest price combined with item metadata.",
"properties": {
"id": {
"title": "Id",
"type": "integer"
},
"name": {
"title": "Name",
"type": "string"
},
"examine": {
"anyOf": [
{
"type": "string"
},
{
"type": "null"
}
],
"default": null,
"title": "Examine"
},
"members": {
"title": "Members",
"type": "boolean"
},
"lowalch": {
"anyOf": [
{
"type": "integer"
},
{
"type": "null"
}
],
"default": null,
"title": "Lowalch"
},
"highalch": {
"anyOf": [
{
"type": "integer"
},
{
"type": "null"
}
],
"default": null,
"title": "Highalch"
},
"limit": {
"anyOf": [
{
"type": "integer"
},
{
"type": "null"
}
],
"default": null,
"title": "Limit"
},
"value": {
"anyOf": [
{
"type": "integer"
},
{
"type": "null"
}
],
"default": null,
"title": "Value"
},
"icon": {
"title": "Icon",
"type": "string"
},
"high": {
"anyOf": [
{
"type": "integer"
},
{
"type": "null"
}
],
"default": null,
"title": "High"
},
"high_time": {
"anyOf": [
{
"type": "integer"
},
{
"type": "null"
}
],
"default": null,
"title": "High Time"
},
"low": {
"anyOf": [
{
"type": "integer"
},
{
"type": "null"
}
],
"default": null,
"title": "Low"
},
"low_time": {
"anyOf": [
{
"type": "integer"
},
{
"type": "null"
}
],
"default": null,
"title": "Low Time"
}
},
"required": [
"id",
"name",
"members",
"icon"
],
"title": "EnrichedLatestPrice",
"type": "object"
}
},
"description": "Response containing latest prices enriched with item metadata.",
"properties": {
"items": {
"items": {
"$ref": "#/$defs/EnrichedLatestPrice"
},
"title": "Items",
"type": "array"
}
},
"required": [
"items"
],
"title": "EnrichedLatestResponse",
"type": "object"
}
Fields:
-
items(list[EnrichedLatestPrice])
osrs_prices.EnrichedAveragePrice
pydantic-model
¶
Bases: EnrichedItemBase
Average price combined with item metadata.
Show JSON schema:
{
"description": "Average price combined with item metadata.",
"properties": {
"id": {
"title": "Id",
"type": "integer"
},
"name": {
"title": "Name",
"type": "string"
},
"examine": {
"anyOf": [
{
"type": "string"
},
{
"type": "null"
}
],
"default": null,
"title": "Examine"
},
"members": {
"title": "Members",
"type": "boolean"
},
"lowalch": {
"anyOf": [
{
"type": "integer"
},
{
"type": "null"
}
],
"default": null,
"title": "Lowalch"
},
"highalch": {
"anyOf": [
{
"type": "integer"
},
{
"type": "null"
}
],
"default": null,
"title": "Highalch"
},
"limit": {
"anyOf": [
{
"type": "integer"
},
{
"type": "null"
}
],
"default": null,
"title": "Limit"
},
"value": {
"anyOf": [
{
"type": "integer"
},
{
"type": "null"
}
],
"default": null,
"title": "Value"
},
"icon": {
"title": "Icon",
"type": "string"
},
"avg_high_price": {
"anyOf": [
{
"type": "integer"
},
{
"type": "null"
}
],
"default": null,
"title": "Avg High Price"
},
"high_price_volume": {
"anyOf": [
{
"type": "integer"
},
{
"type": "null"
}
],
"default": null,
"title": "High Price Volume"
},
"avg_low_price": {
"anyOf": [
{
"type": "integer"
},
{
"type": "null"
}
],
"default": null,
"title": "Avg Low Price"
},
"low_price_volume": {
"anyOf": [
{
"type": "integer"
},
{
"type": "null"
}
],
"default": null,
"title": "Low Price Volume"
}
},
"required": [
"id",
"name",
"members",
"icon"
],
"title": "EnrichedAveragePrice",
"type": "object"
}
Fields:
-
id(int) -
name(str) -
examine(str | None) -
members(bool) -
lowalch(int | None) -
highalch(int | None) -
limit(int | None) -
value(int | None) -
icon(str) -
avg_high_price(int | None) -
high_price_volume(int | None) -
avg_low_price(int | None) -
low_price_volume(int | None)
osrs_prices.EnrichedAverageResponse
pydantic-model
¶
Bases: OSRSBaseModel
Response containing average prices enriched with item metadata.
Show JSON schema:
{
"$defs": {
"EnrichedAveragePrice": {
"description": "Average price combined with item metadata.",
"properties": {
"id": {
"title": "Id",
"type": "integer"
},
"name": {
"title": "Name",
"type": "string"
},
"examine": {
"anyOf": [
{
"type": "string"
},
{
"type": "null"
}
],
"default": null,
"title": "Examine"
},
"members": {
"title": "Members",
"type": "boolean"
},
"lowalch": {
"anyOf": [
{
"type": "integer"
},
{
"type": "null"
}
],
"default": null,
"title": "Lowalch"
},
"highalch": {
"anyOf": [
{
"type": "integer"
},
{
"type": "null"
}
],
"default": null,
"title": "Highalch"
},
"limit": {
"anyOf": [
{
"type": "integer"
},
{
"type": "null"
}
],
"default": null,
"title": "Limit"
},
"value": {
"anyOf": [
{
"type": "integer"
},
{
"type": "null"
}
],
"default": null,
"title": "Value"
},
"icon": {
"title": "Icon",
"type": "string"
},
"avg_high_price": {
"anyOf": [
{
"type": "integer"
},
{
"type": "null"
}
],
"default": null,
"title": "Avg High Price"
},
"high_price_volume": {
"anyOf": [
{
"type": "integer"
},
{
"type": "null"
}
],
"default": null,
"title": "High Price Volume"
},
"avg_low_price": {
"anyOf": [
{
"type": "integer"
},
{
"type": "null"
}
],
"default": null,
"title": "Avg Low Price"
},
"low_price_volume": {
"anyOf": [
{
"type": "integer"
},
{
"type": "null"
}
],
"default": null,
"title": "Low Price Volume"
}
},
"required": [
"id",
"name",
"members",
"icon"
],
"title": "EnrichedAveragePrice",
"type": "object"
}
},
"description": "Response containing average prices enriched with item metadata.",
"properties": {
"items": {
"items": {
"$ref": "#/$defs/EnrichedAveragePrice"
},
"title": "Items",
"type": "array"
},
"timestamp": {
"title": "Timestamp",
"type": "integer"
}
},
"required": [
"items",
"timestamp"
],
"title": "EnrichedAverageResponse",
"type": "object"
}
Fields:
-
items(list[EnrichedAveragePrice]) -
timestamp(int)
osrs_prices.EnrichedTimeseriesResponse
pydantic-model
¶
Bases: OSRSBaseModel
Timeseries response with item metadata attached.
Show JSON schema:
{
"$defs": {
"ItemMapping": {
"description": "Represents metadata for a single item.",
"properties": {
"id": {
"title": "Id",
"type": "integer"
},
"name": {
"title": "Name",
"type": "string"
},
"examine": {
"anyOf": [
{
"type": "string"
},
{
"type": "null"
}
],
"default": null,
"title": "Examine"
},
"members": {
"title": "Members",
"type": "boolean"
},
"lowalch": {
"anyOf": [
{
"type": "integer"
},
{
"type": "null"
}
],
"default": null,
"title": "Lowalch"
},
"highalch": {
"anyOf": [
{
"type": "integer"
},
{
"type": "null"
}
],
"default": null,
"title": "Highalch"
},
"limit": {
"anyOf": [
{
"type": "integer"
},
{
"type": "null"
}
],
"default": null,
"title": "Limit"
},
"value": {
"anyOf": [
{
"type": "integer"
},
{
"type": "null"
}
],
"default": null,
"title": "Value"
},
"icon": {
"title": "Icon",
"type": "string"
}
},
"required": [
"id",
"name",
"members",
"icon"
],
"title": "ItemMapping",
"type": "object"
},
"TimeseriesDataPoint": {
"description": "A single data point in a timeseries.",
"properties": {
"timestamp": {
"title": "Timestamp",
"type": "integer"
},
"avgHighPrice": {
"anyOf": [
{
"type": "integer"
},
{
"type": "null"
}
],
"default": null,
"title": "Avghighprice"
},
"avgLowPrice": {
"anyOf": [
{
"type": "integer"
},
{
"type": "null"
}
],
"default": null,
"title": "Avglowprice"
},
"highPriceVolume": {
"anyOf": [
{
"type": "integer"
},
{
"type": "null"
}
],
"default": null,
"title": "Highpricevolume"
},
"lowPriceVolume": {
"anyOf": [
{
"type": "integer"
},
{
"type": "null"
}
],
"default": null,
"title": "Lowpricevolume"
}
},
"required": [
"timestamp"
],
"title": "TimeseriesDataPoint",
"type": "object"
}
},
"description": "Timeseries response with item metadata attached.",
"properties": {
"item": {
"$ref": "#/$defs/ItemMapping"
},
"data": {
"items": {
"$ref": "#/$defs/TimeseriesDataPoint"
},
"title": "Data",
"type": "array"
}
},
"required": [
"item",
"data"
],
"title": "EnrichedTimeseriesResponse",
"type": "object"
}
Fields:
-
item(ItemMapping) -
data(list[TimeseriesDataPoint])