Skip to main content

An asynchronous Python wrapper for Warframe.Market API

Project description

warframe-market.py

An asynchronous Python client for the Warframe Market API V2.

Warning: This project is in development and not yet ready for production use.

Installation

pip install warframe-market.py

Requirements

  • Python 3.9+
  • aiohttp
  • msgspec

Basic Usage

import asyncio
from warframe_market.client import WarframeMarketClient
from warframe_market.api.item import Items, Item

async def main():
    async with WarframeMarketClient() as client:
        # Get all items
        items = await client.get_all_items()
        for item in items.data:
            print(item.i18n["en"].name)
        
        # Get a single item 
        item = await client.get_item("nova_prime_set")
        print(item)

if __name__ == "__main__":
    loop = asyncio.get_event_loop()
    loop.run_until_complete(main())
    loop.close()

Get static image URLs for items

from warframe_market.client import WarframeMarketClient
from warframe_market.utils import get_static_asset_url

async with WarframeMarketClient() as client:
    # Using client convenience methods (fetches item, returns full URL)
    icon_url = await client.get_item_icon_url("nova_prime_set")
    thumb_url = await client.get_item_thumb_url("nova_prime_set")
    print(icon_url)   # https://warframe.market/static/assets/...
    print(thumb_url)  # https://warframe.market/static/assets/...

    # Using the utility function directly (when you already have a filename)
    icon_url = get_static_asset_url("nova_prime_set.png")
    print(icon_url)

Advanced Usage

Other languages or platforms

By default, the client uses English language, platform is PC and crossplay enabled. You can change these settings by passing parameters to the client:

from warframe_market.client import WarframeMarketClient
from warframe_market.common import Language, Platform

async with WarframeMarketClient(
    language=Language.ENGLISH,
    platform=Platform.SWITCH,
    crossplay=False
) as client:
    # Your code here

Get top 5 sell/buy orders for an item

from warframe_market.client import WarframeMarketClient


async with WarframeMarketClient() as client:
    item = "nekros_prime_chassis_blueprint"

    item_data = await client.get_top_orders_for_item(item)
    print(f"Top sell orders: \n {item_data.data.sell}")
    print(f"Top buy orders: \n {item_data.data.buy}")

Get top 5 sell/buy orders for an item with custom parameters

Items like mods can have additional parameters like rank You can pass these parameters in 2 ways:

from warframe_market.client import WarframeMarketClient
from warframe_market.api import OrdersItemTop

async with WarframeMarketClient() as client:
    item = "primed_continuity"
    rank = 10  # for maxed rank

    # Using the API model
    item_data = await client.get(OrdersItemTop, slug=item, rank=rank)
    print(f"Top sell orders: \n {item_data.data.sell}")
    print(f"Top buy orders: \n {item_data.data.buy}")

    # Using the convenience method
    item_data = await client.get_top_orders_for_item(item, rank=rank)
    print(f"Top sell orders: \n {item_data.data.sell}")
    print(f"Top buy orders: \n {item_data.data.buy}")

Use API models directly

from warframe_market.client import WarframeMarketClient
from warframe_market.api import OrdersItemTop


async with WarframeMarketClient() as client:
    item = "nekros_prime_chassis_blueprint"

    item_data = await client.get(OrdersItemTop, slug=item)
    print(f"Top sell orders: \n {item_data.data.sell}")
    print(f"Top buy orders: \n {item_data.data.buy}")

Use a custom API model

import msgspec
from typing import Optional
from warframe_market.client import WarframeMarketClient
from warframe_market.common import BaseRequest


class _CustomData(msgspec.Struct):
    """Custom data model"""

    field1: str
    field2: Optional[str] = None 


class CustomAPI(BaseRequest):
    """Custom API request model"""
    endpoint = "/a/new/endpoint/{slug}"
    __slug__ = True # Indicates that 'slug' is a path parameter
    __params__ = ["param1", "param2" ] # Query parameters allowed in the request

    data: _CustomData


async with WarframeMarketClient() as client:
    item = "nekros_prime_chassis_blueprint"
    param1 = "value1"
    param2 = "value2"

    custom_data = await client.get(CustomAPI, slug=item, param1=param1, param2=param2)
    print(custom_data.data.field1)
    print(custom_data.data.field2)

License

This project is licensed under the MIT License. See the LICENSE file for details.

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

warframe_market_py-1.2.0.tar.gz (20.6 kB view details)

Uploaded Source

Built Distribution

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

warframe_market_py-1.2.0-py3-none-any.whl (23.2 kB view details)

Uploaded Python 3

File details

Details for the file warframe_market_py-1.2.0.tar.gz.

File metadata

  • Download URL: warframe_market_py-1.2.0.tar.gz
  • Upload date:
  • Size: 20.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: python-httpx/0.28.1

File hashes

Hashes for warframe_market_py-1.2.0.tar.gz
Algorithm Hash digest
SHA256 3e2c87376fa4f4777bbae4d913278c18181e0008f9acf8c9aa9e0d12aa8f0173
MD5 b903d7c2bda71df8ff9a86029d344f4a
BLAKE2b-256 a0e1ffa89600cb13be76a155eebe63bf55c0b5f38a5b5422f0e8445a4b4b25fb

See more details on using hashes here.

File details

Details for the file warframe_market_py-1.2.0-py3-none-any.whl.

File metadata

File hashes

Hashes for warframe_market_py-1.2.0-py3-none-any.whl
Algorithm Hash digest
SHA256 5a3ce6f476990f5735be936d7b5bc79ceffefb39749d35f2e3d3f5b012b7d3f5
MD5 ee242a570edba71366047eec7ad4d9a7
BLAKE2b-256 b0d8208a4f613e6c42a5490e694bebf5e205c2d5bfc3e77963abb12f91d68058

See more details on using hashes here.

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