Skip to content
Merged
32 changes: 16 additions & 16 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,43 +16,43 @@
For now, the implemented function is listed below:

* auth
* sign in
* 🔲 sign in
* 🆖 register
* 🆖 restore password
* profile
* get current user's profile
* 🔲 get current user's profile
* 🔲 manage current user profile
* get a user's profile
* 🔲 get a user's profile
* 🔲 get all of a user's achievements
* 🔲 get all of a user's reviews
* set current user's online/offline status
* 🔲 set current user's online/offline status
* items
* ✅ list all tradable items
* ✅ get info about an item
* statistics
* get statistics of an item
* 🔲 get statistics of an item
* 🔲 get global market statistics
* orders
* get orders of a single item
* 🔲 get orders of a single item
* 🔲 get orders for the last 4 hours
* update a single order on the current profile
* delete a single order on the current profile
* add a new order for the current profile
* 🔲 update a single order on the current profile
* 🔲 delete a single order on the current profile
* 🔲 add a new order for the current profile
* 🔲 get user's sale statistics(closed orders)
* get all of a user's orders
* 🔲 get all of a user's orders
* liches
* list all lich weapons
* list all lich ephemeras
* list all lich quirks
* 🔲 list all lich weapons
* 🔲 list all lich ephemeras
* 🔲 list all lich quirks
* rivens
* list all riven items
* get a list of riven attributes
* 🔲 list all riven items
* 🔲 get a list of riven attributes
* misc
* 🔲 get a list of all known game locations
* 🔲 get a list of all known npcs
* 🔲 get a list of all known missions
* auctions
* create auction ⚠️
* 🔲 create auction
* 🔲 get a list of riven auctions by given search params
* 🔲 get a list of lich auctions by given search params
* auction entry️
Expand Down
6 changes: 3 additions & 3 deletions src/pywmapi/auth/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -109,10 +109,10 @@ class Status(Enum):

id: str
status: Status
region: str
locale: str
reputation: int
last_seen: datetime
ingame_name: Optional[str] = None
lastSeen: datetime
ingameName: Optional[str] = None
"""In-game name. Only get this field when `verification=True`."""
avatar: Optional[str] = None

Expand Down
2 changes: 1 addition & 1 deletion src/pywmapi/common/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,5 @@
from .enums import *
from .models import *

API_BASE_URL = "https://api.warframe.market/v1"
API_BASE_URL = "https://api.warframe.market/v2"
WSS_BASE_URL = "wss://warframe.market/socket"
6 changes: 3 additions & 3 deletions src/pywmapi/items/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ def list_items(lang: Language = Language.en) -> List[ItemShort]:
headers={"Language": lang.value},
)
check_wm_response(res)
return list(map(lambda x: ItemShort.from_dict(x), res.json()["payload"]["items"]))
return list(map(lambda x: ItemShort.from_dict(x), res.json()["data"]))


def get_item(url_name: str, platform: Platform = Platform.pc) -> Tuple[ItemFull, List[ItemFull]]:
Expand All @@ -46,8 +46,8 @@ def get_item(url_name: str, platform: Platform = Platform.pc) -> Tuple[ItemFull,
headers={"Platform": platform.value},
)
check_wm_response(res)
item_json = res.json()["payload"]["item"]
return _transform_item_result(item_json)
item_json = res.json()["data"]
return ItemFull.from_dict(item_json)


def get_orders(*args, **kwargs):
Expand Down
39 changes: 35 additions & 4 deletions src/pywmapi/items/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,18 @@
@define
class ItemShort(ModelBase):
id: str
url_name: str
slug: str
thumb: str
item_name: str
item_slug: str

@classmethod
def from_dict(cls, data: dict) -> "ItemShort":
return cls(
id=data["id"],
slug=data["slug"],
thumb=data["i18n"]["en"]["thumb"],
item_slug=data["i18n"]["en"]["name"],
)


@define
Expand All @@ -32,8 +41,8 @@ class Rarity(Enum):

id: str
"""Item ID."""
url_name: str
"""Item URL name."""
slug: str
"""Item URL slug."""
icon: str
thumb: str
tags: List[str]
Expand Down Expand Up @@ -66,3 +75,25 @@ class Rarity(Enum):
es: Optional[LangInItem] = None
it: Optional[LangInItem] = None
pl: Optional[LangInItem] = None

@classmethod
def from_dict(cls, data: dict) -> "ItemShort":
return cls(
id=data.get("id"),
slug=data.get("slug"),
icon=data["i18n"]["en"].get("icon"),
thumb=data["i18n"]["en"].get("thumb"),
tags=data.get("tags"),
trading_tax=data.get("tradingTax"),
sub_icon=data["i18n"]["en"].get("subIcon"),
quantity_for_set=data.get("quantityInSet"),
mod_max_rank=data.get("maxRank"),
subtypes=data.get("subtypes"),
cyan_stars=data.get("cyanStars"),
amber_stars=data.get("amberStars"),
vaulted=data.get("vaulted"),
ducats=data.get("ducats"),
set_root=data.get("setRoot"),
mastery_level=data.get("reqMasteryRank"),
rarity=cls.Rarity(data["rarity"]) if "rarity" in data else None,
)
4 changes: 2 additions & 2 deletions src/pywmapi/orders/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,13 +56,13 @@ def get_orders(
as the 2nd and 3rd return value.
"""
res = requests.get(
API_BASE_URL + f"/items/{url_name}/orders",
API_BASE_URL + f"/orders/item/{url_name}",
params={"include": include.value if include is not None else None},
headers={"Platform": platform.value},
)
check_wm_response(res)
json_obj = res.json()
orders = list(map(lambda x: OrderRow.from_dict(x), json_obj["payload"]["orders"]))
orders = list(map(lambda x: OrderRow.from_dict(x), json_obj["data"]))
if include == IncludeOption.item:
target_item, items_in_set = _transform_item_result(json_obj["include"]["item"])
return orders, target_item, items_in_set
Expand Down
4 changes: 2 additions & 2 deletions src/pywmapi/orders/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ class OrderCommon(ModelBase):
id: str
platinum: int
quantity: int
order_type: OrderType
type: OrderType
visible: bool
platform: Optional[Platform] = None
region: Optional[str] = None
Expand Down Expand Up @@ -101,7 +101,7 @@ class OrderNewItem(OrderNewItemBase):
"""

item_id: str
order_type: OrderType
type: OrderType


@define(kw_only=True)
Expand Down
6 changes: 3 additions & 3 deletions src/pywmapi/profile/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ def get_current_user(sess: Session) -> User:
User: user
"""
res = requests.get(
API_BASE_URL + f"/profile",
API_BASE_URL + f"/user",
**sess.to_header_dict(),
)
check_wm_response(res)
Expand All @@ -39,10 +39,10 @@ def get_profile_by_username(username: str) -> Profile:
Profile: user profile
"""
res = requests.get(
API_BASE_URL + f"/profile/{username}",
API_BASE_URL + f"/user/{username}",
)
check_wm_response(res)
return Profile.from_dict(res.json()["payload"]["profile"])
return Profile.from_dict(res.json()["data"])


def set_profile_status(sess: Session, status: ProfileStatus) -> None:
Expand Down
41 changes: 30 additions & 11 deletions src/pywmapi/profile/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,30 +15,49 @@
class Profile(ModelBase):
@define
class Achievement:
name: str
id: str
icon: str
description: str
exposed: bool
# might be always `patreon`
type: str

id: str
"""User ID."""
ingame_name: str
"""In-game name."""
slug: str
status: ProfileStatus
"""Wfm status."""
slug: str
icon: str
thumb: str
platform: Platform
region: str
locale: str
banned: bool
avatar: str
last_seen: datetime
lastSeen: datetime
reputation: int
about: str
"""User's about-me section. Rendered as HTML."""
about_raw: str
"""User's about-me section. Raw text."""
own_profile: bool
achievements: List[Achievement]
ban_reason: Optional[str] = None
achievementShowcase: Optional[Achievement]
banMessage: Optional[str] = None
background: Optional[str] = None

@classmethod
def from_dict(cls, data: dict) -> "Profile":
return cls(
id=data.get("id"),
slug=data.get("slug"),
status=ProfileStatus(data.get("status")),
icon=data.get("icon"),
thumb=data.get("thumb"),
platform=Platform(data.get("platform")),
locale=data.get("locale"),
banned=data.get("banned", False),
avatar=data.get("avatar"),
lastSeen=datetime.fromisoformat(data.get("lastSeen").replace("Z", "+00:00")),
reputation=data.get("reputation"),
about=data.get("about"),
own_profile=data.get("ownProfile", False),
achievementShowcase=data.get("achievementShowcase"),
banMessage=data.get("banMessage"),
background=data.get("background"),
)
8 changes: 6 additions & 2 deletions tests/test_orders_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,12 @@


def test_get_orders():
get_orders("mirage_prime_systems", include=IncludeOption.item)
get_orders("heavy_trauma", include=IncludeOption.item)
result1 = get_orders("mirage_prime_systems")
assert isinstance(result1, list)
assert len(result1) > 0
result2 = get_orders("heavy_trauma")
assert isinstance(result2, list)
assert len(result2) > 0


@pytest.mark.skipif(get_test_signin_dict() is None, reason="No test account.")
Expand Down
2 changes: 1 addition & 1 deletion tests/test_profile_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@


def test_get_profile_by_username():
get_profile_by_username("AyajiLin")
get_profile_by_username("megan")


@pytest.mark.skipif(get_test_signin_dict() is None, reason="No test account.")
Expand Down
Loading