aiosmsactivate.client

  1import asyncio
  2import json
  3import logging
  4import re
  5import time
  6from typing import Literal
  7
  8import aiohttp
  9
 10from .utils import is_json
 11from .exceptions import SmsActivateException
 12from .models import ActivationData, Number, SetActivationStatusResponse, Sms
 13from .types import SetActivationStatus, ActivationStatus
 14
 15__all__ = [
 16    "SmsActivate",
 17]
 18
 19
 20allowed_domains = [
 21    'https://api.sms-activate.ae/stubs/handler_api.php',
 22    'https://api.sms-activate.ru/stubs/handler_api.php',
 23    'https://api.sms-activate.io/stubs/handler_api.php',
 24    'https://api.sms-activate.page/stubs/handler_api.php',
 25]
 26
 27class SmsActivate:
 28    """
 29    RU  
 30    Спасибо за использование моей библиотеки, вы можете принять участие в развитии библиотеки  
 31      
 32    ВАЖНО
 33    библиотека полностью поддерживает все методы с оффициальной документации
 34    https://sms-activate.page/api2 на момент 08.07.2025  
 35      
 36    на git: https://github.com/AioSmsProviders/aiosmsactivate
 37    Так же можете писать в чат https://t.me/+5YQ8k6H02bkxZmRi
 38    или обратиться к главному разработчику с идеями, предложениями и багами: https://t.me/lolkof  
 39    
 40    EN  
 41    Thank you for using my library, you can participate in the development of the library.  
 42      
 43    important
 44    The library fully supports all methods from the official documentation
 45    https://sms-activate.page/api2 as of 07/08/2025  
 46      
 47    on git: https://github.com/AioSmsProviders/aiosmsactivate
 48    You can also write to the chat https://t.me/+5YQ8k6H02bkxZmRi
 49    or contact the main developer with ideas, suggestions, and bugs: https://t.me/lolkof
 50    
 51    SIMPLE USAGE
 52    ```python
 53    from aiosmsactivate import SmsActivate
 54    from aiosmsactivate.types import SetActivationStatus
 55
 56    import asyncio
 57
 58
 59    sa = SmsActivate('token')
 60
 61    async def main():
 62        balance = await sa.get_balance()
 63        print(balance) # 6.25
 64        
 65        number = await sa.purchase('ya')
 66        number.activation_id # 3807035855
 67        number.phone_number # '79238944456'
 68        number.operator # 'mtt'
 69        print(number)
 70        # activation_id=3807035855 phone_number='79238944456' activation_cost=0.2 
 71        # country_code='0' can_get_another_sms=True activation_time='2025-07-08 10:49:27' 
 72        # operator='mtt' 
 73        
 74        code = await number.wait_sms_code(timeout=300)
 75        print(code) # 1234
 76        
 77        status = await number.get_activation_status()
 78        
 79        await number.set_activation_status(SetActivationStatus.CANCEL) # Отменить номер || Cancel number
 80        await number.set_activation_status(8) # Отменить номер || Cancel number
 81        
 82    asyncio.run(main())
 83    ```
 84    """
 85
 86    def __init__(self, api_key: str, base_url: str | list = allowed_domains):
 87        """
 88        RU  
 89        api_key передавать api ключ, получить можно вот тут: https://sms-activate.page/profile
 90        В base_url можно указать список адресов, модуль будет проходиться по всем, пока не найдёт рабочий
 91        а можно указать один или вообще не указывать, если не указать будет браться из allowed_domains  
 92        
 93        EN  
 94        api_key to transfer the api key, you can get it here: https://sms-activate.page/profile
 95        You can specify a list of addresses in base_url, and the module will go through all of them until it finds a working one.
 96        or you can specify one or not at all, if not specified, it will be taken from allowed_domains.
 97        """
 98        self._api_key = api_key
 99        if isinstance(base_url, str):
