search

async def search(sort: str, offset: int, limit: int, gift_name: str | list, model: str | list, backdrop: str | list, symbol: str | list, min_price: int, max_price: int, authData: str) -> list[PortalsGift]

Retrieve listed gifts

Returns

list of PortalsGift objects

Raises

  • authDataError - if authData is not provided

  • giftsError:

    • if max_price is less than min_price or min_price and max_price are not integers

    • if gift_name, model, backdrop or symbol are not strings or lists

    • if sort is not one of the valid options

  • requestError - if request fails

Parameters

  • sort (str) - The sorting method for the results. Options are: "latest", "price_asc", "price_desc", "gift_id_asc", "gift_id_desc", "model_rarity_asc", "model_rarity_desc". Defaults to "price_asc".

  • offset (int) - pagination offset. For example, to get second page you need to set offset to 1*limit , third - 2*limit etc. Default is 0.

  • limit (int) - limit of gifts to show. Default is 20, maximum (for now) is 100.

  • gift_name (str | list, optional) - gift name / list of gift names to search for

  • model (str | list, optional) - model name / list of model names to search for

  • backdrop (str | list, optional) - backdrop name / list of backdrop names to search for

  • symbol (str | list, optional) - symbol name / list of symbols to search for

  • min_price (int, optional) - min price of the searching gifts

  • max_price (int, optional) - max price of the searching gifts

  • authData (str) - authentication data required for the api request

PortalsGift object

Methods:

  • .toDict(): Converts the PortalsGift object back to a dictionary format.

Attributes:

  • .id: The ID of the NFT.

  • .tg_id: Telegram number of the gift (an external collection number).

  • .collection_id: The ID of the gift collection.

  • .name: Name of the gift.

  • .photo_url: URL of the photo from Fragment representing the gift (first frame of Lottie animation in PNG).

  • .price: Price of the gift.

  • .model: Model of the gift.

  • .model_rarity: Rarity percentage of the model.

  • .backdrop: Backdrop of the gift.

  • .backdrop_rarity: Rarity percentage of the backdrop.

  • .symbol: Symbol of the gift.

  • .symbol_rarity: Rarity percentage of the symbol.

  • .listed_at: Date and time when the gift has been listed for sale.

  • .status: Status of the gift (possible values: "listed", "unlisted", "withdrawn").

  • .animation_url: URL to the Lottie animation of the gift.

  • .emoji_id: Custom Telegram emoji ID for the gift.

  • .floor_price: Floor price of the gift's collection.

  • .unlocks_at: Date and time when the gift will be mintable (unsure if correct).

Example

Print gift price and floor price for every gift from latest

from aportalsmp.gifts import search
from aportalsmp.auth import update_auth
import asyncio

auth = asyncio.run(update_auth(api_id=123, api_hash="..."))

async def main():
    latest_gifts = await search(sort = "latest", authData = auth)
    for gift in latest_gifts:
        print(f"{gift.name}-{gift.tg_id} - price: {gift.price}, floor: {gift.floor_price}")

See used functions: update_auth

Last updated