API client for CSMarketAPI
Project description
CSMarketAPI-Client
Asynchronous Python client for CSMarketAPI — typed responses (Pydantic), enums for marketplaces/currencies, and convenient async context managers.
Highlights
- Async & Fast: Use with
async with CSMarketAPI(...) - Typed Models: All responses are Pydantic models
- Enums: For
MarketandCurrency - Modern Python: 3.13+, type hints everywhere
Installation
pip install csmarketapi-client
Requirements
- Python 3.13+
- CSMarketAPI API key
Quickstart
import asyncio
from csmarketapi import CSMarketAPI
from csmarketapi.enums import Market, Currency
async def main():
async with CSMarketAPI("YOUR_API_KEY") as client:
items = await client.get_items()
print(f"Loaded {len(items.items)} items.")
asyncio.run(main())
Usage Examples
All methods are async and return Pydantic models.
Listings (Latest)
async with CSMarketAPI("YOUR_API_KEY") as client:
res = await client.get_listings_latest_aggregated(
market_hash_name="Chroma 2 Case",
markets=list(Market)
curreny=Currency.USD
)
print(res.market_hash_name, res.listings[0].market, res.listings[0].min_price)
Sales (Latest)
async with CSMarketAPI("YOUR_API_KEY") as client:
res = await client.get_sales_latest_aggregated(
market_hash_name="Chroma 2 Case",
markets=[Market.SKINPORT, Market.SKINBARON]
)
print(res.sales[0].market, res.sales[0].median_price)
Currency Rates
async with CSMarketAPI("YOUR_API_KEY") as client:
rates = await client.get_currency_rates()
print(rates.items)
Steam Inventory
async with CSMarketAPI("YOUR_API_KEY") as client:
inv = await client.get_steam_inventory(steam_id="YOUR_STEAM_ID")
print(inv.assets)
Error Handling & Tipps
- Wrap API calls in
try/exceptfor network errors - Optional fields may be
None - Use
markets=list(Market)for all markets
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
csmarketapi-1.0.1.tar.gz
(5.5 kB
view details)
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 csmarketapi-1.0.1.tar.gz.
File metadata
- Download URL: csmarketapi-1.0.1.tar.gz
- Upload date:
- Size: 5.5 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.8.13
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
712ef8ae69fbf9a4bf7fb08f5de8e60e85fceba91b9d503b0baab56868d2d3fb
|
|
| MD5 |
fc54a19ff8016b8bbe44a08099a0524b
|
|
| BLAKE2b-256 |
78ed6a928925397625144fb61e38ebd6ecbca17565a7b3a6ad2529ad363791a6
|
File details
Details for the file csmarketapi-1.0.1-py3-none-any.whl.
File metadata
- Download URL: csmarketapi-1.0.1-py3-none-any.whl
- Upload date:
- Size: 5.6 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.8.13
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
e98b7853f09f6c0fc2e8ac1c90f2e9d9eaf274b8ec88891f7879a7684daece89
|
|
| MD5 |
a3f67a6bcfd183252cd1543a7be5a73a
|
|
| BLAKE2b-256 |
8d6ac8b106c7c2195b91335206b195d71adcc68765085f483724d86bb3b74b53
|