100            base_url = [base_url]
101        self._base_urls = base_url
102        self._accept_url = None
103
104    async def __send_request(self, action: str, **kwargs):
105        last_exception = None
106
107        for url in self._base_urls:
108            try:
109                url = self._accept_url if self._accept_url else url
110                params = kwargs.get('params')
111                if params:
112                    kwargs.pop('params')
113                async with aiohttp.ClientSession() as session:
114                    async with session.request(
115                        'POST',
116                        url,
117                        **kwargs,
118                        params={
119                            'api_key': self._api_key,
120                            'action': action,
121                            **(params if params else {})
122                        }
123                    ) as response:
124                        response.raise_for_status()
125                        logging.debug(response.real_url)
126                        return await response.text()
127            except Exception as e:
128                last_exception = e
129                continue
130            self._accept_url = url
131            break
132
133        raise last_exception
134
135    async def get_balance(self, cashback: bool = False) -> float:
136        pattern = re.compile(r'ACCESS_BALANCE:(\d+\.\d{2})')
137        response = await self.__send_request('getBalance' if not cashback else 'getBalanceAndCashBack')
138        match = pattern.match(response)
139        if not match:
140            raise SmsActivateException('Invalid response sequence')
141
142        return float(match.group(1))
143    async def get_balance_and_cashback(self):
144        return await self.get_balance(cashback=True)
145
146    async def get_available_countries(self, service: str, freePrice: bool | str) -> dict[str, ...]:
147        response = await self.__send_request('getTopCountriesByService', params={
148            'service': service,
149            'freePrice': str(freePrice).lower()
150        })
151        
152        if not is_json(response):
153            return response
154        
155        return json.loads(response)
156    
157    async def get_count_numbers(self, country: str, operator: str) -> dict[str, ...]:
158        response = await self.__send_request('getNumbersStatus', params={
159            'country': country,
160            'operator': operator
161        })
162        
163        if not is_json(response):
164            return response
165        
166        return json.loads(response)
167    
168    async def get_operators(self, country: str = None) -> dict[str, ...]:
169        params = {}
170        if country is not None:
171            params["country"] = country
172        response = await self.__send_request('getOperators', params=params)
173        
174        if not is_json(response):
175            return response
176        
177        return json.loads(response)
178    
179    async def get_active_activations(self) -> dict[str, ...]:
180        response = await self.__send_request('getActiveActivations')
181        
182        if not is_json(response):
183            return response
184        
185        return json.loads(response)
186
187    async def get_activation_status_v1(self, id: str) -> tuple[ActivationStatus, str | None]:
188        response = await self.__send_request('getStatus', params={
189            'id': id
190        })
191
192        data = response.split(':')
193
194        match data[0]:
195            case 'STATUS_WAIT_CODE':
196                return ActivationStatus.WAIT, None
197            case 'STATUS_WAIT_RETRY':
198                return ActivationStatus.RETRY, data[1]
199            case 'STATUS_WAIT_RESEND':
200                return ActivationStatus.RESEND, None
201            case 'STATUS_CANCEL':
202                return ActivationStatus.CANCEL, None
203            case 'STATUS_OK':
204                return ActivationStatus.OK, data[1]
205            case _:
206                raise SmsActivateException('Invalid response sequence')
207    
208    async def get_activation_status(self, activation_id: str | int | Number) -> ActivationData | str:
209        if isinstance(activation_id, Number):
210            activation_id = activation_id.activation_id
211        response = await self.__send_request('getStatusV2', params={
212            'id': activation_id
213        })
214
215        if not is_json(response):
216            return response
217        
218        return ActivationData(**json.loads(response))
219    
220    async def wait_sms_code(self, activation_id: str | int | Number, timeout: int = 60*5, per_attempt: int = 5) -> Sms | str | int | None:
221        """
222        Ожидание смс кода
223        Wait sms code
224
225        Аргументы:
226            activation_id: activation_id номера или целый объект номера
227            timeout: максимальное время ожидание смс в секундах, по умолчанию 5 минут 
228            per_attempt: время между попыткой получить смс, по умолчанию 5 секунд
229            
230        Args:
231            activation_id: activation_id of number or Number object
232            timeout: maximum time to wait sms code 
233            per_attempt: time per attempt
234            
235        Returns: Sms
236        """
237        activation_id = activation_id.activation_id if isinstance(activation_id, Number) else activation_id
238        if not self._api_key:
239            raise ValueError('API key is required for this method')
240
241        try:
242            await self.set_activation_status(activation_id=activation_id, status=SetActivationStatus.READY)
243        except:
244            pass
245
246        start_time = time.time()
247        
248        while time.time() - start_time < timeout:
249            await asyncio.sleep(per_attempt)
250            status, code = await self.get_activation_status_v1(activation_id)
251            if status == ActivationStatus.OK:
252                try:
253                    await self.set_activation_status(activation_id, SetActivationStatus.AGAIN)
254                except:
255                    pass
256                return code
257        
258        return None
259
260    async def purchase(self, service: str, forward: bool | None = None, maxPrice: float | None = None,
261                       phoneException: str | None = None, operator: str | None = None,
262                       activationType: int | str | None = None, language: str | None = None,
263                       userId: str | int | None = None,
264                       ref: str | None = None, country: str | None = None,
265                       useCashBack: bool | None = None,
266                       orderId: str | int | None = None,
267                       _is_v2: bool = True
268                       ) -> Number | str:
269        response = await self.__send_request('getNumber' if not _is_v2 else 'getNumberV2', params={
270            'service': service,
271            **({'forward': 1 if forward else 0} if forward is not None else {}),
272            **({'maxPrice': str(maxPrice)} if maxPrice is not None else {}),
273            **({'phoneException': phoneException} if phoneException is not None else {}),
274            **({'operator': operator} if operator is not None else {}),
275            **({'activationType': str(activationType)} if activationType is not None else {}),
276            **({'language': str(language)} if language is not None else {}),
277            **({'userId': str(userId)} if userId is not None else {}),
278            **({'orderId': str(orderId)} if orderId is not None and _is_v2 else {}),
279            **({'ref': ref} if ref is not None else {}),
280            **({'country ': country} if country is not None else {}),
281            **({'useCashBack': str(useCashBack).lower()} if useCashBack is not None else {}),
282        })
283
284        if not is_json(response):
285            return response
286        
287        return Number.from_response(self, json.loads(response))
288    
289    async def get_number(self, *args, **kwargs):
290        kwargs["_is_v2"] = False
291        return await self.purchase(*args, **kwargs)
292    
293    async def get_multi_service_number(self, 
294                        multiService: str, multiForward: str | None = None,
295                        operator: str | None = None,
296                        ref: str | None = None, country: str | None = None,
297                       ) -> dict:
298        """
299        Get multiservice number.
300
301        :param multiService: service1,service2,service3 (Services separated by commas)
302        :param multiForward: 1,0,1 (forwards separated by commas, forwards count equal services count)
303        :return: dict object of response
304        """
305        response = await self.__send_request('getMultiServiceNumber', params={
306            'multiService': multiService,
307            **({'multiForward': multiForward} if multiForward is not None else {}),
308            **({'operator': operator} if operator is not None else {}),
309            **({'ref': ref} if ref is not None else {}),
310            **({'country ': country} if country is not None else {}),
311        })
312
313        if not is_json(response):
314            return response
315        
316        return json.loads(response)
317    
318
319    async def set_activation_status(self, activation_id: str | int, status: SetActivationStatus | int,
320                                    forward: str | None = None) -> SetActivationStatusResponse:
321        members = {member.value: member for member in SetActivationStatusResponse}
322        response = await self.__send_request('setStatus', params={
323            'id': activation_id,
324            'status': status.value if isinstance(status, SetActivationStatus) else status,
325            **({'forward': forward} if forward is not None else {})
326        })
327
328        return members[response]
329
330    async def get_history(self, 
331                          start: str | int = None,
332                          end: str | int = None,
333                          offset: str | int = None,
334                          limit: str | int = None,
335                       ) -> dict | list:
336        response = await self.__send_request('getHistory', params={
337            **({'start': str(start)} if start is not None else {}),
338            **({'end': str(end)} if end is not None else {}),
339            **({'offset': str(offset)} if offset is not None else {}),
340            **({'limit': str(limit)} if limit is not None else {}),
341        })
342
343        if not is_json(response):
344            return response
345        
346        return json.loads(response)
347    
348    async def get_list_top_countries(self, 
349                          service: str,
350                       ) -> dict | list:
351        response = await self.__send_request('getListOfTopCountriesByService', params={
352            'service': service
353        })
354
355        if not is_json(response):
356            return response
357        
358        return json.loads(response)
359    
360    async def get_incoming_call_status(self, 
361                          id: str | int = None,
362                       ) -> dict | list:
363        response = await self.__send_request('getIncomingCallStatus', params={
364            'activationId': id
365        })
366
367        if not is_json(response):
368            return response
369        
370        return json.loads(response)
371    
372    async def get_prices(self, 
373                          service: str = None,
374                          country: str = None,
375                       ) -> dict | list:
376        response = await self.__send_request('getPrices', params={
377            **({'service': str(service)} if service is not None else {}),
378            **({'country': str(country)} if country is not None else {}),
379        })
380
381        if not is_json(response):
382            return response
383        
384        return json.loads(response)
385    
386    async def get_prices_verification(self, 
387                          service: str = None,
388                       ) -> dict | list:
389        response = await self.__send_request('getPricesVerification', params={
390            **({'service': str(service)} if service is not None else {}),
391        })
392
393        if not is_json(response):
394            return response
395        
396        return json.loads(response)
397    
398    async def get_countries(self,
399                       ) -> dict | list:
400        response = await self.__send_request('getCountries', params={
401        })
402
403        if not is_json(response):
404            return response
405        
406        return json.loads(response)
407    
408    async def get_service_list(self, 
409                          country: str = None,
410                          lang: Literal['ru', 'en', 'es', 'cn'] = None,
411                       ) -> dict | list:
412        response = await self.__send_request('getServicesList', params={
413            **({'country': str(country)} if country is not None else {}),
414            **({'lang': str(lang)} if lang is not None else {}),
415        })
416
417        if not is_json(response):
418            return response
419        
420        return json.loads(response)
421    
422    async def get_additional_service(self, 
423                          service: str = None,
424                          id: str = None,
425                       ):
426        """
427        Get additional service to activation its cost 5rub
428        return 2 values: addition activation id and phone number
429        
430        use like this: 
431        activation_id, phone_number = await getAdditionalService(service, activation id)
432        """
433        response = await self.__send_request('getAdditionalService', params={
434            'service': service,
435            'id':id
436        })
437
438        data = response.split(':')
439        if len(data) > 2:
440            return data[1], data[2]
441        
442        return data
443    
444    async def get_extra_activation(self, 
445                          id: str = None,
446                       ):
447        """
448        return 2 values: addition activation id and phone number
449        
450        use like this: 
451        activation_id, phone_number = await getExtraActivation(activation id)
452        """
453        response = await self.__send_request('getExtraActivation', params={
454            'id':id
455        })
456
457        data = response.split(':')
458        if len(data) > 2:
459            return data[1], data[2]
460        
461        return data
462    
463    async def check_extra_activation(self, 
464                          activationId: str | int
465                       ) -> dict | list:
466        response = await self.__send_request('checkExtraActivation', params={
467            'activationId': str(activationId)
468        })
469
470        if not is_json(response):
471            return response
472        
473        return json.loads(response)
474    
475    async def parse_call(self, 
476                          id: str | int,
477                          newLang: str,
478                       ) -> dict | list:
479        response = await self.__send_request('parseCall', params={
480            "id": id,
481            "newLang": newLang,
482        })
483
484        if not is_json(response):
485            return response
486        
487        return json.loads(response)
488    
489    # !!! BOTTOM IT IS RENT API
490    async def get_rent_services_and_countries(self,
491                       time: int | str | None = None,
492                       operator: str | None = None,
493                       country: str | None = None,
494                       currency: str | None = None,
495                       incomingCall: bool | None = None,
496                       ) -> dict | str:
497        response = await self.__send_request('getRentServicesAndCountries', params={
498            **({'time ': str(time )} if time is not None else {}),
499            **({'operator ': str(operator )} if operator is not None else {}),
500            **({'country ': str(country )} if country is not None else {}),
501            **({'currency ': str(currency )} if currency is not None else {}),
502            **({'incomingCall': str(incomingCall).lower()} if incomingCall is not None else {}),
503        })
504
505        if not is_json(response):
506            return response
507        
508        return json.loads(response)
509    
510    async def get_rent_number(self,
511                        service: str,
512                        time: int | str | None = None,
513                        operator: str | None = None,
514                        country: str | None = None,
515                        url: str | None = None,
516                        incomingCall: bool | None = None,
517                       ) -> dict | str:
518        response = await self.__send_request('getRentNumber', params={
519            'service': service,
520            **({'time ': str(time )} if time is not None else {}),
521            **({'operator ': str(operator )} if operator is not None else {}),
522            **({'country ': str(country )} if country is not None else {}),
523            **({'url ': str(url )} if url is not None else {}),
524            **({'incomingCall': str(incomingCall).lower()} if incomingCall is not None else {}),
525        })
526
527        if not is_json(response):
528            return response
529        
530        return json.loads(response)
531    
532    async def get_rent_status(self,
533                        id: str,
534                        page: int | str | None = None,
535                        size: int | str | None = None,
536                       ) -> dict | str:
537        response = await self.__send_request('getRentStatus', params={
538            'id': id,
539            **({'page ': str(page)} if page is not None else {}),
540            **({'size ': str(size )} if size is not None else {}),
541        })
542
543        if not is_json(response):
544            return response
545        
546        return json.loads(response)
547    
548    async def set_rent_status(self,
549                        id: str,
550                        status: Literal[1, 2, '1', '2'],
551                       ) -> dict | str:
552        response = await self.__send_request('getRentStatus', params={
553            'id': str(id),
554            'status': str(status),
555        })
556
557        if not is_json(response):
558            return response
559        
560        return json.loads(response)
561    
562    async def get_rent_list(self,
563                       ) -> dict | str:
564        response = await self.__send_request('getRentList', params={
565        })
566
567        if not is_json(response):
568            return response
569        
570        return json.loads(response)
571    
572    async def continue_rent_number(self,
573                        id: str,
574                        rent_time: int | str | None = 4,
575                       ) -> dict | str:
576        response = await self.__send_request('continueRentNumber', params={
577            'id': id,
578            'rent_time': str(rent_time)
579        })
580
581        if not is_json(response):
582            return response
583        
584        return json.loads(response)
585    
586    async def get_continue_rent_price_number(self,
587                        id: str,
588                        rent_time: int | str | None = 4,
589                        currency: str | None = None
590                       ) -> dict | str:
591        response = await self.__send_request('getContinueRentPriceNumber', params={
592            'id': id,
593            'rent_time': str(rent_time),
594            **({'currency ': str(currency )} if currency is not None else {}),
595        })
596
597        if not is_json(response):
598            return response
599        
600        return json.loads(response)
601    
602    # !!! BOTTOM IS IT PARTNER SOFT API
603    async def buy_partner_product(self,
604                        id: str,
605                       ) -> dict | str:
606        response = await self.__send_request('buyPartnerProduct', params={
607            'id': id,
608        })
609
610        if not is_json(response):
611            return response
612        
613        return json.loads(response)
614    
615
616# === Method Aliases (outside class for pdoc) ===
617SmsActivate.getBalance = SmsActivate.get_balance
618SmsActivate.getBalanceAndCashBack = SmsActivate.get_balance_and_cashback
619SmsActivate.getTopCountriesByService = SmsActivate.get_available_countries
620SmsActivate.getNumbersStatus = SmsActivate.get_count_numbers
621SmsActivate.getOperators = SmsActivate.get_operators
622SmsActivate.getActiveActivations = SmsActivate.get_active_activations
623SmsActivate.getStatus = SmsActivate.get_activation_status_v1
624SmsActivate.getStatusV2 = SmsActivate.get_activation_status
625SmsActivate.getNumberV2 = SmsActivate.purchase
626SmsActivate.purchase_v1 = SmsActivate.get_number
627SmsActivate.getNumber = SmsActivate.get_number
628SmsActivate.getMultiServiceNumber = SmsActivate.get_multi_service_number
629SmsActivate.setStatus = SmsActivate.set_activation_status
630SmsActivate.getHistory = SmsActivate.get_history
631SmsActivate.getListOfTopCountriesByService = SmsActivate.get_list_top_countries
632SmsActivate.getIncomingCallStatus = SmsActivate.get_incoming_call_status
633SmsActivate.getPrices = SmsActivate.get_prices
634SmsActivate.getPricesVerification = SmsActivate.get_prices_verification
635SmsActivate.getCountries = SmsActivate.get_countries
636SmsActivate.getServicesList = SmsActivate.get_service_list
637SmsActivate.getAdditionalService = SmsActivate.get_additional_service
638SmsActivate.getExtraActivation = SmsActivate.get_extra_activation
639SmsActivate.checkExtraActivation = SmsActivate.check_extra_activation
640SmsActivate.parseCall = SmsActivate.parse_call
641SmsActivate.getRentServicesAndCountries = SmsActivate.get_rent_services_and_countries
642SmsActivate.getRentNumber = SmsActivate.get_rent_number
643SmsActivate.getRentStatus = SmsActivate.get_rent_status
644SmsActivate.getRentStatus = SmsActivate.get_rent_status
645SmsActivate.getRentList = SmsActivate.get_rent_list
646SmsActivate.continueRentNumber = SmsActivate.continue_rent_number
647SmsActivate.getContinueRentPriceNumber = SmsActivate.get_continue_rent_price_number
648SmsActivate.buyPartnerProduct = SmsActivate.buy_partner_product
class SmsActivate:
 28class SmsActivate:
 29    """
 30    RU  
 31    Спасибо за использование моей библиотеки, вы можете принять участие в развитии библиотеки  
 32      
 33    ВАЖНО
 34    библиотека полностью поддерживает все методы с оффициальной документации
 35    https://sms-activate.page/api2 на момент 08.07.2025  
 36      
 37    на git: https://github.com/AioSmsProviders/aiosmsactivate
 38    Так же можете писать в чат https://t.me/+5YQ8k6H02bkxZmRi
 39    или обратиться к главному разработчику с идеями, предложениями и багами: https://t.me/lolkof  
 40    
 41    EN  
 42    Thank you for using my library, you can participate in the development of the library.  
 43      
 44    important
 45    The library fully supports all methods from the official documentation
 46    https://sms-activate.page/api2 as of 07/08/2025  
 47      
 48    on git: https://github.com/AioSmsProviders/aiosmsactivate
 49    You can also write to the chat https://t.me/+5YQ8k6H02bkxZmRi
 50    or contact the main developer with ideas, suggestions, and bugs: https://t.me/lolkof
 51    
 52    SIMPLE USAGE
 53    ```python
 54    from aiosmsactivate import SmsActivate
 55    from aiosmsactivate.types import SetActivationStatus
 56
 57    import asyncio
 58
 59
 60    sa = SmsActivate('token')
 61
 62    async def main():
 63        balance = await sa.get_balance()
 64        print(balance) # 6.25
 65        
 66        number = await sa.purchase('ya')
 67        number.activation_id # 3807035855
 68        number.phone_number # '79238944456'
 69        number.operator # 'mtt'
 70        print(number)
 71        # activation_id=3807035855 phone_number='79238944456' activation_cost=0.2 
 72        # country_code='0' can_get_another_sms=True activation_time='2025-07-08 10:49:27' 
 73        # operator='mtt' 
 74        
 75        code = await number.wait_sms_code(timeout=300)
 76        print(code) # 1234
 77        
 78        status = await number.get_activation_status()
 79        
 80        await number.set_activation_status(SetActivationStatus.CANCEL) # Отменить номер || Cancel number
 81        await number.set_activation_status(8) # Отменить номер || Cancel number
 82        
 83    asyncio.run(main())
 84    ```
 85    """
 86
 87    def __init__(self, api_key: str, base_url: str | list = allowed_domains):
 88        """
 89        RU  
 90        api_key передавать api ключ, получить можно вот тут: https://sms-activate.page/profile
 91        В base_url можно указать список адресов, модуль будет проходиться по всем, пока не найдёт рабочий
 92        а можно указать один или вообще не указывать, если не указать будет браться из allowed_domains  
 93        
 94        EN  
 95        api_key to transfer the api key, you can get it here: https://sms-activate.page/profile
 96        You can specify a list of addresses in base_url, and the module will go through all of them until it finds a working one.
 97        or you can specify one or not at all, if not specified, it will be taken from allowed_domains.
 98        """
 99        self._api_key = api_key
