{"id":461261,"date":"2025-05-28T15:00:25","date_gmt":"2025-05-28T15:00:25","guid":{"rendered":"http:\/\/savepearlharbor.com\/?p=461261"},"modified":"-0001-11-30T00:00:00","modified_gmt":"-0001-11-29T21:00:00","slug":"","status":"publish","type":"post","link":"https:\/\/savepearlharbor.com\/?p=461261","title":{"rendered":"<span>\u0420\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u043a\u0430 NFT-\u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0439 \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e Magic Eden API: \u043e\u0442 \u0438\u0434\u0435\u0438 \u0434\u043e \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438<\/span>"},"content":{"rendered":"<div><!--[--><!--]--><\/div>\n<div id=\"post-content-body\">\n<div>\n<div class=\"article-formatted-body article-formatted-body article-formatted-body_version-2\">\n<div xmlns=\"http:\/\/www.w3.org\/1999\/xhtml\">\n<p>\u041f\u0440\u0438\u0432\u0435\u0442, \u0425\u0430\u0431\u0440! \u0412 \u044d\u0442\u043e\u0439 \u0441\u0442\u0430\u0442\u044c\u0435 \u044f \u0440\u0430\u0441\u0441\u043a\u0430\u0436\u0443 \u043e \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0441\u0442\u044f\u0445 API Magic Eden &#8212; \u043e\u0434\u043d\u043e\u0433\u043e \u0438\u0437 \u043a\u0440\u0443\u043f\u043d\u0435\u0439\u0448\u0438\u0445 NFT-\u043c\u0430\u0440\u043a\u0435\u0442\u043f\u043b\u0435\u0439\u0441\u043e\u0432, \u0432 \u0441\u0442\u0430\u0442\u044c\u0435 \u0437\u0430\u0442\u0440\u043e\u043d\u0443 \u043d\u0435\u043f\u043e\u0441\u0440\u0435\u0434\u0441\u0442\u0432\u0435\u043d\u043d\u043e \u043c\u0435\u0442\u043e\u0434\u044b \u0441\u043e\u043b\u0430\u043d\u044b, \u0438 \u043f\u043e\u043a\u0430\u0436\u0443, \u043a\u0430\u043a \u0441 \u0435\u0433\u043e \u043f\u043e\u043c\u043e\u0449\u044c\u044e \u043c\u043e\u0436\u043d\u043e \u0441\u043e\u0437\u0434\u0430\u0432\u0430\u0442\u044c \u0438\u043d\u0442\u0435\u0440\u0435\u0441\u043d\u044b\u0435 \u043f\u0440\u043e\u0435\u043a\u0442\u044b.<\/p>\n<h3>\u0412\u0432\u0435\u0434\u0435\u043d\u0438\u0435<\/h3>\n<p>Magic Eden \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u0432\u0435\u0434\u0443\u0449\u0438\u043c NFT-\u043c\u0430\u0440\u043a\u0435\u0442\u043f\u043b\u0435\u0439\u0441\u043e\u043c \u0441 \u0435\u0436\u0435\u043c\u0435\u0441\u044f\u0447\u043d\u044b\u043c \u043e\u0431\u044a\u0435\u043c\u043e\u043c \u0442\u043e\u0440\u0433\u043e\u0432 \u0431\u043e\u043b\u0435\u0435 $100 \u043c\u0438\u043b\u043b\u0438\u043e\u043d\u043e\u0432. API \u043f\u043b\u0430\u0442\u0444\u043e\u0440\u043c\u044b \u043e\u0442\u043a\u0440\u044b\u0432\u0430\u0435\u0442 \u0448\u0438\u0440\u043e\u043a\u0438\u0435 \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0441\u0442\u0438 \u0434\u043b\u044f \u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u0447\u0438\u043a\u043e\u0432, \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u044f \u0441\u043e\u0437\u0434\u0430\u0432\u0430\u0442\u044c \u0440\u0430\u0437\u043b\u0438\u0447\u043d\u044b\u0435 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f: \u043e\u0442 \u043f\u0440\u043e\u0441\u0442\u044b\u0445 NFT-\u0442\u0440\u0435\u043a\u0435\u0440\u043e\u0432 \u0434\u043e \u0441\u043b\u043e\u0436\u043d\u044b\u0445 \u0442\u043e\u0440\u0433\u043e\u0432\u044b\u0445 \u0431\u043e\u0442\u043e\u0432.<\/p>\n<h3>\u041e\u0431\u0437\u043e\u0440 API<\/h3>\n<p>Magic Eden API \u043f\u0440\u0435\u0434\u043e\u0441\u0442\u0430\u0432\u043b\u044f\u0435\u0442 \u0434\u043e\u0441\u0442\u0443\u043f \u043a \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u043c \u043e\u0441\u043d\u043e\u0432\u043d\u044b\u043c \u043a\u0430\u0442\u0435\u0433\u043e\u0440\u0438\u044f\u043c \u0434\u0430\u043d\u043d\u044b\u0445:<\/p>\n<ul>\n<li>\n<p>\u0418\u043d\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u044f \u043e NFT \u0438 \u043a\u043e\u043b\u043b\u0435\u043a\u0446\u0438\u044f\u0445<\/p>\n<\/li>\n<li>\n<p>\u0414\u0430\u043d\u043d\u044b\u0435 \u043e \u043b\u0438\u0441\u0442\u0438\u043d\u0433\u0430\u0445 \u0438 \u043f\u0440\u0435\u0434\u043b\u043e\u0436\u0435\u043d\u0438\u044f\u0445<\/p>\n<\/li>\n<li>\n<p>\u0421\u0442\u0430\u0442\u0438\u0441\u0442\u0438\u043a\u0430 \u0442\u043e\u0440\u0433\u043e\u0432<\/p>\n<\/li>\n<li>\n<p>\u0418\u043d\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u044f \u043e \u043a\u043e\u0448\u0435\u043b\u044c\u043a\u0430\u0445<\/p>\n<\/li>\n<li>\n<p>\u0418\u043d\u0441\u0442\u0440\u0443\u043a\u0446\u0438\u0438 \u0434\u043b\u044f \u0442\u043e\u0440\u0433\u043e\u0432\u044b\u0445 \u043e\u043f\u0435\u0440\u0430\u0446\u0438\u0439<\/p>\n<\/li>\n<li>\n<p>\u041c\u0435\u0442\u0430\u0434\u0430\u043d\u043d\u044b\u0435 \u0438 \u0430\u043d\u0430\u043b\u0438\u0442\u0438\u043a\u0430<\/p>\n<\/li>\n<\/ul>\n<h4>\u0411\u0430\u0437\u043e\u0432\u044b\u0435 \u044d\u043d\u0434\u043f\u043e\u0438\u043d\u0442\u044b<\/h4>\n<pre><code class=\"python\">BASE_URL_MAINNET = \"https:\/\/api-mainnet.magiceden.dev\/v2\" BASE_URL_DEVNET = \"https:\/\/api-devnet.magiceden.dev\/v2\"  ENDPOINTS = {     # NFT \u0438 \u043a\u043e\u043b\u043b\u0435\u043a\u0446\u0438\u0438     \"collections\": \"\/collections\",     \"collection_stats\": \"\/collections\/{symbol}\/stats\",     \"collection_listings\": \"\/collections\/{symbol}\/listings\",          # \u0422\u043e\u043a\u0435\u043d\u044b     \"token_metadata\": \"\/tokens\/{token_mint}\",     \"token_listings\": \"\/tokens\/{token_mint}\/listings\",     \"token_offers\": \"\/tokens\/{token_mint}\/offers\",          # \u041a\u043e\u0448\u0435\u043b\u044c\u043a\u0438     \"wallet_tokens\": \"\/wallets\/{wallet_address}\/tokens\",     \"wallet_activities\": \"\/wallets\/{wallet_address}\/activities\",          # \u0422\u043e\u0440\u0433\u043e\u0432\u044b\u0435 \u043e\u043f\u0435\u0440\u0430\u0446\u0438\u0438     \"create_listing\": \"\/instructions\/sell\",     \"buy_now\": \"\/instructions\/buy_now\",     \"place_bid\": \"\/instructions\/buy\", } <\/code><\/pre>\n<h3>\u041d\u0430\u0441\u0442\u0440\u043e\u0439\u043a\u0430 \u0438 \u0430\u0432\u0442\u043e\u0440\u0438\u0437\u0430\u0446\u0438\u044f<\/h3>\n<h4>\u041f\u043e\u043b\u0443\u0447\u0435\u043d\u0438\u0435 API \u043a\u043b\u044e\u0447\u0430<\/h4>\n<p>\u0414\u043b\u044f \u0440\u0430\u0431\u043e\u0442\u044b \u0441 API \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e \u043f\u043e\u043b\u0443\u0447\u0438\u0442\u044c \u043a\u043b\u044e\u0447. \u041f\u0440\u043e\u0446\u0435\u0441\u0441 \u0440\u0435\u0433\u0438\u0441\u0442\u0440\u0430\u0446\u0438\u0438:<\/p>\n<pre><code class=\"python\">import requests  class MagicEdenClient:     def __init__(self, api_key: str = None):         self.base_url = \"https:\/\/api-mainnet.magiceden.dev\/v2\"         self.session = requests.Session()         if api_key:             self.session.headers.update({                 'Authorization': f'Bearer {api_key}',                 'Content-Type': 'application\/json'             })      def _make_request(self, method: str, endpoint: str, **kwargs):         try:             response = self.session.request(                 method,                 f\"{self.base_url}{endpoint}\",                 **kwargs             )             response.raise_for_status()             return response.json()         except requests.exceptions.RequestException as e:             logger.error(f\"API Error: {e}\")             return None <\/code><\/pre>\n<h3>\u041e\u0441\u043d\u043e\u0432\u043d\u044b\u0435 \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0441\u0442\u0438<\/h3>\n<h4>1. \u0420\u0430\u0431\u043e\u0442\u0430 \u0441 \u043a\u043e\u043b\u043b\u0435\u043a\u0446\u0438\u044f\u043c\u0438<\/h4>\n<pre><code class=\"python\">class CollectionManager:     def __init__(self, client: MagicEdenClient):         self.client = client      def get_collection_stats(self, symbol: str):         \"\"\"\u041f\u043e\u043b\u0443\u0447\u0435\u043d\u0438\u0435 \u0441\u0442\u0430\u0442\u0438\u0441\u0442\u0438\u043a\u0438 \u043a\u043e\u043b\u043b\u0435\u043a\u0446\u0438\u0438\"\"\"         return self.client._make_request('GET', f'\/collections\/{symbol}\/stats')      def get_floor_price(self, symbol: str) -&amp;gt; float:         \"\"\"\u041f\u043e\u043b\u0443\u0447\u0435\u043d\u0438\u0435 \u043c\u0438\u043d\u0438\u043c\u0430\u043b\u044c\u043d\u043e\u0439 \u0446\u0435\u043d\u044b \u0432 \u043a\u043e\u043b\u043b\u0435\u043a\u0446\u0438\u0438\"\"\"         stats = self.get_collection_stats(symbol)         return stats.get('floorPrice', 0) \/ 1e9 if stats else 0      def monitor_floor_price(self, symbol: str, interval: int = 60):         \"\"\"\u041c\u043e\u043d\u0438\u0442\u043e\u0440\u0438\u043d\u0433 \u0438\u0437\u043c\u0435\u043d\u0435\u043d\u0438\u044f \u043c\u0438\u043d\u0438\u043c\u0430\u043b\u044c\u043d\u043e\u0439 \u0446\u0435\u043d\u044b\"\"\"         while True:             price = self.get_floor_price(symbol)             logger.info(f\"Floor price for {symbol}: {price} SOL\")             time.sleep(interval) <\/code><\/pre>\n<h4>2. \u0420\u0430\u0431\u043e\u0442\u0430 \u0441 \u0442\u043e\u043a\u0435\u043d\u0430\u043c\u0438<\/h4>\n<pre><code class=\"python\">class TokenManager:     def __init__(self, client: MagicEdenClient):         self.client = client      def get_token_metadata(self, mint_address: str):         \"\"\"\u041f\u043e\u043b\u0443\u0447\u0435\u043d\u0438\u0435 \u043c\u0435\u0442\u0430\u0434\u0430\u043d\u043d\u044b\u0445 \u0442\u043e\u043a\u0435\u043d\u0430\"\"\"         return self.client._make_request('GET', f'\/tokens\/{mint_address}')      def get_token_listings(self, mint_address: str):         \"\"\"\u041f\u043e\u043b\u0443\u0447\u0435\u043d\u0438\u0435 \u0430\u043a\u0442\u0438\u0432\u043d\u044b\u0445 \u043b\u0438\u0441\u0442\u0438\u043d\u0433\u043e\u0432 \u0442\u043e\u043a\u0435\u043d\u0430\"\"\"         return self.client._make_request('GET', f'\/tokens\/{mint_address}\/listings')      async def monitor_token_price(self, mint_address: str):         \"\"\"\u0410\u0441\u0438\u043d\u0445\u0440\u043e\u043d\u043d\u044b\u0439 \u043c\u043e\u043d\u0438\u0442\u043e\u0440\u0438\u043d\u0433 \u0446\u0435\u043d\u044b \u0442\u043e\u043a\u0435\u043d\u0430\"\"\"         while True:             listings = self.get_token_listings(mint_address)             if listings:                 min_price = min(listing['price'] for listing in listings)                 logger.info(f\"Lowest price for {mint_address}: {min_price} SOL\")             await asyncio.sleep(30) <\/code><\/pre>\n<h3>\u0418\u0434\u0435\u0438 \u0434\u043b\u044f \u043f\u0440\u043e\u0435\u043a\u0442\u043e\u0432<\/h3>\n<h4>1. NFT \u0410\u0440\u0431\u0438\u0442\u0440\u0430\u0436\u043d\u044b\u0439 \u0431\u043e\u0442<\/h4>\n<p>\u0418\u0434\u0435\u044f: \u041f\u043e\u0438\u0441\u043a \u0446\u0435\u043d\u043e\u0432\u044b\u0445 \u0440\u0430\u0437\u043b\u0438\u0447\u0438\u0439 \u043c\u0435\u0436\u0434\u0443 Magic Eden \u0438 \u0434\u0440\u0443\u0433\u0438\u043c\u0438 \u043c\u0430\u0440\u043a\u0435\u0442\u043f\u043b\u0435\u0439\u0441\u0430\u043c\u0438.<\/p>\n<pre><code class=\"python\">class ArbitrageBot:     def __init__(self, me_client: MagicEdenClient, other_marketplace_client):         self.me_client = me_client         self.other_client = other_marketplace_client         self.min_profit = 0.5  # \u041c\u0438\u043d\u0438\u043c\u0430\u043b\u044c\u043d\u0430\u044f \u043f\u0440\u0438\u0431\u044b\u043b\u044c \u0432 SOL      async def find_opportunities(self, collection_symbol: str):         me_listings = await self.me_client.get_collection_listings(collection_symbol)         other_listings = await self.other_client.get_collection_listings(collection_symbol)          for me_listing in me_listings:             for other_listing in other_listings:                 if me_listing['tokenMint'] == other_listing['tokenMint']:                     profit = other_listing['price'] - me_listing['price']                     if profit &amp;gt; self.min_profit:                         await self.execute_arbitrage(me_listing, other_listing) <\/code><\/pre>\n<h4>2. NFT \u0421\u043d\u0430\u0439\u043f\u0435\u0440<\/h4>\n<p>\u0418\u0434\u0435\u044f: \u0410\u0432\u0442\u043e\u043c\u0430\u0442\u0438\u0447\u0435\u0441\u043a\u0430\u044f \u043f\u043e\u043a\u0443\u043f\u043a\u0430 NFT \u043f\u043e \u0437\u0430\u0434\u0430\u043d\u043d\u044b\u043c \u043a\u0440\u0438\u0442\u0435\u0440\u0438\u044f\u043c.<\/p>\n<pre><code class=\"python\">class NFTSniper:     def __init__(self, client: MagicEdenClient):         self.client = client         self.target_collections = []         self.max_prices = {}      async def add_target(self, collection: str, max_price: float):         self.target_collections.append(collection)         self.max_prices[collection] = max_price      async def monitor_listings(self):         while True:             for collection in self.target_collections:                 listings = await self.client.get_collection_listings(collection)                 for listing in listings:                     if listing['price'] &amp;lt;= self.max_prices[collection]:                         await self.buy_nft(listing)             await asyncio.sleep(1)      async def buy_nft(self, listing):         try:             instruction = await self.client.get_buy_instruction(listing['tokenMint'])             # \u0412\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u0435 \u0442\u0440\u0430\u043d\u0437\u0430\u043a\u0446\u0438\u0438 \u043f\u043e\u043a\u0443\u043f\u043a\u0438             transaction = await self.execute_transaction(instruction)             logger.info(f\"Successfully bought NFT: {listing['tokenMint']}\")         except Exception as e:             logger.error(f\"Failed to buy NFT: {e}\") <\/code><\/pre>\n<p>\u0412\u0441\u0435 \u0432\u044b\u0448\u0435 \u043f\u0435\u0440\u0435\u0447\u0438\u0441\u043b\u0435\u043d\u043d\u043e\u0435, \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u043f\u0440\u0438\u043c\u0435\u0440\u043e\u043c \u0447\u0430\u0441\u0442\u0438 \u043a\u0430\u043a\u043e\u0433\u043e-\u0442\u043e \u0431\u043e\u043b\u044c\u0448\u043e\u0433\u043e \u043a\u043e\u0434\u0430 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f \u0438 \u0442\u0443\u0442 \u043e\u043f\u0438\u0441\u0430\u043d \u043b\u0438\u0448\u044c \u043f\u0440\u0438\u043c\u0435\u0440\u043d\u044b\u0439 \u0430\u043b\u0433\u043e\u0440\u0438\u0442\u043c, \u0447\u0442\u043e \u0431\u044b \u0434\u0430\u0442\u044c \u0432\u0430\u043c \u043f\u043e\u0447\u0432\u0443 \u0434\u043b\u044f \u0440\u0430\u0437\u043c\u044b\u0448\u043b\u0435\u043d\u0438\u0439. <\/p>\n<h3>\u041b\u0443\u0447\u0448\u0438\u0435 \u043f\u0440\u0430\u043a\u0442\u0438\u043a\u0438<\/h3>\n<ol>\n<li>\n<p>\u041e\u0431\u0440\u0430\u0431\u043e\u0442\u043a\u0430 \u043e\u0448\u0438\u0431\u043e\u043a \u0438 \u043f\u043e\u0432\u0442\u043e\u0440\u043d\u044b\u0435 \u043f\u043e\u043f\u044b\u0442\u043a\u0438:<\/p>\n<\/li>\n<\/ol>\n<pre><code class=\"python\">from tenacity import retry, stop_after_attempt, wait_exponential  class RobustClient:     @retry(stop=stop_after_attempt(3), wait=wait_exponential(multiplier=1, min=4, max=10))     async def make_request(self, endpoint: str):         try:             response = await self.session.get(f\"{self.base_url}{endpoint}\")             response.raise_for_status()             return response.json()         except Exception as e:             logger.error(f\"Request failed: {e}\")             raise <\/code><\/pre>\n<ol start=\"2\">\n<li>\n<p>\u041a\u044d\u0448\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u0435 \u0434\u0430\u043d\u043d\u044b\u0445:<\/p>\n<\/li>\n<\/ol>\n<pre><code class=\"python\">from functools import lru_cache import time  class CachedClient:     @lru_cache(maxsize=100)     def get_collection_stats(self, symbol: str):         return self.client._make_request('GET', f'\/collections\/{symbol}\/stats')      def clear_cache(self):         self.get_collection_stats.cache_clear() <\/code><\/pre>\n<ol start=\"3\">\n<li>\n<p>\u0423\u043f\u0440\u0430\u0432\u043b\u0435\u043d\u0438\u0435 rate limits:<\/p>\n<\/li>\n<\/ol>\n<pre><code class=\"python\">class RateLimitedClient:     def __init__(self, max_requests_per_minute: int = 120):         self.requests = []         self.max_requests = max_requests_per_minute      async def make_request(self, endpoint: str):         now = time.time()         # \u041e\u0447\u0438\u0441\u0442\u043a\u0430 \u0441\u0442\u0430\u0440\u044b\u0445 \u0437\u0430\u043f\u0440\u043e\u0441\u043e\u0432         self.requests = [req for req in self.requests if now - req &amp;lt; 60]                  if len(self.requests) &amp;gt;= self.max_requests:             wait_time = 60 - (now - self.requests[0])             await asyncio.sleep(wait_time)                  self.requests.append(now)         return await self._make_request(endpoint) <\/code><\/pre>\n<h3>\u0417\u0430\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u0435<\/h3>\n<p>Magic Eden API \u043f\u0440\u0435\u0434\u043e\u0441\u0442\u0430\u0432\u043b\u044f\u0435\u0442 \u043c\u043e\u0449\u043d\u044b\u0435 \u0438\u043d\u0441\u0442\u0440\u0443\u043c\u0435\u043d\u0442\u044b \u0434\u043b\u044f \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u044f \u0440\u0430\u0437\u043b\u0438\u0447\u043d\u044b\u0445 NFT-\u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0439. \u041c\u044b \u0440\u0430\u0441\u0441\u043c\u043e\u0442\u0440\u0435\u043b\u0438 \u043e\u0441\u043d\u043e\u0432\u043d\u044b\u0435 \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0441\u0442\u0438 API \u0438 \u043f\u0440\u0438\u043c\u0435\u0440\u044b \u0438\u0445 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u044f, \u0430 \u0442\u0430\u043a\u0436\u0435 \u043f\u043e\u0434\u0435\u043b\u0438\u043b\u0438\u0441\u044c \u0438\u0434\u0435\u044f\u043c\u0438 \u0434\u043b\u044f \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u044f \u043f\u0440\u043e\u0435\u043a\u0442\u043e\u0432.<\/p>\n<h4>\u041f\u043e\u043b\u0435\u0437\u043d\u044b\u0435 \u0441\u0441\u044b\u043b\u043a\u0438:<\/h4>\n<ul>\n<li>\n<p><a href=\"https:\/\/docs.magiceden.io\/\" rel=\"noopener noreferrer nofollow\">\u041e\u0444\u0438\u0446\u0438\u0430\u043b\u044c\u043d\u0430\u044f \u0434\u043e\u043a\u0443\u043c\u0435\u043d\u0442\u0430\u0446\u0438\u044f Magic Eden<\/a><\/p>\n<\/li>\n<li>\n<p><a href=\"https:\/\/github.com\/magiceden-oss\" rel=\"noopener noreferrer nofollow\">GitHub \u0440\u0435\u043f\u043e\u0437\u0438\u0442\u043e\u0440\u0438\u0439 \u0441 \u043f\u0440\u0438\u043c\u0435\u0440\u0430\u043c\u0438<\/a><\/p>\n<\/li>\n<li>\n<p><a href=\"https:\/\/discord.gg\/magiceden\" rel=\"noopener noreferrer nofollow\">Discord \u0441\u043e\u043e\u0431\u0449\u0435\u0441\u0442\u0432\u043e Magic Eden<\/a><\/p>\n<\/li>\n<\/ul>\n<h4>P.S.<\/h4>\n<p>\u0415\u0441\u043b\u0438 \u0443 \u0432\u0430\u0441 \u0435\u0441\u0442\u044c \u0432\u043e\u043f\u0440\u043e\u0441\u044b \u0438\u043b\u0438 \u0432\u044b \u0445\u043e\u0442\u0438\u0442\u0435 \u043f\u043e\u0434\u0435\u043b\u0438\u0442\u044c\u0441\u044f \u0441\u0432\u043e\u0438\u043c \u043e\u043f\u044b\u0442\u043e\u043c \u0440\u0430\u0431\u043e\u0442\u044b \u0441 Magic Eden API, \u043f\u0438\u0448\u0438\u0442\u0435 \u0432 \u043a\u043e\u043c\u043c\u0435\u043d\u0442\u0430\u0440\u0438\u044f\u0445.<\/p>\n<\/div>\n<\/div>\n<\/div>\n<p><!----><!----><\/div>\n<p><!----><\/p>\n<div class=\"tm-article-poll-container\"><!--[--><\/p>\n<div class=\"tm-article-poll tm-article-poll_variant-bordered\">\n<div class=\"tm-notice tm-notice_positive tm-article-poll__notice\"><!----><\/p>\n<div class=\"tm-notice__inner\"><!----><\/p>\n<div class=\"tm-notice__content\" data-test-id=\"notice-content\"><!--[--><span>\u0422\u043e\u043b\u044c\u043a\u043e \u0437\u0430\u0440\u0435\u0433\u0438\u0441\u0442\u0440\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u044b\u0435 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u0438 \u043c\u043e\u0433\u0443\u0442 \u0443\u0447\u0430\u0441\u0442\u0432\u043e\u0432\u0430\u0442\u044c \u0432 \u043e\u043f\u0440\u043e\u0441\u0435. <a rel=\"nofollow\" href=\"\/kek\/v1\/auth\/habrahabr\/?back=\/ru\/articles\/913414\/&#038;hl=ru\">\u0412\u043e\u0439\u0434\u0438\u0442\u0435<\/a>, \u043f\u043e\u0436\u0430\u043b\u0443\u0439\u0441\u0442\u0430.<\/span><!--]--><\/div>\n<\/div>\n<\/div>\n<p><!--[--><\/p>\n<div class=\"tm-article-poll__header\">\u041a\u0430\u043a\u043e\u0439 \u043f\u0440\u043e\u0435\u043a\u0442 \u0432\u044b \u0431\u044b \u0445\u043e\u0442\u0435\u043b\u0438 \u0440\u0435\u0430\u043b\u0438\u0437\u043e\u0432\u0430\u0442\u044c?<\/div>\n<div class=\"tm-article-poll__answers\"><!--[--><\/p>\n<div class=\"tm-article-poll__answer\">\n<div class=\"tm-article-poll__answer-data\"><span class=\"tm-article-poll__answer-percent tm-article-poll__answer-percent_winning\">100% <\/span><span class=\"tm-article-poll__answer-label\">NFT \u0410\u0440\u0431\u0438\u0442\u0440\u0430\u0436\u043d\u044b\u0439 \u0431\u043e\u0442<\/span><span class=\"tm-article-poll__answer-votes\">2<\/span><\/div>\n<div class=\"tm-article-poll__answer-bar\">\n<div class=\"tm-article-poll__answer-progress tm-article-poll__answer-progress_winning\" style=\"width: 100%\"><\/div>\n<\/div>\n<\/div>\n<div class=\"tm-article-poll__answer\">\n<div class=\"tm-article-poll__answer-data\"><span class=\"tm-article-poll__answer-percent\">50% <\/span><span class=\"tm-article-poll__answer-label\">NFT \u0421\u043d\u0430\u0439\u043f\u0435\u0440<\/span><span class=\"tm-article-poll__answer-votes\">1<\/span><\/div>\n<div class=\"tm-article-poll__answer-bar\">\n<div class=\"tm-article-poll__answer-progress\" style=\"width: 50%\"><\/div>\n<\/div>\n<\/div>\n<div class=\"tm-article-poll__answer\">\n<div class=\"tm-article-poll__answer-data\"><span class=\"tm-article-poll__answer-percent\">0% <\/span><span class=\"tm-article-poll__answer-label\">\u0421\u0432\u043e\u0439 \u0432\u0430\u0440\u0438\u0430\u043d\u0442 \u0432 \u043a\u043e\u043c\u043c\u0435\u043d\u0442\u044b<\/span><span class=\"tm-article-poll__answer-votes\">0<\/span><\/div>\n<div class=\"tm-article-poll__answer-bar\">\n<div class=\"tm-article-poll__answer-progress\" style=\"width: 0%\"><\/div>\n<\/div>\n<\/div>\n<p><!--]--><\/div>\n<div class=\"tm-article-poll__stats\"> \u041f\u0440\u043e\u0433\u043e\u043b\u043e\u0441\u043e\u0432\u0430\u043b\u0438 2 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044f.    \u0412\u043e\u0437\u0434\u0435\u0440\u0436\u0430\u043b\u0441\u044f 1 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044c. <\/div>\n<p><!--]--><\/div>\n<p><!--]--><\/div>\n<p> \u0441\u0441\u044b\u043b\u043a\u0430 \u043d\u0430 \u043e\u0440\u0438\u0433\u0438\u043d\u0430\u043b \u0441\u0442\u0430\u0442\u044c\u0438 <a href=\"https:\/\/habr.com\/ru\/articles\/913414\/\"> https:\/\/habr.com\/ru\/articles\/913414\/<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<div><!--[--><!--]--><\/div>\n<div id=\"post-content-body\">\n<div>\n<div class=\"article-formatted-body article-formatted-body article-formatted-body_version-2\">\n<div xmlns=\"http:\/\/www.w3.org\/1999\/xhtml\">\n<p>\u041f\u0440\u0438\u0432\u0435\u0442, \u0425\u0430\u0431\u0440! \u0412 \u044d\u0442\u043e\u0439 \u0441\u0442\u0430\u0442\u044c\u0435 \u044f \u0440\u0430\u0441\u0441\u043a\u0430\u0436\u0443 \u043e \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0441\u0442\u044f\u0445 API Magic Eden &#8212; \u043e\u0434\u043d\u043e\u0433\u043e \u0438\u0437 \u043a\u0440\u0443\u043f\u043d\u0435\u0439\u0448\u0438\u0445 NFT-\u043c\u0430\u0440\u043a\u0435\u0442\u043f\u043b\u0435\u0439\u0441\u043e\u0432, \u0432 \u0441\u0442\u0430\u0442\u044c\u0435 \u0437\u0430\u0442\u0440\u043e\u043d\u0443 \u043d\u0435\u043f\u043e\u0441\u0440\u0435\u0434\u0441\u0442\u0432\u0435\u043d\u043d\u043e \u043c\u0435\u0442\u043e\u0434\u044b \u0441\u043e\u043b\u0430\u043d\u044b, \u0438 \u043f\u043e\u043a\u0430\u0436\u0443, \u043a\u0430\u043a \u0441 \u0435\u0433\u043e \u043f\u043e\u043c\u043e\u0449\u044c\u044e \u043c\u043e\u0436\u043d\u043e \u0441\u043e\u0437\u0434\u0430\u0432\u0430\u0442\u044c \u0438\u043d\u0442\u0435\u0440\u0435\u0441\u043d\u044b\u0435 \u043f\u0440\u043e\u0435\u043a\u0442\u044b.<\/p>\n<h3>\u0412\u0432\u0435\u0434\u0435\u043d\u0438\u0435<\/h3>\n<p>Magic Eden \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u0432\u0435\u0434\u0443\u0449\u0438\u043c NFT-\u043c\u0430\u0440\u043a\u0435\u0442\u043f\u043b\u0435\u0439\u0441\u043e\u043c \u0441 \u0435\u0436\u0435\u043c\u0435\u0441\u044f\u0447\u043d\u044b\u043c \u043e\u0431\u044a\u0435\u043c\u043e\u043c \u0442\u043e\u0440\u0433\u043e\u0432 \u0431\u043e\u043b\u0435\u0435 $100 \u043c\u0438\u043b\u043b\u0438\u043e\u043d\u043e\u0432. API \u043f\u043b\u0430\u0442\u0444\u043e\u0440\u043c\u044b \u043e\u0442\u043a\u0440\u044b\u0432\u0430\u0435\u0442 \u0448\u0438\u0440\u043e\u043a\u0438\u0435 \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0441\u0442\u0438 \u0434\u043b\u044f \u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u0447\u0438\u043a\u043e\u0432, \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u044f \u0441\u043e\u0437\u0434\u0430\u0432\u0430\u0442\u044c \u0440\u0430\u0437\u043b\u0438\u0447\u043d\u044b\u0435 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f: \u043e\u0442 \u043f\u0440\u043e\u0441\u0442\u044b\u0445 NFT-\u0442\u0440\u0435\u043a\u0435\u0440\u043e\u0432 \u0434\u043e \u0441\u043b\u043e\u0436\u043d\u044b\u0445 \u0442\u043e\u0440\u0433\u043e\u0432\u044b\u0445 \u0431\u043e\u0442\u043e\u0432.<\/p>\n<h3>\u041e\u0431\u0437\u043e\u0440 API<\/h3>\n<p>Magic Eden API \u043f\u0440\u0435\u0434\u043e\u0441\u0442\u0430\u0432\u043b\u044f\u0435\u0442 \u0434\u043e\u0441\u0442\u0443\u043f \u043a \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u043c \u043e\u0441\u043d\u043e\u0432\u043d\u044b\u043c \u043a\u0430\u0442\u0435\u0433\u043e\u0440\u0438\u044f\u043c \u0434\u0430\u043d\u043d\u044b\u0445:<\/p>\n<ul>\n<li>\n<p>\u0418\u043d\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u044f \u043e NFT \u0438 \u043a\u043e\u043b\u043b\u0435\u043a\u0446\u0438\u044f\u0445<\/p>\n<\/li>\n<li>\n<p>\u0414\u0430\u043d\u043d\u044b\u0435 \u043e \u043b\u0438\u0441\u0442\u0438\u043d\u0433\u0430\u0445 \u0438 \u043f\u0440\u0435\u0434\u043b\u043e\u0436\u0435\u043d\u0438\u044f\u0445<\/p>\n<\/li>\n<li>\n<p>\u0421\u0442\u0430\u0442\u0438\u0441\u0442\u0438\u043a\u0430 \u0442\u043e\u0440\u0433\u043e\u0432<\/p>\n<\/li>\n<li>\n<p>\u0418\u043d\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u044f \u043e \u043a\u043e\u0448\u0435\u043b\u044c\u043a\u0430\u0445<\/p>\n<\/li>\n<li>\n<p>\u0418\u043d\u0441\u0442\u0440\u0443\u043a\u0446\u0438\u0438 \u0434\u043b\u044f \u0442\u043e\u0440\u0433\u043e\u0432\u044b\u0445 \u043e\u043f\u0435\u0440\u0430\u0446\u0438\u0439<\/p>\n<\/li>\n<li>\n<p>\u041c\u0435\u0442\u0430\u0434\u0430\u043d\u043d\u044b\u0435 \u0438 \u0430\u043d\u0430\u043b\u0438\u0442\u0438\u043a\u0430<\/p>\n<\/li>\n<\/ul>\n<h4>\u0411\u0430\u0437\u043e\u0432\u044b\u0435 \u044d\u043d\u0434\u043f\u043e\u0438\u043d\u0442\u044b<\/h4>\n<pre><code class=\"python\">BASE_URL_MAINNET = \"https:\/\/api-mainnet.magiceden.dev\/v2\" BASE_URL_DEVNET = \"https:\/\/api-devnet.magiceden.dev\/v2\"  ENDPOINTS = {     # NFT \u0438 \u043a\u043e\u043b\u043b\u0435\u043a\u0446\u0438\u0438     \"collections\": \"\/collections\",     \"collection_stats\": \"\/collections\/{symbol}\/stats\",     \"collection_listings\": \"\/collections\/{symbol}\/listings\",          # \u0422\u043e\u043a\u0435\u043d\u044b     \"token_metadata\": \"\/tokens\/{token_mint}\",     \"token_listings\": \"\/tokens\/{token_mint}\/listings\",     \"token_offers\": \"\/tokens\/{token_mint}\/offers\",          # \u041a\u043e\u0448\u0435\u043b\u044c\u043a\u0438     \"wallet_tokens\": \"\/wallets\/{wallet_address}\/tokens\",     \"wallet_activities\": \"\/wallets\/{wallet_address}\/activities\",          # \u0422\u043e\u0440\u0433\u043e\u0432\u044b\u0435 \u043e\u043f\u0435\u0440\u0430\u0446\u0438\u0438     \"create_listing\": \"\/instructions\/sell\",     \"buy_now\": \"\/instructions\/buy_now\",     \"place_bid\": \"\/instructions\/buy\", } <\/code><\/pre>\n<h3>\u041d\u0430\u0441\u0442\u0440\u043e\u0439\u043a\u0430 \u0438 \u0430\u0432\u0442\u043e\u0440\u0438\u0437\u0430\u0446\u0438\u044f<\/h3>\n<h4>\u041f\u043e\u043b\u0443\u0447\u0435\u043d\u0438\u0435 API \u043a\u043b\u044e\u0447\u0430<\/h4>\n<p>\u0414\u043b\u044f \u0440\u0430\u0431\u043e\u0442\u044b \u0441 API \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e \u043f\u043e\u043b\u0443\u0447\u0438\u0442\u044c \u043a\u043b\u044e\u0447. \u041f\u0440\u043e\u0446\u0435\u0441\u0441 \u0440\u0435\u0433\u0438\u0441\u0442\u0440\u0430\u0446\u0438\u0438:<\/p>\n<pre><code class=\"python\">import requests  class MagicEdenClient:     def __init__(self, api_key: str = None):         self.base_url = \"https:\/\/api-mainnet.magiceden.dev\/v2\"         self.session = requests.Session()         if api_key:             self.session.headers.update({                 'Authorization': f'Bearer {api_key}',                 'Content-Type': 'application\/json'             })      def _make_request(self, method: str, endpoint: str, **kwargs):         try:             response = self.session.request(                 method,                 f\"{self.base_url}{endpoint}\",                 **kwargs             )             response.raise_for_status()             return response.json()         except requests.exceptions.RequestException as e:             logger.error(f\"API Error: {e}\")             return None <\/code><\/pre>\n<h3>\u041e\u0441\u043d\u043e\u0432\u043d\u044b\u0435 \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0441\u0442\u0438<\/h3>\n<h4>1. \u0420\u0430\u0431\u043e\u0442\u0430 \u0441 \u043a\u043e\u043b\u043b\u0435\u043a\u0446\u0438\u044f\u043c\u0438<\/h4>\n<pre><code class=\"python\">class CollectionManager:     def __init__(self, client: MagicEdenClient):         self.client = client      def get_collection_stats(self, symbol: str):         \"\"\"\u041f\u043e\u043b\u0443\u0447\u0435\u043d\u0438\u0435 \u0441\u0442\u0430\u0442\u0438\u0441\u0442\u0438\u043a\u0438 \u043a\u043e\u043b\u043b\u0435\u043a\u0446\u0438\u0438\"\"\"         return self.client._make_request('GET', f'\/collections\/{symbol}\/stats')      def get_floor_price(self, symbol: str) -&amp;gt; float:         \"\"\"\u041f\u043e\u043b\u0443\u0447\u0435\u043d\u0438\u0435 \u043c\u0438\u043d\u0438\u043c\u0430\u043b\u044c\u043d\u043e\u0439 \u0446\u0435\u043d\u044b \u0432 \u043a\u043e\u043b\u043b\u0435\u043a\u0446\u0438\u0438\"\"\"         stats = self.get_collection_stats(symbol)         return stats.get('floorPrice', 0) \/ 1e9 if stats else 0      def monitor_floor_price(self, symbol: str, interval: int = 60):         \"\"\"\u041c\u043e\u043d\u0438\u0442\u043e\u0440\u0438\u043d\u0433 \u0438\u0437\u043c\u0435\u043d\u0435\u043d\u0438\u044f \u043c\u0438\u043d\u0438\u043c\u0430\u043b\u044c\u043d\u043e\u0439 \u0446\u0435\u043d\u044b\"\"\"         while True:             price = self.get_floor_price(symbol)             logger.info(f\"Floor price for {symbol}: {price} SOL\")             time.sleep(interval) <\/code><\/pre>\n<h4>2. \u0420\u0430\u0431\u043e\u0442\u0430 \u0441 \u0442\u043e\u043a\u0435\u043d\u0430\u043c\u0438<\/h4>\n<pre><code class=\"python\">class TokenManager:     def __init__(self, client: MagicEdenClient):         self.client = client      def get_token_metadata(self, mint_address: str):         \"\"\"\u041f\u043e\u043b\u0443\u0447\u0435\u043d\u0438\u0435 \u043c\u0435\u0442\u0430\u0434\u0430\u043d\u043d\u044b\u0445 \u0442\u043e\u043a\u0435\u043d\u0430\"\"\"         return self.client._make_request('GET', f'\/tokens\/{mint_address}')      def get_token_listings(self, mint_address: str):         \"\"\"\u041f\u043e\u043b\u0443\u0447\u0435\u043d\u0438\u0435 \u0430\u043a\u0442\u0438\u0432\u043d\u044b\u0445 \u043b\u0438\u0441\u0442\u0438\u043d\u0433\u043e\u0432 \u0442\u043e\u043a\u0435\u043d\u0430\"\"\"         return self.client._make_request('GET', f'\/tokens\/{mint_address}\/listings')      async def monitor_token_price(self, mint_address: str):         \"\"\"\u0410\u0441\u0438\u043d\u0445\u0440\u043e\u043d\u043d\u044b\u0439 \u043c\u043e\u043d\u0438\u0442\u043e\u0440\u0438\u043d\u0433 \u0446\u0435\u043d\u044b \u0442\u043e\u043a\u0435\u043d\u0430\"\"\"         while True:             listings = self.get_token_listings(mint_address)             if listings:                 min_price = min(listing['price'] for listing in listings)                 logger.info(f\"Lowest price for {mint_address}: {min_price} SOL\")             await asyncio.sleep(30) <\/code><\/pre>\n<h3>\u0418\u0434\u0435\u0438 \u0434\u043b\u044f \u043f\u0440\u043e\u0435\u043a\u0442\u043e\u0432<\/h3>\n<h4>1. NFT \u0410\u0440\u0431\u0438\u0442\u0440\u0430\u0436\u043d\u044b\u0439 \u0431\u043e\u0442<\/h4>\n<p>\u0418\u0434\u0435\u044f: \u041f\u043e\u0438\u0441\u043a \u0446\u0435\u043d\u043e\u0432\u044b\u0445 \u0440\u0430\u0437\u043b\u0438\u0447\u0438\u0439 \u043c\u0435\u0436\u0434\u0443 Magic Eden \u0438 \u0434\u0440\u0443\u0433\u0438\u043c\u0438 \u043c\u0430\u0440\u043a\u0435\u0442\u043f\u043b\u0435\u0439\u0441\u0430\u043c\u0438.<\/p>\n<pre><code class=\"python\">class ArbitrageBot:     def __init__(self, me_client: MagicEdenClient, other_marketplace_client):         self.me_client = me_client         self.other_client = other_marketplace_client         self.min_profit = 0.5  # \u041c\u0438\u043d\u0438\u043c\u0430\u043b\u044c\u043d\u0430\u044f \u043f\u0440\u0438\u0431\u044b\u043b\u044c \u0432 SOL      async def find_opportunities(self, collection_symbol: str):         me_listings = await self.me_client.get_collection_listings(collection_symbol)         other_listings = await self.other_client.get_collection_listings(collection_symbol)          for me_listing in me_listings:             for other_listing in other_listings:                 if me_listing['tokenMint'] == other_listing['tokenMint']:                     profit = other_listing['price'] - me_listing['price']                     if profit &amp;gt; self.min_profit:                         await self.execute_arbitrage(me_listing, other_listing) <\/code><\/pre>\n<h4>2. NFT \u0421\u043d\u0430\u0439\u043f\u0435\u0440<\/h4>\n<p>\u0418\u0434\u0435\u044f: \u0410\u0432\u0442\u043e\u043c\u0430\u0442\u0438\u0447\u0435\u0441\u043a\u0430\u044f \u043f\u043e\u043a\u0443\u043f\u043a\u0430 NFT \u043f\u043e \u0437\u0430\u0434\u0430\u043d\u043d\u044b\u043c \u043a\u0440\u0438\u0442\u0435\u0440\u0438\u044f\u043c.<\/p>\n<pre><code class=\"python\">class NFTSniper:     def __init__(self, client: MagicEdenClient):         self.client = client         self.target_collections = []         self.max_prices = {}      async def add_target(self, collection: str, max_price: float):         self.target_collections.append(collection)         self.max_prices[collection] = max_price      async def monitor_listings(self):         while True:             for collection in self.target_collections:                 listings = await self.client.get_collection_listings(collection)                 for listing in listings:                     if listing['price'] &amp;lt;= self.max_prices[collection]:                         await self.buy_nft(listing)             await asyncio.sleep(1)      async def buy_nft(self, listing):         try:             instruction = await self.client.get_buy_instruction(listing['tokenMint'])             # \u0412\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u0435 \u0442\u0440\u0430\u043d\u0437\u0430\u043a\u0446\u0438\u0438 \u043f\u043e\u043a\u0443\u043f\u043a\u0438             transaction = await self.execute_transaction(instruction)             logger.info(f\"Successfully bought NFT: {listing['tokenMint']}\")         except Exception as e:             logger.error(f\"Failed to buy NFT: {e}\") <\/code><\/pre>\n<p>\u0412\u0441\u0435 \u0432\u044b\u0448\u0435 \u043f\u0435\u0440\u0435\u0447\u0438\u0441\u043b\u0435\u043d\u043d\u043e\u0435, \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u043f\u0440\u0438\u043c\u0435\u0440\u043e\u043c \u0447\u0430\u0441\u0442\u0438 \u043a\u0430\u043a\u043e\u0433\u043e-\u0442\u043e \u0431\u043e\u043b\u044c\u0448\u043e\u0433\u043e \u043a\u043e\u0434\u0430 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f \u0438 \u0442\u0443\u0442 \u043e\u043f\u0438\u0441\u0430\u043d \u043b\u0438\u0448\u044c \u043f\u0440\u0438\u043c\u0435\u0440\u043d\u044b\u0439 \u0430\u043b\u0433\u043e\u0440\u0438\u0442\u043c, \u0447\u0442\u043e \u0431\u044b \u0434\u0430\u0442\u044c \u0432\u0430\u043c \u043f\u043e\u0447\u0432\u0443 \u0434\u043b\u044f \u0440\u0430\u0437\u043c\u044b\u0448\u043b\u0435\u043d\u0438\u0439. <\/p>\n<h3>\u041b\u0443\u0447\u0448\u0438\u0435 \u043f\u0440\u0430\u043a\u0442\u0438\u043a\u0438<\/h3>\n<ol>\n<li>\n<p>\u041e\u0431\u0440\u0430\u0431\u043e\u0442\u043a\u0430 \u043e\u0448\u0438\u0431\u043e\u043a \u0438 \u043f\u043e\u0432\u0442\u043e\u0440\u043d\u044b\u0435 \u043f\u043e\u043f\u044b\u0442\u043a\u0438:<\/p>\n<\/li>\n<\/ol>\n<pre><code class=\"python\">from tenacity import retry, stop_after_attempt, wait_exponential  class RobustClient:     @retry(stop=stop_after_attempt(3), wait=wait_exponential(multiplier=1, min=4, max=10))     async def make_request(self, endpoint: str):         try:             response = await self.session.get(f\"{self.base_url}{endpoint}\")             response.raise_for_status()             return response.json()         except Exception as e:             logger.error(f\"Request failed: {e}\")             raise <\/code><\/pre>\n<ol start=\"2\">\n<li>\n<p>\u041a\u044d\u0448\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u0435 \u0434\u0430\u043d\u043d\u044b\u0445:<\/p>\n<\/li>\n<\/ol>\n<pre><code class=\"python\">from functools import lru_cache import time  class CachedClient:     @lru_cache(maxsize=100)     def get_collection_stats(self, symbol: str):         return self.client._make_request('GET', f'\/collections\/{symbol}\/stats')      def clear_cache(self):         self.get_collection_stats.cache_clear() <\/code><\/pre>\n<ol start=\"3\">\n<li>\n<p>\u0423\u043f\u0440\u0430\u0432\u043b\u0435\u043d\u0438\u0435 rate limits:<\/p>\n<\/li>\n<\/ol>\n<pre><code class=\"python\">class RateLimitedClient:     def __init__(self, max_requests_per_minute: int = 120):         self.requests = []         self.max_requests = max_requests_per_minute      async def make_request(self, endpoint: str):         now = time.time()         # \u041e\u0447\u0438\u0441\u0442\u043a\u0430 \u0441\u0442\u0430\u0440\u044b\u0445 \u0437\u0430\u043f\u0440\u043e\u0441\u043e\u0432         self.requests = [req for req in self.requests if now - req &amp;lt; 60]                  if len(self.requests) &amp;gt;= self.max_requests:             wait_time = 60 - (now - self.requests[0])             await asyncio.sleep(wait_time)                  self.requests.append(now)         return await self._make_request(endpoint) <\/code><\/pre>\n<h3>\u0417\u0430\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u0435<\/h3>\n<p>Magic Eden API \u043f\u0440\u0435\u0434\u043e\u0441\u0442\u0430\u0432\u043b\u044f\u0435\u0442 \u043c\u043e\u0449\u043d\u044b\u0435 \u0438\u043d\u0441\u0442\u0440\u0443\u043c\u0435\u043d\u0442\u044b \u0434\u043b\u044f \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u044f \u0440\u0430\u0437\u043b\u0438\u0447\u043d\u044b\u0445 NFT-\u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0439. \u041c\u044b \u0440\u0430\u0441\u0441\u043c\u043e\u0442\u0440\u0435\u043b\u0438 \u043e\u0441\u043d\u043e\u0432\u043d\u044b\u0435 \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0441\u0442\u0438 API \u0438 \u043f\u0440\u0438\u043c\u0435\u0440\u044b \u0438\u0445 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u044f, \u0430 \u0442\u0430\u043a\u0436\u0435 \u043f\u043e\u0434\u0435\u043b\u0438\u043b\u0438\u0441\u044c \u0438\u0434\u0435\u044f\u043c\u0438 \u0434\u043b\u044f \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u044f \u043f\u0440\u043e\u0435\u043a\u0442\u043e\u0432.<\/p>\n<h4>\u041f\u043e\u043b\u0435\u0437\u043d\u044b\u0435 \u0441\u0441\u044b\u043b\u043a\u0438:<\/h4>\n<ul>\n<li>\n<p><a href=\"https:\/\/docs.magiceden.io\/\" rel=\"noopener noreferrer nofollow\">\u041e\u0444\u0438\u0446\u0438\u0430\u043b\u044c\u043d\u0430\u044f \u0434\u043e\u043a\u0443\u043c\u0435\u043d\u0442\u0430\u0446\u0438\u044f Magic Eden<\/a><\/p>\n<\/li>\n<li>\n<p><a href=\"https:\/\/github.com\/magiceden-oss\" rel=\"noopener noreferrer nofollow\">GitHub \u0440\u0435\u043f\u043e\u0437\u0438\u0442\u043e\u0440\u0438\u0439 \u0441 \u043f\u0440\u0438\u043c\u0435\u0440\u0430\u043c\u0438<\/a><\/p>\n<\/li>\n<li>\n<p><a href=\"https:\/\/discord.gg\/magiceden\" rel=\"noopener noreferrer nofollow\">Discord \u0441\u043e\u043e\u0431\u0449\u0435\u0441\u0442\u0432\u043e Magic Eden<\/a><\/p>\n<\/li>\n<\/ul>\n<h4>P.S.<\/h4>\n<p>\u0415\u0441\u043b\u0438 \u0443 \u0432\u0430\u0441 \u0435\u0441\u0442\u044c \u0432\u043e\u043f\u0440\u043e\u0441\u044b \u0438\u043b\u0438 \u0432\u044b \u0445\u043e\u0442\u0438\u0442\u0435 \u043f\u043e\u0434\u0435\u043b\u0438\u0442\u044c\u0441\u044f \u0441\u0432\u043e\u0438\u043c \u043e\u043f\u044b\u0442\u043e\u043c \u0440\u0430\u0431\u043e\u0442\u044b \u0441 Magic Eden API, \u043f\u0438\u0448\u0438\u0442\u0435 \u0432 \u043a\u043e\u043c\u043c\u0435\u043d\u0442\u0430\u0440\u0438\u044f\u0445.<\/p>\n<\/div>\n<\/div>\n<\/div>\n<p><!----><!----><\/div>\n<p><!----><\/p>\n<div class=\"tm-article-poll-container\"><!--[--><\/p>\n<div class=\"tm-article-poll tm-article-poll_variant-bordered\">\n<div class=\"tm-notice tm-notice_positive tm-article-poll__notice\"><!----><\/p>\n<div class=\"tm-notice__inner\"><!----><\/p>\n<div class=\"tm-notice__content\" data-test-id=\"notice-content\"><!--[--><span>\u0422\u043e\u043b\u044c\u043a\u043e \u0437\u0430\u0440\u0435\u0433\u0438\u0441\u0442\u0440\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u044b\u0435 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u0438 \u043c\u043e\u0433\u0443\u0442 \u0443\u0447\u0430\u0441\u0442\u0432\u043e\u0432\u0430\u0442\u044c \u0432 \u043e\u043f\u0440\u043e\u0441\u0435. <a rel=\"nofollow\" href=\"\/kek\/v1\/auth\/habrahabr\/?back=\/ru\/articles\/913414\/&#038;hl=ru\">\u0412\u043e\u0439\u0434\u0438\u0442\u0435<\/a>, \u043f\u043e\u0436\u0430\u043b\u0443\u0439\u0441\u0442\u0430.<\/span><!--]--><\/div>\n<\/div>\n<\/div>\n<p><!--[--><\/p>\n<div class=\"tm-article-poll__header\">\u041a\u0430\u043a\u043e\u0439 \u043f\u0440\u043e\u0435\u043a\u0442 \u0432\u044b \u0431\u044b \u0445\u043e\u0442\u0435\u043b\u0438 \u0440\u0435\u0430\u043b\u0438\u0437\u043e\u0432\u0430\u0442\u044c?<\/div>\n<div class=\"tm-article-poll__answers\"><!--[--><\/p>\n<div class=\"tm-article-poll__answer\">\n<div class=\"tm-article-poll__answer-data\"><span class=\"tm-article-poll__answer-percent tm-article-poll__answer-percent_winning\">100% <\/span><span class=\"tm-article-poll__answer-label\">NFT \u0410\u0440\u0431\u0438\u0442\u0440\u0430\u0436\u043d\u044b\u0439 \u0431\u043e\u0442<\/span><span class=\"tm-article-poll__answer-votes\">2<\/span><\/div>\n<div class=\"tm-article-poll__answer-bar\">\n<div class=\"tm-article-poll__answer-progress tm-article-poll__answer-progress_winning\" style=\"width: 100%\"><\/div>\n<\/div>\n<\/div>\n<div class=\"tm-article-poll__answer\">\n<div class=\"tm-article-poll__answer-data\"><span class=\"tm-article-poll__answer-percent\">50% <\/span><span class=\"tm-article-poll__answer-label\">NFT \u0421\u043d\u0430\u0439\u043f\u0435\u0440<\/span><span class=\"tm-article-poll__answer-votes\">1<\/span><\/div>\n<div class=\"tm-article-poll__answer-bar\">\n<div class=\"tm-article-poll__answer-progress\" style=\"width: 50%\"><\/div>\n<\/div>\n<\/div>\n<div class=\"tm-article-poll__answer\">\n<div class=\"tm-article-poll__answer-data\"><span class=\"tm-article-poll__answer-percent\">0% <\/span><span class=\"tm-article-poll__answer-label\">\u0421\u0432\u043e\u0439 \u0432\u0430\u0440\u0438\u0430\u043d\u0442 \u0432 \u043a\u043e\u043c\u043c\u0435\u043d\u0442\u044b<\/span><span class=\"tm-article-poll__answer-votes\">0<\/span><\/div>\n<div class=\"tm-article-poll__answer-bar\">\n<div class=\"tm-article-poll__answer-progress\" style=\"width: 0%\"><\/div>\n<\/div>\n<\/div>\n<p><!--]--><\/div>\n<div class=\"tm-article-poll__stats\"> \u041f\u0440\u043e\u0433\u043e\u043b\u043e\u0441\u043e\u0432\u0430\u043b\u0438 2 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044f.    \u0412\u043e\u0437\u0434\u0435\u0440\u0436\u0430\u043b\u0441\u044f 1 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044c. <\/div>\n<p><!--]--><\/div>\n<p><!--]--><\/div>\n<p> \u0441\u0441\u044b\u043b\u043a\u0430 \u043d\u0430 \u043e\u0440\u0438\u0433\u0438\u043d\u0430\u043b \u0441\u0442\u0430\u0442\u044c\u0438 <a href=\"https:\/\/habr.com\/ru\/articles\/913414\/\"> https:\/\/habr.com\/ru\/articles\/913414\/<\/a><br \/><\/br><\/br><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[],"tags":[],"class_list":["post-461261","post","type-post","status-publish","format-standard","hentry"],"_links":{"self":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/461261","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=461261"}],"version-history":[{"count":0,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/461261\/revisions"}],"wp:attachment":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=461261"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=461261"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=461261"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}