### Get First Page of Gifts Source: https://context7.com/boostnt/mrkt-api/llms.txt Retrieves the initial page of gifts. Ensure you have a valid token and the get_gifts function is defined. ```python token = 'ваш_токен' response = get_gifts(token) gifts = response.get('gifts', []) print(f'Найдено подарков: {len(gifts)}') for gift in gifts: print(gift) ``` -------------------------------- ### Get Next Page of Gifts using Cursor Source: https://context7.com/boostnt/mrkt-api/llms.txt Fetches the subsequent page of gifts using a cursor obtained from a previous response. If the cursor is None, it indicates the last page of results. ```python cursor = response.get('cursor') if cursor: next_page = get_gifts(token, page_cursor=cursor) print(next_page.get('gifts', [])) ``` -------------------------------- ### POST /api/v1/gifts/saling - Get List of Gifts for Sale Source: https://context7.com/boostnt/mrkt-api/llms.txt The main endpoint for retrieving current gift listings on the marketplace. It supports filtering by collection, model, backdrop, and symbol, as well as sorting by price or rarity. The response includes a `gifts` array and a `cursor` for paginated browsing. ```APIDOC ## POST /api/v1/gifts/saling ### Description Main endpoint for obtaining current gift listings on the marketplace. Supports filtering by collection, model, backdrop, and symbol, as well as sorting by price or rarity. The response includes a `gifts` array and a `cursor` for paginated browsing. The maximum number of gifts per response is 20. ### Method POST ### Endpoint /api/v1/gifts/saling ### Parameters #### Query Parameters - **token** (string) - Required - Authorization token obtained from the `/api/v1/auth` endpoint. #### Request Body - **collectionNames** (array of strings) - Optional - List of collection names (e.g., `['Lunar Snake']`). - **modelNames** (array of strings) - Optional - List of gift model names (e.g., `['Albino']`). - **backdropNames** (array of strings) - Optional - List of backdrop names. - **symbolNames** (array of strings) - Optional - List of symbol names. - **ordering** (string) - Optional - Sorting criteria: `Price`, `ModelRarity`, `BackgroundRarity`, `SymbolRarity`, or `None`. - **lowToHigh** (boolean) - Optional - `True` for ascending, `False` for descending order. - **maxPrice** (number) - Optional - Maximum price (null for no limit). - **minPrice** (number) - Optional - Minimum price (null for no limit). - **mintable** (boolean) - Optional - Filter by mintable status. - **number** (integer) - Optional - Specific gift number. - **count** (integer) - Optional - Number of results per page (max 20). - **cursor** (string) - Optional - Pagination cursor (empty string `''` for the first page). - **query** (string) - Optional - Search query. - **promotedFirst** (boolean) - Optional - Whether to show promoted items first. ### Request Example ```json { "collectionNames": ["Lunar Snake"], "modelNames": ["Albino"], "backdropNames": [], "symbolNames": [], "ordering": "Price", "lowToHigh": true, "maxPrice": null, "minPrice": null, "mintable": null, "number": null, "count": 20, "cursor": "", "query": null, "promotedFirst": false } ``` ### Response #### Success Response (200) - **gifts** (array of objects) - List of gift objects. - **gift_id** (string) - Unique identifier for the gift. - **name** (string) - Name of the gift. - **collection** (string) - Collection the gift belongs to. - **model** (string) - Model of the gift. - **price** (string) - Price of the gift. - ... (other gift properties) - **cursor** (string) - Cursor for the next page of results. #### Response Example ```json { "gifts": [ { "gift_id": "123e4567-e89b-12d3-a456-426614174000", "name": "Albino Lunar Snake", "collection": "Lunar Snake", "model": "Albino", "price": "0.5 ETH", "rarity": "Common", "image_url": "https://example.com/image.png" } ], "cursor": "next_page_cursor_string" } ``` ``` -------------------------------- ### Get MRKT Selling Gifts List with Filtering and Pagination Source: https://context7.com/boostnt/mrkt-api/llms.txt Retrieve a list of gifts currently for sale on the MRKT marketplace. Supports filtering by collection, model, backdrop, and symbol, with options for sorting by price or rarity. Pagination is handled via a cursor. Maximum results per request is 20. ```python from curl_cffi import requests MARKET_API_URL = 'https://api.tgmrkt.io/api/v1' def get_gifts(token: str, page_cursor: str = '') -> dict: """ Получает список подарков с фильтрацией и пагинацией. Параметры фильтрации: - collectionNames: список названий коллекций (напр. ['Lunar Snake']) - modelNames: список моделей подарка (напр. ['Albino']) - backdropNames: список фонов подарка - symbolNames: список узоров подарка - ordering: сортировка — 'Price' | 'ModelRarity' | 'BackgroundRarity' | 'SymbolRarity' | None - lowToHigh: True — по возрастанию, False — по убыванию - maxPrice: максимальная цена (None — без ограничения) - minPrice: минимальная цена (None — без ограничения) - mintable: фильтр по возможности вывода в блокчейн - number: конкретный номер подарка - count: кол-во результатов (макс. 20) - cursor: курсор пагинации ('' для первой страницы) """ headers = { 'Authorization': token, 'Referer': 'https://cdn.tgmrkt.io/' } json_data = { "collectionNames": ['Lunar Snake'], "modelNames": ['Albino'], "backdropNames": [], "symbolNames": [], "ordering": "Price", "lowToHigh": True, "maxPrice": None, "minPrice": None, "mintable": None, "number": None, "count": 20, "cursor": page_cursor, "query": None, "promotedFirst": False, } try: r = requests.post( f'{MARKET_API_URL}/gifts/saling', headers=headers, json=json_data ) return r.json() except Exception as e: print(f'Ошибка запроса: {e}') return {} ``` -------------------------------- ### Get Gifts Source: https://github.com/boostnt/mrkt-api/blob/main/README.md Fetches gifts from the MRKT API. Allows filtering by various criteria. ```APIDOC ## POST /api/v1/gifts/saling ### Description This endpoint is used to retrieve gifts from the MRKT platform. It supports filtering through a JSON payload. ### Method POST ### Endpoint https://api.tgmrkt.io/api/v1/gifts/saling ### Parameters #### Request Body - **collectionNames** (array) - Optional - List of gift collection names to filter by. - **modelNames** (array) - Optional - List of gift model names to filter by. - **backdropNames** (array) - Optional - List of gift backdrop names to filter by. - **symbolNames** (array) - Optional - List of gift symbol names to filter by. - **ordering** (string) - Optional - Type of sorting. Possible values: "Price", "ModelRarity", "BackgroundRarity", "SymbolRarity", None. - **lowToHigh** (boolean) - Optional - Whether to sort in ascending order (depends on the selected ordering type). - **maxPrice** (number) - Optional - Maximum price of the gift. - **minPrice** (number) - Optional - Minimum price of the gift. - **mintable** (boolean) - Optional - Whether the gift can be minted to the blockchain. - **number** (number) - Optional - Specific gift number. - **count** (integer) - Optional - Maximum number of gifts to retrieve (limit is 20). - **cursor** (string) - Optional - Offset for pagination. Use an empty string for the first page. Subsequent pages use the cursor from the previous response. - **query** (any) - Optional - Unknown purpose. - **promotedFirst** (boolean) - Optional - Unknown purpose. ### Request Example ```json { "collectionNames": [], "modelNames": [], "backdropNames": [], "symbolNames": [], "ordering": "Price", "lowToHigh": true, "maxPrice": null, "minPrice": null, "mintable": null, "number": null, "count": 20, "cursor": '', "query": null, "promotedFirst": false } ``` ### Response #### Success Response (200) - **gifts** (array) - List of gift objects. - **cursor** (string) - Cursor for the next page of results. #### Response Example ```json { "gifts": [ { "collectionName": "Example Collection", "modelName": "Example Model", "backdropName": "Example Backdrop", "symbolName": "Example Symbol", "price": 100, "mintable": true // ... other gift properties } ], "cursor": "next_page_cursor" } ``` ``` -------------------------------- ### Get MRKT API Authorization Token with Pyrogram Source: https://context7.com/boostnt/mrkt-api/llms.txt Obtain a JWT authorization token by interacting with the Telegram WebApp. Requires Pyrogram for Telegram client interaction and curl_cffi for making the API request. The token is valid for over 24 hours. ```python import asyncio from pyrogram import Client from pyrogram.raw.functions.messages import RequestAppWebView from pyrogram.raw.types import InputBotAppShortName, InputUser from urllib.parse import unquote from curl_cffi import requests # Получить api_id и api_hash на https://my.telegram.org/auth api_id = 123123123 api_hash = 'ваш_api_hash' client = Client('session', api_id, api_hash) async def get_auth_token() -> str | None: """Получает токен авторизации через Telegram WebApp init_data.""" async with client: bot_entity = await client.get_users('mrkt') peer = await client.resolve_peer('mrkt') bot = InputUser(user_id=bot_entity.id, access_hash=bot_entity.raw.access_hash) bot_app = InputBotAppShortName(bot_id=bot, short_name='app') web_view = await client.invoke( RequestAppWebView( peer=peer, app=bot_app, platform='android', ) ) # Извлечение init_data из URL WebApp init_data = unquote( web_view.url.split('tgWebAppData=', 1)[1].split('&tgWebAppVersion', 1)[0] ) # POST-запрос к эндпоинту авторизации r = requests.post( url='https://api.tgmrkt.io/api/v1/auth', json={'data': init_data} ) rj = r.json() return rj.get('token') if rj else None # Запуск loop = asyncio.get_event_loop() token = loop.run_until_complete(get_auth_token()) print(token) # Вывод: eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9... ``` -------------------------------- ### POST /api/v1/auth - Get Authorization Token Source: https://context7.com/boostnt/mrkt-api/llms.txt Endpoint to obtain a JWT token required for all subsequent API requests. It accepts `init_data` from the Telegram WebApp, which can be extracted using libraries like Pyrogram or Telethon. ```APIDOC ## POST /api/v1/auth ### Description Endpoint for obtaining a JWT token necessary for all subsequent API requests. It accepts `init_data` - a Telegram WebApp initialization string, which can only be extracted when the application is run through a Telegram client (Pyrogram, Telethon) or manually via developer tools in the web version of Telegram. The token is valid for more than 24 hours. ### Method POST ### Endpoint /api/v1/auth ### Request Body - **data** (string) - Required - The `init_data` string from Telegram WebApp. ### Request Example ```json { "data": "query_id=...&user=...&auth_date=...&hash=..." } ``` ### Response #### Success Response (200) - **token** (string) - The JWT authorization token. #### Response Example ```json { "token": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9..." } ``` ``` -------------------------------- ### Python Script to Get MRKT API Auth Token using Pyrogram and curl_cffi Source: https://github.com/boostnt/mrkt-api/blob/main/README.md This Python script uses Pyrogram to interact with Telegram and obtain `init_data`, which is then used with `curl_cffi` to authenticate with the MRKT API and retrieve a token. Ensure you replace placeholder API ID and Hash with your actual Telegram API credentials. ```python import asyncio from pyrogram import Client from pyrogram.raw.functions.messages import RequestAppWebView from pyrogram.raw.types import InputBotAppShortName, InputUser from urllib.parse import unquote from curl_cffi import AsyncSession api_id = 123123123 # замени с https://my.telegram.org/auth api_hash = '1rghg34hb3g4bkj3gbg134' # замени с https://my.telegram.org/auth client = Client('main') async def get_auth_token(): async with client: bot_entity = await client.get_users('mrkt') peer = await client.resolve_peer('mrkt') bot = InputUser(user_id=bot_entity.id, access_hash=bot_entity.raw.access_hash) bot_app = InputBotAppShortName(bot_id=bot, short_name='app') web_view = await client.invoke( RequestAppWebView( peer=peer, app=bot_app, platform="android", ) ) init_data = unquote(web_view.url.split('tgWebAppData=', 1)[1].split('&tgWebAppVersion', 1)[0]) auth_data = {"data": init_data} async with AsyncSession() as s: r = await s.post(url="https://api.tgmrkt.io/api/v1/auth", json=auth_data) rj = r.json() if rj: token = rj.get('token', None) else: token = None return token async def main(): token = await get_auth_token() print(token) loop = asyncio.get_event_loop() loop.run_until_complete(main()) ``` -------------------------------- ### Authenticate and Fetch Market Gifts with Python Source: https://github.com/boostnt/mrkt-api/blob/main/README.md This snippet shows how to authenticate with the MRKT API to obtain a token and then use that token to fetch a list of gifts. It includes parameters for filtering gifts by collection, model, and ordering. Requires Pyrogram and curl_cffi libraries. ```python import asyncio from pyrogram import Client from pyrogram.raw.functions.messages import RequestAppWebView from pyrogram.raw.types import InputBotAppShortName, InputUser from urllib.parse import unquote from curl_cffi import requests MARKET_API_URL = 'https://api.tgmrkt.io/api/v1' api_id = 123123123 # замените на своё с https://my.telegram.org/auth api_hash = '1rghg34hb3g4bkj3gbg134' # замените на своё с https://my.telegram.org/auth client = Client('main', api_id, api_hash) async def main(): token = await get_auth_token() # token = '' или через веб тг headers = {'Authorization': token, 'Referer': 'https://cdn.tgmrkt.io/'} json_data = { "collectionNames": ['Lunar Snake'], "modelNames": ['Albino'], "backdropNames": [], "symbolNames": [], "ordering": "Price", "lowToHigh": True, "maxPrice": None, "minPrice": None, "mintable": None, "number": None, "count": 20, "cursor": '', "query": None, "promotedFirst": False, } try: r=requests.post(f'{MARKET_API_URL}/gifts/saling', headers=headers, json=json_data) rj=r.json() gifts = rj['gifts'] print(gifts) # Или если нужна следующая страница: # cursor = rj['cursor'] # json_data.update({'cursor': cursor}) # r=requests.post(f'{MARKET_API_URL}/gifts/saling', headers=headers, json=json_data) # rj=r.json() # print(gifts) except Exception as e: print(e) # Код выведет первую страницу с подарками Lunar Snake с моделью Albino async def get_auth_token(): async with client: bot_entity = await client.get_users('mrkt') peer = await client.resolve_peer('mrkt') bot = InputUser(user_id=bot_entity.id, access_hash=bot_entity.raw.access_hash) bot_app = InputBotAppShortName(bot_id=bot, short_name='app') web_view = await client.invoke( RequestAppWebView( peer=peer, app=bot_app, platform='android', ) ) init_data = unquote(web_view.url.split('tgWebAppData=', 1)[1].split('&tgWebAppVersion', 1)[0]) auth_data = {'data': init_data} r = requests.post(url='https://api.tgmrkt.io/api/v1/auth', json=auth_data) rj = r.json() if rj: token = rj.get('token', None) else: token = None return token loop = asyncio.get_event_loop() loop.run_until_complete(main()) ``` -------------------------------- ### Authentication Source: https://github.com/boostnt/mrkt-api/blob/main/README.md Obtains an authentication token required for interacting with the MRKT API. ```APIDOC ## POST /api/v1/auth ### Description This endpoint is used to authenticate and obtain a token necessary for making further requests to the MRKT API. The `init_data` parameter is obtained from the Telegram Web App context. ### Method POST ### Endpoint https://api.tgmrkt.io/api/v1/auth ### Parameters #### Request Body - **data** (string) - Required - The `init_data` obtained from the Telegram Web App. ### Request Example ```json { "data": "your_init_data_here" } ``` ### Response #### Success Response (200) - **token** (string) - The authentication token. #### Response Example ```json { "token": "your_auth_token_here" } ``` ``` -------------------------------- ### MRKT API Authentication URL Source: https://github.com/boostnt/mrkt-api/blob/main/README.md This URL is used to authenticate with the MRKT API. It requires a POST request with a JSON body containing `{"data": init_data}`. ```python https://api.tgmrkt.io/api/v1/auth ``` -------------------------------- ### MRKT API Gift Fetching URL Source: https://github.com/boostnt/mrkt-api/blob/main/README.md This is the URL used to fetch gifts from the MRKT API. It is used in POST requests. ```python https://api.tgmrkt.io/api/v1/gifts/saling ``` -------------------------------- ### MRKT API Gift Filtering JSON Structure Source: https://github.com/boostnt/mrkt-api/blob/main/README.md This JSON structure is used to filter gifts when making requests to the MRKT API. It allows specifying collection, model, backdrop, and symbol names, as well as price ranges and sorting options. ```json { "collectionNames": [], "modelNames": [], "backdropNames": [], "symbolNames": [], "ordering": "Price", "lowToHigh": True, "maxPrice": None, "minPrice": None, "mintable": None, "number": None, "count": 20, "cursor": '', "query": None, "promotedFirst": False, } ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.