100        if isinstance(base_url, str):
101            base_url = [base_url]
102        self._base_urls = base_url
103        self._accept_url = None
104
105    async def __send_request(self, action: str, **kwargs):
106        last_exception = None
107
108        for url in self._base_urls:
109            try:
110                url = self._accept_url if self._accept_url else url
111                params = kwargs.get('params')
112                if params:
113                    kwargs.pop('params')
114                async with aiohttp.ClientSession() as session:
115                    async with session.request(
116                        'POST',
117                        url,
118                        **kwargs,
119                        params={
120                            'api_key': self._api_key,
121                            'action': action,
122                            **(params if params else {})
123                        }
124                    ) as response:
125                        response.raise_for_status()
126                        logging.debug(response.real_url)
127                        return await response.text()
128            except Exception as e:
129                last_exception = e
130                continue
131            self._accept_url = url
132            break
133
134        raise last_exception
135
136    async def get_balance(self, cashback: bool = False) -> float:
137        pattern = re.compile(r'ACCESS_BALANCE:(\d+\.\d{2})')
138        response = await self.__send_request('getBalance' if not cashback else 'getBalanceAndCashBack')
139        match = pattern.match(response)
140        if not match:
141            raise SmsActivateException('Invalid response sequence')
142
143        return float(match.group(1))
144    async def get_balance_and_cashback(self):
145        return await self.get_balance(cashback=True)
146
147    async def get_available_countries(self, service: str, freePrice: bool | str) -> dict[str, ...]:
148        response = await self.__send_request('getTopCountriesByService', params={
149            'service': service,
150            'freePrice': str(freePrice).lower()
151        })
152        
153        if not is_json(response):
154            return response
155        
156        return json.loads(response)
157    
158    async def get_count_numbers(self, country: str, operator: str) -> dict[str, ...]:
159        response = await self.__send_request('getNumbersStatus', params={
160            'country': country,
161            'operator': operator
162        })
163        
164        if not is_json(response):
165            return response
166        
167        return json.loads(response)
168    
169    async def get_operators(self, country: str = None) -> dict[str, ...]:
170        params = {}
171        if country is not None:
172            params["country"] = country
173        response = await self.__send_request('getOperators', params=params)
174        
175        if not is_json(response):
176            return response
177        
178        return json.loads(response)
179    
180    async def get_active_activations(self) -> dict[str, ...]:
181        response = await self.__send_request('getActiveActivations')
182        
183        if not is_json(response):
184            return response
185        
186        return json.loads(response)
187
188    async def get_activation_status_v1(self, id: str) -> tuple[ActivationStatus, str | None]:
189        response = await self.__send_request('getStatus', params={
190            'id': id
191        })
192
193        data = response.split(':')
194
195        match data[0]:
196            case 'STATUS_WAIT_CODE':
197                return ActivationStatus.WAIT, None
198            case 'STATUS_WAIT_RETRY':
199                return ActivationStatus.RETRY, data[1]
200            case 'STATUS_WAIT_RESEND':
201                return ActivationStatus.RESEND, None
202            case 'STATUS_CANCEL':
203                return ActivationStatus.CANCEL, None
204            case 'STATUS_OK':
205                return ActivationStatus.OK, data[1]
206            case _:
207                raise SmsActivateException('Invalid response sequence')
208    
209    async def get_activation_status(self, activation_id: str | int | Number) -> ActivationData | str:
210        if isinstance(activation_id, Number):
211            activation_id = activation_id.activation_id
212        response = await self.__send_request('getStatusV2', params={
213            'id': activation_id
214        })
215
216        if not is_json(response):
217            return response
218        
219        return ActivationData(**json.loads(response))
220    
221    async def wait_sms_code(self, activation_id: str | int | Number, timeout: int = 60*5, per_attempt: int = 5) -> Sms | str | int | None:
222        """
223        Ожидание смс кода
224        Wait sms code
225
226        Аргументы:
227            activation_id: activation_id номера или целый объект номера
228            timeout: максимальное время ожидание смс в секундах, по умолчанию 5 минут 
229            per_attempt: время между попыткой получить смс, по умолчанию 5 секунд
230            
231        Args:
232            activation_id: activation_id of number or Number object
233            timeout: maximum time to wait sms code 
234            per_attempt: time per attempt
235            
236        Returns: Sms
237        """
238        activation_id = activation_id.activation_id if isinstance(activation_id, Number) else activation_id
239        if not self._api_key:
240            raise ValueError('API key is required for this method')
241
242        try:
243            await self.set_activation_status(activation_id=activation_id, status=SetActivationStatus.READY)
244        except:
245            pass
246
247        start_time = time.time()
248        
249        while time.time() - start_time < timeout:
250            await asyncio.sleep(per_attempt)
251            status, code = await self.get_activation_status_v1(activation_id)
252            if status == ActivationStatus.OK:
253                try:
254                    await self.set_activation_status(activation_id, SetActivationStatus.AGAIN)
255                except:
256                    pass
257                return code
258        
259        return None
260
261    async def purchase(self, service: str, forward: bool | None = None, maxPrice: float | None = None,
262                       phoneException: str | None = None, operator: str | None = None,
263                       activationType: int | str | None = None, language: str | None = None,
264                       userId: str | int | None = None,
265                       ref: str | None = None, country: str | None = None,
266                       useCashBack: bool | None = None,
267                       orderId: str | int | None = None,
268                       _is_v2: bool = True
269                       ) -> Number | str:
270        response = await self.__send_request('getNumber' if not _is_v2 else 'getNumberV2', params={
271            'service': service,
272            **({'forward': 1 if forward else 0} if forward is not None else {}),
273            **({'maxPrice': str(maxPrice)} if maxPrice is not None else {}),
274            **({'phoneException': phoneException} if phoneException is not None else {}),
275            **({'operator': operator} if operator is not None else {}),
276            **({'activationType': str(activationType)} if activationType is not None else {}),
277            **({'language': str(language)} if language is not None else {}),
278            **({'userId': str(userId)} if userId is not None else {}),
279            **({'orderId': str(orderId)} if orderId is not None and _is_v2 else {}),
280            **({'ref': ref} if ref is not None else {}),
281            **({'country ': country} if country is not None else {}),
282            **({'useCashBack': str(useCashBack).lower()} if useCashBack is not None else {}),
283        })
284
285        if not is_json(response):
286            return response
287        
288        return Number.from_response(self, json.loads(response))
289    
290    async def get_number(self, *args, **kwargs):
291        kwargs["_is_v2"] = False
292        return await self.purchase(*args, **kwargs)
293    
294    async def get_multi_service_number(self, 
295                        multiService: str, multiForward: str | None = None,
296                        operator: str | None = None,
297                        ref: str | None = None, country: str | None = None,
298                       ) -> dict:
299        """
300        Get multiservice number.
301
302        :param multiService: service1,service2,service3 (Services separated by commas)
303        :param multiForward: 1,0,1 (forwards separated by commas, forwards count equal services count)
304        :return: dict object of response
305        """
306        response = await self.__send_request('getMultiServiceNumber', params={
307            'multiService': multiService,
308            **({'multiForward': multiForward} if multiForward is not None else {}),
309            **({'operator': operator} if operator is not None else {}),
310            **({'ref': ref} if ref is not None else {}),
311            **({'country ': country} if country is not None else {}),
312        })
313
314        if not is_json(response):
315            return response
316        
317        return json.loads(response)
318    
319
320    async def set_activation_status(self, activation_id: str | int, status: SetActivationStatus | int,
321                                    forward: str | None = None) -> SetActivationStatusResponse:
322        members = {member.value: member for member in SetActivationStatusResponse}
323        response = await self.__send_request('setStatus', params={
324            'id': activation_id,
325            'status': status.value if isinstance(status, SetActivationStatus) else status,
326            **({'forward': forward} if forward is not None else {})
327        })
328
329        return members[response]
330
331    async def get_history(self, 
332                          start: str | int = None,
333                          end: str | int = None,
334                          offset: str | int = None,
335                          limit: str | int = None,
336                       ) -> dict | list:
337        response = await self.__send_request('getHistory', params={
338            **({'start': str(start)} if start is not None else {}),
339            **({'end': str(end)} if end is not None else {}),
340            **({'offset': str(offset)} if offset is not None else {}),
341            **({'limit': str(limit)} if limit is not None else {}),
342        })
343
344        if not is_json(response):
345            return response
346        
347        return json.loads(response)
348    
349    async def get_list_top_countries(self, 
350                          service: str,
351                       ) -> dict | list:
352        response = await self.__send_request('getListOfTopCountriesByService', params={
353            'service': service
354        })
355
356        if not is_json(response):
357            return response
358        
359        return json.loads(response)
360    
361    async def get_incoming_call_status(self, 
362                          id: str | int = None,
363                       ) -> dict | list:
364        response = await self.__send_request('getIncomingCallStatus', params={
365            'activationId': id
366        })
367
368        if not is_json(response):
369            return response
370        
371        return json.loads(response)
372    
373    async def get_prices(self, 
374                          service: str = None,
375                          country: str = None,
376                       ) -> dict | list:
377        response = await self.__send_request('getPrices', params={
378            **({'service': str(service)} if service is not None else {}),
379            **({'country': str(country)} if country is not None else {}),
380        })
381
382        if not is_json(response):
383            return response
384        
385        return json.loads(response)
386    
387    async def get_prices_verification(self, 
388                          service: str = None,
389                       ) -> dict | list:
390        response = await self.__send_request('getPricesVerification', params={
391            **({'service': str(service)} if service is not None else {}),
392        })
393
394        if not is_json(response):
395            return response
396        
397        return json.loads(response)
398    
399    async def get_countries(self,
400                       ) -> dict | list:
401        response = await self.__send_request('getCountries', params={
402        })
403
404        if not is_json(response):
405            return response
406        
407        return json.loads(response)
408    
409    async def get_service_list(self, 
410                          country: str = None,
411                          lang: Literal['ru', 'en', 'es', 'cn'] = None,
412                       ) -> dict | list:
413        response = await self.__send_request('getServicesList', params={
414            **({'country': str(country)} if country is not None else {}),
415            **({'lang': str(lang)} if lang is not None else {}),
416        })
417
418        if not is_json(response):
419            return response
420        
421        return json.loads(response)
422    
423    async def get_additional_service(self, 
424                          service: str = None,
425                          id: str = None,
426                       ):
427        """
428        Get additional service to activation its cost 5rub
429        return 2 values: addition activation id and phone number
430        
431        use like this: 
432        activation_id, phone_number = await getAdditionalService(service, activation id)
433        """
434        response = await self.__send_request('getAdditionalService', params={
435            'service': service,
436            'id':id
437        })
438
439        data = response.split(':')
440        if len(data) > 2:
441            return data[1], data[2]
442        
443        return data
444    
445    async def get_extra_activation(self, 
446                          id: str = None,
447                       ):
448        """
449        return 2 values: addition activation id and phone number
450        
451        use like this: 
452        activation_id, phone_number = await getExtraActivation(activation id)
453        """
454        response = await self.__send_request('getExtraActivation', params={
455            'id':id
456        })
457
458        data = response.split(':')
459        if len(data) > 2:
460            return data[1], data[2]
461        
462        return data
463    
464    async def check_extra_activation(self, 
465                          activationId: str | int
466                       ) -> dict | list:
467        response = await self.__send_request('checkExtraActivation', params={
468            'activationId': str(activationId)
469        })
470
471        if not is_json(response):
472            return response
473        
474        return json.loads(response)
475    
476    async def parse_call(self, 
477                          id: str | int,
478                          newLang: str,
479                       ) -> dict | list:
480        response = await self.__send_request('parseCall', params={
481            "id": id,
482            "newLang": newLang,
483        })
484
485        if not is_json(response):
486            return response
487        
488        return json.loads(response)
489    
490    # !!! BOTTOM IT IS RENT API
491    async def get_rent_services_and_countries(self,
492                       time: int | str | None = None,
493                       operator: str | None = None,
494                       country: str | None = None,
495                       currency: str | None = None,
496                       incomingCall: bool | None = None,
497                       ) -> dict | str:
498        response = await self.__send_request('getRentServicesAndCountries', params={
499            **({'time ': str(time )} if time is not None else {}),
500            **({'operator ': str(operator )} if operator is not None else {}),
501            **({'country ': str(country )} if country is not None else {}),
502            **({'currency ': str(currency )} if currency is not None else {}),
503            **({'incomingCall': str(incomingCall).lower()} if incomingCall is not None else {}),
504        })
505
506        if not is_json(response):
507            return response
508        
509        return json.loads(response)
510    
511    async def get_rent_number(self,
512                        service: str,
513                        time: int | str | None = None,
514                        operator: str | None = None,
515                        country: str | None = None,
516                        url: str | None = None,
517                        incomingCall: bool | None = None,
518                       ) -> dict | str:
519        response = await self.__send_request('getRentNumber', params={
520            'service': service,
521            **({'time ': str(time )} if time is not None else {}),
522            **({'operator ': str(operator )} if operator is not None else {}),
523            **({'country ': str(country )} if country is not None else {}),
524            **({'url ': str(url )} if url is not None else {}),
525            **({'incomingCall': str(incomingCall).lower()} if incomingCall is not None else {}),
526        })
527
528        if not is_json(response):
529            return response
530        
531        return json.loads(response)
532    
533    async def get_rent_status(self,
534                        id: str,
535                        page: int | str | None = None,
536                        size: int | str | None = None,
537                       ) -> dict | str:
538        response = await self.__send_request('getRentStatus', params={
539            'id': id,
540            **({'page ': str(page)} if page is not None else {}),
541            **({'size ': str(size )} if size is not None else {}),
542        })
543
544        if not is_json(response):
545            return response
546        
547        return json.loads(response)
548    
549    async def set_rent_status(self,
550                        id: str,
551                        status: Literal[1, 2, '1', '2'],
552                       ) -> dict | str:
553        response = await self.__send_request('getRentStatus', params={
554            'id': str(id),
555            'status': str(status),
556        })
557
558        if not is_json(response):
559            return response
560        
561        return json.loads(response)
562    
563    async def get_rent_list(self,
564                       ) -> dict | str:
565        response = await self.__send_request('getRentList', params={
566        })
567
568        if not is_json(response):
569            return response
570        
571        return json.loads(response)
572    
573    async def continue_rent_number(self,
574                        id: str,
575                        rent_time: int | str | None = 4,
576                       ) -> dict | str:
577        response = await self.__send_request('continueRentNumber', params={
578            'id': id,
579            'rent_time': str(rent_time)
580        })
581
582        if not is_json(response):
583            return response
584        
585        return json.loads(response)
586    
587    async def get_continue_rent_price_number(self,
588                        id: str,
589                        rent_time: int | str | None = 4,
590                        currency: str | None = None
591                       ) -> dict | str:
592        response = await self.__send_request('getContinueRentPriceNumber', params={
593            'id': id,
594            'rent_time': str(rent_time),
595            **({'currency ': str(currency )} if currency is not None else {}),
596        })
597
598        if not is_json(response):
599            return response
600        
601        return json.loads(response)
602    
603    # !!! BOTTOM IS IT PARTNER SOFT API
604    async def buy_partner_product(self,
605                        id: str,
606                       ) -> dict | str:
607        response = await self.__send_request('buyPartnerProduct', params={
608            'id': id,
609        })
610
611        if not is_json(response):
612            return response
613        
614        return json.loads(response)

RU
Спасибо за использование моей библиотеки, вы можете принять участие в развитии библиотеки

ВАЖНО библиотека полностью поддерживает все методы с оффициальной документации https://sms-activate.page/api2 на момент 08.07.2025

на git: https://github.com/AioSmsProviders/aiosmsactivate Так же можете писать в чат https://t.me/+5YQ8k6H02bkxZmRi или обратиться к главному разработчику с идеями, предложениями и багами: https://t.me/lolkof

EN
Thank you for using my library, you can participate in the development of the library.

important The library fully supports all methods from the official documentation https://sms-activate.page/api2 as of 07/08/2025

on git: https://github.com/AioSmsProviders/aiosmsactivate You can also write to the chat https://t.me/+5YQ8k6H02bkxZmRi or contact the main developer with ideas, suggestions, and bugs: https://t.me/lolkof

SIMPLE USAGE

from aiosmsactivate import SmsActivate
from aiosmsactivate.types import SetActivationStatus

import asyncio


sa = SmsActivate('token')

async def main():
    balance = await sa.get_balance()
    print(balance) # 6.25

    number = await sa.purchase('ya')
    number.activation_id # 3807035855
    number.phone_number # '79238944456'
    number.operator # 'mtt'
    print(number)
    # activation_id=3807035855 phone_number='79238944456' activation_cost=0.2 
    # country_code='0' can_get_another_sms=True activation_time='2025-07-08 10:49:27' 
    # operator='mtt' 

    code = await number.wait_sms_code(timeout=300)
    print(code) # 1234

    status = await number.get_activation_status()

    await number.set_activation_status(SetActivationStatus.CANCEL) # Отменить номер || Cancel number
    await number.set_activation_status(8) # Отменить номер || Cancel number

asyncio.run(main())
SmsActivate( api_key: str, base_url: str | list = ['https://api.sms-activate.ae/stubs/handler_api.php', 'https://api.sms-activate.ru/stubs/handler_api.php', 'https://api.sms-activate.io/stubs/handler_api.php', 'https://api.sms-activate.page/stubs/handler_api.php'])
 87    def __init__(self, api_key: str, base_url: str | list = allowed_domains):
 88        """
 89        RU  
 90        api_key передавать api ключ, получить можно вот тут: https://sms-activate.page/profile
 91        В base_url можно указать список адресов, модуль будет проходиться по всем, пока не найдёт рабочий
 92        а можно указать один или вообще не указывать, если не указать будет браться из allowed_domains  
 93        
 94        EN  
 95        api_key to transfer the api key, you can get it here: https://sms-activate.page/profile
 96        You can specify a list of addresses in base_url, and the module will go through all of them until it finds a working one.
 97        or you can specify one or not at all, if not specified, it will be taken from allowed_domains.
 98        """
 99        self._api_key = api_key
100        if isinstance(base_url, str):
101            base_url = [base_url]
102        self._base_urls = base_url
103        self._accept_url = None

RU
api_key передавать api ключ, получить можно вот тут: https://sms-activate.page/profile В base_url можно указать список адресов, модуль будет проходиться по всем, пока не найдёт рабочий а можно указать один или вообще не указывать, если не указать будет браться из allowed_domains

EN
api_key to transfer the api key, you can get it here: https://sms-activate.page/profile You can specify a list of addresses in base_url, and the module will go through all of them until it finds a working one. or you can specify one or not at all, if not specified, it will be taken from allowed_domains.

async def get_balance(self, cashback: bool = False) -> float:
136    async def get_balance(self, cashback: bool = False) -> float:
137        pattern = re.compile(r'ACCESS_BALANCE:(\d+\.\d{2})')
138        response = await self.__send_request('getBalance' if not cashback else 'getBalanceAndCashBack')
139        match = pattern.match(response)
140        if not match:
141            raise SmsActivateException('Invalid response sequence')
142
143        return float(match.group(1))
async def get_balance_and_cashback(self):
144    async def get_balance_and_cashback(self):
145        return await self.get_balance(cashback=True)
async def get_available_countries(self, service: str, freePrice: bool | str) -> dict[str, ...]:
147    async def get_available_countries(self, service: str, freePrice: bool | str) -> dict[str, ...]:
148        response = await self.__send_request('getTopCountriesByService', params={
149            'service': service,
150            'freePrice': str(freePrice).lower()
151        })
152        
153        if not is_json(response):
154            return response
155        
156        return json.loads(response)
async def get_count_numbers(self, country: str, operator: str) -> dict[str, ...]:
158    async def get_count_numbers(self, country: str, operator: str) -> dict[str, ...]:
159        response = await self.__send_request('getNumbersStatus', params={
160            'country': country,
161            'operator': operator
162        })
163        
164        if not is_json(response):
165            return response
166        
167        return json.loads(response)
async def get_operators(self, country: str = None) -> dict[str, ...]:
169    async def get_operators(self, country: str = None) -> dict[str, ...]:
170        params = {}
171        if country is not None:
172            params["country"] = country
173        response = await self.__send_request('getOperators', params=params)
174        
175        if not is_json(response):
176            return response
177        
178        return json.loads(response)
async def get_active_activations(self) -> dict[str, ...]:
180    async def get_active_activations(self) -> dict[str, ...]:
181        response = await self.__send_request('getActiveActivations')
182        
183        if not is_json(response):
184            return response
185        
186        return json.loads(response)
async def get_activation_status_v1( self, id: str) -> tuple[aiosmsactivate.types.ActivationStatus, str | None]:
188    async def get_activation_status_v1(self, id: str) -> tuple[ActivationStatus, str | None]:
189        response = await self.__send_request('getStatus', params={
190            'id': id
191        })
192
193        data = response.split(':')
194
195        match data[0]:
196            case 'STATUS_WAIT_CODE':
197                return ActivationStatus.WAIT, None
198            case 'STATUS_WAIT_RETRY':
199                return ActivationStatus.RETRY, data[1]
200            case 'STATUS_WAIT_RESEND':
201                return ActivationStatus.RESEND, None
202            case 'STATUS_CANCEL':
203                return ActivationStatus.CANCEL, None
204            case 'STATUS_OK':
205                return ActivationStatus.OK, data[1]
206            case _:
207                raise SmsActivateException('Invalid response sequence')
async def get_activation_status( self, activation_id: str | int | aiosmsactivate.models.Number) -> aiosmsactivate.models.ActivationData | str:
209    async def get_activation_status(self, activation_id: str | int | Number) -> ActivationData | str:
210        if isinstance(activation_id, Number):
211            activation_id = activation_id.activation_id
212        response = await self.__send_request('getStatusV2', params={
213            'id': activation_id
214        })
215
216        if not is_json(response):
217            return response
218        
219        return ActivationData(**json.loads(response))
async def wait_sms_code( self, activation_id: str | int | aiosmsactivate.models.Number, timeout: int = 300, per_attempt: int = 5) -> aiosmsactivate.models.Sms | str | int | None:
221    async def wait_sms_code(self, activation_id: str | int | Number, timeout: int = 60*5, per_attempt: int = 5) -> Sms | str | int | None:
222        """
223        Ожидание смс кода
224        Wait sms code
225
226        Аргументы:
227            activation_id: activation_id номера или целый объект номера
228            timeout: максимальное время ожидание смс в секундах, по умолчанию 5 минут 
229            per_attempt: время между попыткой получить смс, по умолчанию 5 секунд
230            
231        Args:
232            activation_id: activation_id of number or Number object
233            timeout: maximum time to wait sms code 
234            per_attempt: time per attempt
235            
236        Returns: Sms
237        """
238        activation_id = activation_id.activation_id if isinstance(activation_id, Number) else activation_id
239        if not self._api_key:
240            raise ValueError('API key is required for this method')
241
242        try:
243            await self.set_activation_status(activation_id=activation_id, status=SetActivationStatus.READY)
244        except:
245            pass
246
247        start_time = time.time()
248        
249        while time.time() - start_time < timeout:
250            await asyncio.sleep(per_attempt)
251            status, code = await self.get_activation_status_v1(activation_id)
252            if status == ActivationStatus.OK:
253                try:
254                    await self.set_activation_status(activation_id, SetActivationStatus.AGAIN)
255                except:
256                    pass
257                return code
258        
259        return None

Ожидание смс кода Wait sms code

Аргументы: activation_id: activation_id номера или целый объект номера timeout: максимальное время ожидание смс в секундах, по умолчанию 5 минут per_attempt: время между попыткой получить смс, по умолчанию 5 секунд

Args: activation_id: activation_id of number or Number object timeout: maximum time to wait sms code per_attempt: time per attempt

Returns: Sms

async def purchase( self, service: str, forward: bool | None = None, maxPrice: float | None = None, phoneException: str | None = None, operator: str | None = None, activationType: int | str | None = None, language: str | None = None, userId: str | int | None = None, ref: str | None = None, country: str | None = None, useCashBack: bool | None = None, orderId: str | int | None = None, _is_v2: bool = True) -> aiosmsactivate.models.Number | str:
261    async def purchase(self, service: str, forward: bool | None = None, maxPrice: float | None = None,
262                       phoneException: str | None = None, operator: str | None = None,
263                       activationType: int | str | None = None, language: str | None = None,
264                       userId: str | int | None = None,
265                       ref: str | None = None, country: str | None = None,
266                       useCashBack: bool | None = None,
267                       orderId: str | int | None = None,
268                       _is_v2: bool = True
269                       ) -> Number | str:
270        response = await self.__send_request('getNumber' if not _is_v2 else 'getNumberV2', params={
271            'service': service,
272            **({'forward': 1 if forward else 0} if forward is not None else {}),
273            **({'maxPrice': str(maxPrice)} if maxPrice is not None else {}),
274            **({'phoneException': phoneException} if phoneException is not None else {}),
275            **({'operator': operator} if operator is not None else {}),
276            **({'activationType': str(activationType)} if activationType is not None else {}),
277            **({'language': str(language)} if language is not None else {}),
278            **({'userId': str(userId)} if userId is not None else {}),
279            **({'orderId': str(orderId)} if orderId is not None and _is_v2 else {}),
280            **({'ref': ref} if ref is not None else {}),
281            **({'country ': country} if country is not None else {}),
282            **({'useCashBack': str(useCashBack).lower()} if useCashBack is not None else {}),
283        })
284
285        if not is_json(response):
286            return response
287        
288        return Number.from_response(self, json.loads(response))
async def get_number(self, *args, **kwargs):
290    async def get_number(self, *args, **kwargs):
291        kwargs["_is_v2"] = False
292        return await self.purchase(*args, **kwargs)
async def get_multi_service_number( self, multiService: str, multiForward: str | None = None, operator: str | None = None, ref: str | None = None, country: str | None = None) -> dict:
294    async def get_multi_service_number(self, 
295                        multiService: str, multiForward: str | None = None,
296                        operator: str | None = None,
297                        ref: str | None = None, country: str | None = None,
298                       ) -> dict:
299        """
300        Get multiservice number.
301
302        :param multiService: service1,service2,service3 (Services separated by commas)
303        :param multiForward: 1,0,1 (forwards separated by commas, forwards count equal services count)
304        :return: dict object of response
305        """
306        response = await self.__send_request('getMultiServiceNumber', params={
307            'multiService': multiService,
308            **({'multiForward': multiForward} if multiForward is not None else {}),
309            **({'operator': operator} if operator is not None else {}),
310            **({'ref': ref} if ref is not None else {}),
311            **({'country ': country} if country is not None else {}),
312        })
313
314        if not is_json(response):
315            return response
316        
317        return json.loads(response)

Get multiservice number.

Parameters
  • multiService: service1,service2,service3 (Services separated by commas)
  • multiForward: 1,0,1 (forwards separated by commas, forwards count equal services count)
Returns

dict object of response

async def set_activation_status( self, activation_id: str | int, status: aiosmsactivate.types.SetActivationStatus | int, forward: str | None = None) -> aiosmsactivate.models.SetActivationStatusResponse:
320    async def set_activation_status(self, activation_id: str | int, status: SetActivationStatus | int,
321                                    forward: str | None = None) -> SetActivationStatusResponse:
322        members = {member.value: member for member in SetActivationStatusResponse}
323        response = await self.__send_request('setStatus', params={
324            'id': activation_id,
325            'status': status.value if isinstance(status, SetActivationStatus) else status,
326            **({'forward': forward} if forward is not None else {})
327        })
328
329        return members[response]
async def get_history( self, start: str | int = None, end: str | int = None, offset: str | int = None, limit: str | int = None) -> dict | list:
331    async def get_history(self, 
332                          start: str | int = None,
333                          end: str | int = None,
334                          offset: str | int = None,
335                          limit: str | int = None,
336                       ) -> dict | list:
337        response = await self.__send_request('getHistory', params={
338            **({'start': str(start)} if start is not None else {}),
339            **({'end': str(end)} if end is not None else {}),
340            **({'offset': str(offset)} if offset is not None else {}),
341            **({'limit': str(limit)} if limit is not None else {}),
342        })
343
344        if not is_json(response):
345            return response
346        
347        return json.loads(response)
async def get_list_top_countries(self, service: str) -> dict | list:
349    async def get_list_top_countries(self, 
350                          service: str,
351                       ) -> dict | list:
352        response = await self.__send_request('getListOfTopCountriesByService', params={
353            'service': service
354        })
355
356        if not is_json(response):
357            return response
358        
359        return json.loads(response)
async def get_incoming_call_status(self, id: str | int = None) -> dict | list:
361    async def get_incoming_call_status(self, 
362                          id: str | int = None,
363                       ) -> dict | list:
364        response = await self.__send_request('getIncomingCallStatus', params={
365            'activationId': id
366        })
367
368        if not is_json(response):
369            return response
370        
371        return json.loads(response)
async def get_prices(self, service: str = None, country: str = None) -> dict | list:
373    async def get_prices(self, 
374                          service: str = None,
375                          country: str = None,
376                       ) -> dict | list:
377        response = await self.__send_request('getPrices', params={
378            **({'service': str(service)} if service is not None else {}),
379            **({'country': str(country)} if country is not None else {}),
380        })
381
382        if not is_json(response):
383            return response
384        
385        return json.loads(response)
async def get_prices_verification(self, service: str = None) -> dict | list:
387    async def get_prices_verification(self, 
388                          service: str = None,
389                       ) -> dict | list:
390        response = await self.__send_request('getPricesVerification', params={
391            **({'service': str(service)} if service is not None else {}),
392        })
393
394        if not is_json(response):
395            return response
396        
397        return json.loads(response)
async def get_countries(self) -> dict | list:
399    async def get_countries(self,
400                       ) -> dict | list:
401        response = await self.__send_request('getCountries', params={
402        })
403
404        if not is_json(response):
405            return response
406        
407        return json.loads(response)
async def get_service_list( self, country: str = None, lang: Literal['ru', 'en', 'es', 'cn'] = None) -> dict | list:
409    async def get_service_list(self, 
410                          country: str = None,
411                          lang: Literal['ru', 'en', 'es', 'cn'] = None,
412                       ) -> dict | list:
413        response = await self.__send_request('getServicesList', params={
414            **({'country': str(country)} if country is not None else {}),
415            **({'lang': str(lang)} if lang is not None else {}),
416        })
417
418        if not is_json(response):
419            return response
420        
421        return json.loads(response)
async def get_additional_service(self, service: str = None, id: str = None):
423    async def get_additional_service(self, 
424                          service: str = None,
425                          id: str = None,
426                       ):
427        """
428        Get additional service to activation its cost 5rub
429        return 2 values: addition activation id and phone number
430        
431        use like this: 
432        activation_id, phone_number = await getAdditionalService(service, activation id)
433        """
434        response = await self.__send_request('getAdditionalService', params={
435            'service': service,
436            'id':id
437        })
438
439        data = response.split(':')
440        if len(data) > 2:
441            return data[1], data[2]
442        
443        return data

Get additional service to activation its cost 5rub return 2 values: addition activation id and phone number

use like this: activation_id, phone_number = await getAdditionalService(service, activation id)

async def get_extra_activation(self, id: str = None):
445    async def get_extra_activation(self, 
446                          id: str = None,
447                       ):
448        """
449        return 2 values: addition activation id and phone number
450        
451        use like this: 
452        activation_id, phone_number = await getExtraActivation(activation id)
453        """
454        response = await self.__send_request('getExtraActivation', params={
455            'id':id
456        })
457
458        data = response.split(':')
459        if len(data) > 2:
460            return data[1], data[2]
461        
462        return data

return 2 values: addition activation id and phone number

use like this: activation_id, phone_number = await getExtraActivation(activation id)

async def check_extra_activation(self, activationId: str | int) -> dict | list:
464    async def check_extra_activation(self, 
465                          activationId: str | int
466                       ) -> dict | list:
467        response = await self.__send_request('checkExtraActivation', params={
468            'activationId': str(activationId)
469        })
470
471        if not is_json(response):
472            return response
473        
474        return json.loads(response)
async def parse_call(self, id: str | int, newLang: str) -> dict | list:
476    async def parse_call(self, 
477                          id: str | int,
478                          newLang: str,
479                       ) -> dict | list:
480        response = await self.__send_request('parseCall', params={
481            "id": id,
482            "newLang": newLang,
483        })
484
485        if not is_json(response):
486            return response
487        
488        return json.loads(response)
async def get_rent_services_and_countries( self, time: int | str | None = None, operator: str | None = None, country: str | None = None, currency: str | None = None, incomingCall: bool | None = None) -> dict | str:
491    async def get_rent_services_and_countries(self,
492                       time: int | str | None = None,
493                       operator: str | None = None,
494                       country: str | None = None,
495                       currency: str | None = None,
496                       incomingCall: bool | None = None,
497                       ) -> dict | str:
498        response = await self.__send_request('getRentServicesAndCountries', params={
499            **({'time ': str(time )} if time is not None else {}),
500            **({'operator ': str(operator )} if operator is not None else {}),
501            **({'country ': str(country )} if country is not None else {}),
502            **({'currency ': str(currency )} if currency is not None else {}),
503            **({'incomingCall': str(incomingCall).lower()} if incomingCall is not None else {}),
504        })
505
506        if not is_json(response):
507            return response
508        
509        return json.loads(response)
async def get_rent_number( self, service: str, time: int | str | None = None, operator: str | None = None, country: str | None = None, url: str | None = None, incomingCall: bool | None = None) -> dict | str:
511    async def get_rent_number(self,
512                        service: str,
513                        time: int | str | None = None,
514                        operator: str | None = None,
515                        country: str | None = None,
516                        url: str | None = None,
517                        incomingCall: bool | None = None,
518                       ) -> dict | str:
519        response = await self.__send_request('getRentNumber', params={
520            'service': service,
521            **({'time ': str(time )} if time is not None else {}),
522            **({'operator ': str(operator )} if operator is not None else {}),
523            **({'country ': str(country )} if country is not None else {}),
524            **({'url ': str(url )} if url is not None else {}),
525            **({'incomingCall': str(incomingCall).lower()} if incomingCall is not None else {}),
526        })
527
528        if not is_json(response):
529            return response
530        
531        return json.loads(response)
async def get_rent_status( self, id: str, page: int | str | None = None, size: int | str | None = None) -> dict | str:
533    async def get_rent_status(self,
534                        id: str,
535                        page: int | str | None = None,
536                        size: int | str | None = None,
537                       ) -> dict | str:
538        response = await self.__send_request('getRentStatus', params={
539            'id': id,
540            **({'page ': str(page)} if page is not None else {}),
541            **({'size ': str(size )} if size is not None else {}),
542        })
543
544        if not is_json(response):
545            return response
546        
547        return json.loads(response)
async def set_rent_status(self, id: str, status: Literal[1, 2, '1', '2']) -> dict | str:
549    async def set_rent_status(self,
550                        id: str,
551                        status: Literal[1, 2, '1', '2'],
552                       ) -> dict | str:
553        response = await self.__send_request('getRentStatus', params={
554            'id': str(id),
555            'status': str(status),
556        })
557
558        if not is_json(response):
559            return response
560        
561        return json.loads(response)
async def get_rent_list(self) -> dict | str:
563    async def get_rent_list(self,
564                       ) -> dict | str:
565        response = await self.__send_request('getRentList', params={
566        })
567
568        if not is_json(response):
569            return response
570        
571        return json.loads(response)
async def continue_rent_number(self, id: str, rent_time: int | str | None = 4) -> dict | str:
573    async def continue_rent_number(self,
574                        id: str,
575                        rent_time: int | str | None = 4,
576                       ) -> dict | str:
577        response = await self.__send_request('continueRentNumber', params={
578            'id': id,
579            'rent_time': str(rent_time)
580        })
581
582        if not is_json(response):
583            return response
584        
585        return json.loads(response)
async def get_continue_rent_price_number( self, id: str, rent_time: int | str | None = 4, currency: str | None = None) -> dict | str:
587    async def get_continue_rent_price_number(self,
588                        id: str,
589                        rent_time: int | str | None = 4,
590                        currency: str | None = None
591                       ) -> dict | str:
592        response = await self.__send_request('getContinueRentPriceNumber', params={
593            'id': id,
594            'rent_time': str(rent_time),
595            **({'currency ': str(currency )} if currency is not None else {}),
596        })
597
598        if not is_json(response):
599            return response
600        
601        return json.loads(response)
async def buy_partner_product(self, id: str) -> dict | str:
604    async def buy_partner_product(self,
605                        id: str,
606                       ) -> dict | str:
607        response = await self.__send_request('buyPartnerProduct', params={
608            'id': id,
609        })
610
611        if not is_json(response):
612            return response
613        
614        return json.loads(response)
async def getBalance(self, cashback: bool = False) -> float:
136    async def get_balance(self, cashback: bool = False) -> float:
137        pattern = re.compile(r'ACCESS_BALANCE:(\d+\.\d{2})')
138        response = await self.__send_request('getBalance' if not cashback else 'getBalanceAndCashBack')
139        match = pattern.match(response)
140        if not match:
141            raise SmsActivateException('Invalid response sequence')
142
143        return float(match.group(1))
async def getBalanceAndCashBack(self):
144    async def get_balance_and_cashback(self):
145        return await self.get_balance(cashback=True)
async def getTopCountriesByService(self, service: str, freePrice: bool | str) -> dict[str, ...]:
147    async def get_available_countries(self, service: str, freePrice: bool | str) -> dict[str, ...]:
148        response = await self.__send_request('getTopCountriesByService', params={
149            'service': service,
150            'freePrice': str(freePrice).lower()
151        })
152        
153        if not is_json(response):
154            return response
155        
156        return json.loads(response)
async def getNumbersStatus(self, country: str, operator: str) -> dict[str, ...]:
158    async def get_count_numbers(self, country: str, operator: str) -> dict[str, ...]:
159        response = await self.__send_request('getNumbersStatus', params={
160            'country': country,
161            'operator': operator
162        })
163        
164        if not is_json(response):
165            return response
166        
167        return json.loads(response)
async def getOperators(self, country: str = None) -> dict[str, ...]:
169    async def get_operators(self, country: str = None) -> dict[str, ...]:
170        params = {}
171        if country is not None:
172            params["country"] = country
173        response = await self.__send_request('getOperators', params=params)
174        
175        if not is_json(response):
176            return response
177        
178        return json.loads(response)
async def getActiveActivations(self) -> dict[str, ...]:
180    async def get_active_activations(self) -> dict[str, ...]:
181        response = await self.__send_request('getActiveActivations')
182        
183        if not is_json(response):
184            return response
185        
186        return json.loads(response)
async def getStatus( self, id: str) -> tuple[aiosmsactivate.types.ActivationStatus, str | None]:
188    async def get_activation_status_v1(self, id: str) -> tuple[ActivationStatus, str | None]:
189        response = await self.__send_request('getStatus', params={
190            'id': id
191        })
192
193        data = response.split(':')
194
195        match data[0]:
196            case 'STATUS_WAIT_CODE':
197                return ActivationStatus.WAIT, None
198            case 'STATUS_WAIT_RETRY':
199                return ActivationStatus.RETRY, data[1]
200            case 'STATUS_WAIT_RESEND':
201                return ActivationStatus.RESEND, None
202            case 'STATUS_CANCEL':
203                return ActivationStatus.CANCEL, None
204            case 'STATUS_OK':
205                return ActivationStatus.OK, data[1]
206            case _:
207                raise SmsActivateException('Invalid response sequence')
async def getStatusV2( self, activation_id: str | int | aiosmsactivate.models.Number) -> aiosmsactivate.models.ActivationData | str:
209    async def get_activation_status(self, activation_id: str | int | Number) -> ActivationData | str:
210        if isinstance(activation_id, Number):
211            activation_id = activation_id.activation_id
212        response = await self.__send_request('getStatusV2', params={
213            'id': activation_id
214        })
215
216        if not is_json(response):
217            return response
218        
219        return ActivationData(**json.loads(response))
async def getNumberV2( self, service: str, forward: bool | None = None, maxPrice: float | None = None, phoneException: str | None = None, operator: str | None = None, activationType: int | str | None = None, language: str | None = None, userId: str | int | None = None, ref: str | None = None, country: str | None = None, useCashBack: bool | None = None, orderId: str | int | None = None, _is_v2: bool = True) -> aiosmsactivate.models.Number | str:
261    async def purchase(self, service: str, forward: bool | None = None, maxPrice: float | None = None,
262                       phoneException: str | None = None, operator: str | None = None,
263                       activationType: int | str | None = None, language: str | None = None,
264                       userId: str | int | None = None,
265                       ref: str | None = None, country: str | None = None,
266                       useCashBack: bool | None = None,
267                       orderId: str | int | None = None,
268                       _is_v2: bool = True
269                       ) -> Number | str:
270        response = await self.__send_request('getNumber' if not _is_v2 else 'getNumberV2', params={
271            'service': service,
272            **({'forward': 1 if forward else 0} if forward is not None else {}),
273            **({'maxPrice': str(maxPrice)} if maxPrice is not None else {}),
274            **({'phoneException': phoneException} if phoneException is not None else {}),
275            **({'operator': operator} if operator is not None else {}),
276            **({'activationType': str(activationType)} if activationType is not None else {}),
277            **({'language': str(language)} if language is not None else {}),
278            **({'userId': str(userId)} if userId is not None else {}),
279            **({'orderId': str(orderId)} if orderId is not None and _is_v2 else {}),
280            **({'ref': ref} if ref is not None else {}),
281            **({'country ': country} if country is not None else {}),
282            **({'useCashBack': str(useCashBack).lower()} if useCashBack is not None else {}),
283        })
284
285        if not is_json(response):
286            return response
287        
288        return Number.from_response(self, json.loads(response))
async def purchase_v1(self, *args, **kwargs):
290    async def get_number(self, *args, **kwargs):
291        kwargs["_is_v2"] = False
292        return await self.purchase(*args, **kwargs)
async def getNumber(self, *args, **kwargs):
290    async def get_number(self, *args, **kwargs):
291        kwargs["_is_v2"] = False
292        return await self.purchase(*args, **kwargs)
async def getMultiServiceNumber( self, multiService: str, multiForward: str | None = None, operator: str | None = None, ref: str | None = None, country: str | None = None) -> dict:
294    async def get_multi_service_number(self, 
295                        multiService: str, multiForward: str | None = None,
296                        operator: str | None = None,
297                        ref: str | None = None, country: str | None = None,
298                       ) -> dict:
299        """
300        Get multiservice number.
301
302        :param multiService: service1,service2,service3 (Services separated by commas)
303        :param multiForward: 1,0,1 (forwards separated by commas, forwards count equal services count)
304        :return: dict object of response
305        """
306        response = await self.__send_request('getMultiServiceNumber', params={
307            'multiService': multiService,
308            **({'multiForward': multiForward} if multiForward is not None else {}),
309            **({'operator': operator} if operator is not None else {}),
310            **({'ref': ref} if ref is not None else {}),
311            **({'country ': country} if country is not None else {}),
312        })
313
314        if not is_json(response):
315            return response
316        
317        return json.loads(response)

Get multiservice number.

Parameters
  • multiService: service1,service2,service3 (Services separated by commas)
  • multiForward: 1,0,1 (forwards separated by commas, forwards count equal services count)
Returns

dict object of response

async def setStatus( self, activation_id: str | int, status: aiosmsactivate.types.SetActivationStatus | int, forward: str | None = None) -> aiosmsactivate.models.SetActivationStatusResponse:
320    async def set_activation_status(self, activation_id: str | int, status: SetActivationStatus | int,
321                                    forward: str | None = None) -> SetActivationStatusResponse:
322        members = {member.value: member for member in SetActivationStatusResponse}
323        response = await self.__send_request('setStatus', params={
324            'id': activation_id,
325            'status': status.value if isinstance(status, SetActivationStatus) else status,
326            **({'forward': forward} if forward is not None else {})
327        })
328
329        return members[response]
async def getHistory( self, start: str | int = None, end: str | int = None, offset: str | int = None, limit: str | int = None) -> dict | list:
331    async def get_history(self, 
332                          start: str | int = None,
333                          end: str | int = None,
334                          offset: str | int = None,
335                          limit: str | int = None,
336                       ) -> dict | list:
337        response = await self.__send_request('getHistory', params={
338            **({'start': str(start)} if start is not None else {}),
339            **({'end': str(end)} if end is not None else {}),
340            **({'offset': str(offset)} if offset is not None else {}),
341            **({'limit': str(limit)} if limit is not None else {}),
342        })
343
344        if not is_json(response):
345            return response
346        
347        return json.loads(response)
async def getListOfTopCountriesByService(self, service: str) -> dict | list:
349    async def get_list_top_countries(self, 
350                          service: str,
351                       ) -> dict | list:
352        response = await self.__send_request('getListOfTopCountriesByService', params={
353            'service': service
354        })
355
356        if not is_json(response):
357            return response
358        
359        return json.loads(response)
async def getIncomingCallStatus(self, id: str | int = None) -> dict | list:
361    async def get_incoming_call_status(self, 
362                          id: str | int = None,
363                       ) -> dict | list:
364        response = await self.__send_request('getIncomingCallStatus', params={
365            'activationId': id
366        })
367
368        if not is_json(response):
369            return response
370        
371        return json.loads(response)
async def getPrices(self, service: str = None, country: str = None) -> dict | list:
373    async def get_prices(self, 
374                          service: str = None,
375                          country: str = None,
376                       ) -> dict | list:
377        response = await self.__send_request('getPrices', params={
378            **({'service': str(service)} if service is not None else {}),
379            **({'country': str(country)} if country is not None else {}),
380        })
381
382        if not is_json(response):
383            return response
384        
385        return json.loads(response)
async def getPricesVerification(self, service: str = None) -> dict | list:
387    async def get_prices_verification(self, 
388                          service: str = None,
389                       ) -> dict | list:
390        response = await self.__send_request('getPricesVerification', params={
391            **({'service': str(service)} if service is not None else {}),
392        })
393
394        if not is_json(response):
395            return response
396        
397        return json.loads(response)
async def getCountries(self) -> dict | list:
399    async def get_countries(self,
400                       ) -> dict | list:
401        response = await self.__send_request('getCountries', params={
402        })
403
404        if not is_json(response):
405            return response
406        
407        return json.loads(response)
async def getServicesList( self, country: str = None, lang: Literal['ru', 'en', 'es', 'cn'] = None) -> dict | list:
409    async def get_service_list(self, 
410                          country: str = None,
411                          lang: Literal['ru', 'en', 'es', 'cn'] = None,
412                       ) -> dict | list:
413        response = await self.__send_request('getServicesList', params={
414            **({'country': str(country)} if country is not None else {}),
415            **({'lang': str(lang)} if lang is not None else {}),
416        })
417
418        if not is_json(response):
419            return response
420        
421        return json.loads(response)
async def getAdditionalService(self, service: str = None, id: str = None):
423    async def get_additional_service(self, 
424                          service: str = None,
425                          id: str = None,
426                       ):
427        """
428        Get additional service to activation its cost 5rub
429        return 2 values: addition activation id and phone number
430        
431        use like this: 
432        activation_id, phone_number = await getAdditionalService(service, activation id)
433        """
434        response = await self.__send_request('getAdditionalService', params={
435            'service': service,
436            'id':id
437        })
438
439        data = response.split(':')
440        if len(data) > 2:
441            return data[1], data[2]
442        
443        return data

Get additional service to activation its cost 5rub return 2 values: addition activation id and phone number

use like this: activation_id, phone_number = await getAdditionalService(service, activation id)

async def getExtraActivation(self, id: str = None):
445    async def get_extra_activation(self, 
446                          id: str = None,
447                       ):
448        """
449        return 2 values: addition activation id and phone number
450        
451        use like this: 
452        activation_id, phone_number = await getExtraActivation(activation id)
453        """
454        response = await self.__send_request('getExtraActivation', params={
455            'id':id
456        })
457
458        data = response.split(':')
459        if len(data) > 2:
460            return data[1], data[2]
461        
462        return data

return 2 values: addition activation id and phone number

use like this: activation_id, phone_number = await getExtraActivation(activation id)

async def checkExtraActivation(self, activationId: str | int) -> dict | list:
464    async def check_extra_activation(self, 
465                          activationId: str | int
466                       ) -> dict | list:
467        response = await self.__send_request('checkExtraActivation', params={
468            'activationId': str(activationId)
469        })
470
471        if not is_json(response):
472            return response
473        
474        return json.loads(response)
async def parseCall(self, id: str | int, newLang: str) -> dict | list:
476    async def parse_call(self, 
477                          id: str | int,
478                          newLang: str,
479                       ) -> dict | list:
480        response = await self.__send_request('parseCall', params={
481            "id": id,
482            "newLang": newLang,
483        })
484
485        if not is_json(response):
486            return response
487        
488        return json.loads(response)
async def getRentServicesAndCountries( self, time: int | str | None = None, operator: str | None = None, country: str | None = None, currency: str | None = None, incomingCall: bool | None = None) -> dict | str:
491    async def get_rent_services_and_countries(self,
492                       time: int | str | None = None,
493                       operator: str | None = None,
494                       country: str | None = None,
495                       currency: str | None = None,
496                       incomingCall: bool | None = None,
497                       ) -> dict | str:
498        response = await self.__send_request('getRentServicesAndCountries', params={
499            **({'time ': str(time )} if time is not None else {}),
500            **({'operator ': str(operator )} if operator is not None else {}),
501            **({'country ': str(country )} if country is not None else {}),
502            **({'currency ': str(currency )} if currency is not None else {}),
503            **({'incomingCall': str(incomingCall).lower()} if incomingCall is not None else {}),
504        })
505
506        if not is_json(response):
507            return response
508        
509        return json.loads(response)
async def getRentNumber( self, service: str, time: int | str | None = None, operator: str | None = None, country: str | None = None, url: str | None = None, incomingCall: bool | None = None) -> dict | str:
511    async def get_rent_number(self,
512                        service: str,
513                        time: int | str | None = None,
514                        operator: str | None = None,
515                        country: str | None = None,
516                        url: str | None = None,
517                        incomingCall: bool | None = None,
518                       ) -> dict | str:
519        response = await self.__send_request('getRentNumber', params={
520            'service': service,
521            **({'time ': str(time )} if time is not None else {}),
522            **({'operator ': str(operator )} if operator is not None else {}),
523            **({'country ': str(country )} if country is not None else {}),
524            **({'url ': str(url )} if url is not None else {}),
525            **({'incomingCall': str(incomingCall).lower()} if incomingCall is not None else {}),
526        })
527
528        if not is_json(response):
529            return response
530        
531        return json.loads(response)
async def getRentStatus( self, id: str, page: int | str | None = None, size: int | str | None = None) -> dict | str:
533    async def get_rent_status(self,
534                        id: str,
535                        page: int | str | None = None,
536                        size: int | str | None = None,
537                       ) -> dict | str:
538        response = await self.__send_request('getRentStatus', params={
539            'id': id,
540            **({'page ': str(page)} if page is not None else {}),
541            **({'size ': str(size )} if size is not None else {}),
542        })
543
544        if not is_json(response):
545            return response
546        
547        return json.loads(response)
async def getRentList(self) -> dict | str:
563    async def get_rent_list(self,
564                       ) -> dict | str:
565        response = await self.__send_request('getRentList', params={
566        })
567
568        if not is_json(response):
569            return response
570        
571        return json.loads(response)
async def continueRentNumber(self, id: str, rent_time: int | str | None = 4) -> dict | str:
573    async def continue_rent_number(self,
574                        id: str,
575                        rent_time: int | str | None = 4,
576                       ) -> dict | str:
577        response = await self.__send_request('continueRentNumber', params={
578            'id': id,
579            'rent_time': str(rent_time)
580        })
581
582        if not is_json(response):
583            return response
584        
585        return json.loads(response)
async def getContinueRentPriceNumber( self, id: str, rent_time: int | str | None = 4, currency: str | None = None) -> dict | str:
587    async def get_continue_rent_price_number(self,
588                        id: str,
589                        rent_time: int | str | None = 4,
590                        currency: str | None = None
591                       ) -> dict | str:
592        response = await self.__send_request('getContinueRentPriceNumber', params={
593            'id': id,
594            'rent_time': str(rent_time),
595            **({'currency ': str(currency )} if currency is not None else {}),
596        })
597
598        if not is_json(response):
599            return response
600        
601        return json.loads(response)
async def buyPartnerProduct(self, id: str) -> dict | str:
604    async def buy_partner_product(self,
605                        id: str,
606                       ) -> dict | str:
607        response = await self.__send_request('buyPartnerProduct', params={
608            'id': id,
609        })
610
611        if not is_json(response):
612            return response
613        
614        return json.loads(response)