Skip to content

deal element in /v2/classifieds/listings/batch #7

Description

@StrangePlay02

Hello good sir,

I noticed occasionally backpacktf endpoint /v2/classifieds/listings/batch returns a new element deal.

response[1]['result'].keys()
dict_keys(['id', 'steamid', 'appid', 'currencies', 'value', 'tradeOffersPreferred', 'buyoutOnly', 'details', 'listedAt', 'bumpedAt', 'intent', 'count', 'status', 'source', 'item', 'deal', 'userAgent', 'user'])

Looks like this:

response[1]['result']['deal']
{'percent': 0.11452184179456913, 'value': 33.88}

This is however not accounted for in the Listing dataclass, leading to a KeyError:

class Listing:
    id: str
    steamid: str
    appid: int
    currencies: dict[str, Any]
    value: dict
    details: str
    listedAt: int
    bumpedAt: int
    intent: str
    count: int
    status: str
    source: str
    item: dict[str, Any]
    user: dict = field(default_factory=dict)  # Made optional for API compatibility
    userAgent: dict = field(default_factory=dict)
    tradeOffersPreferred: bool = None
    buyoutOnly: bool = None
    archived: bool = field(default=False)  # Added for API compatibility

This breaks create_listings():

    def create_listings(self, listings: list[dict]) -> list[Listing]:
        to_list = [construct_listing(**listing) for listing in listings]
        response = self.request("POST", "/v2/classifieds/listings/batch", json=to_list)
        return [Listing(**listing["result"]) for listing in response]

Hope this can be looked at. Thanks so much!

Metadata

Metadata

Assignees

Labels

bugSomething isn't working

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions