aiosmsactivate.client

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

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'])
51    def __init__(self, api_key: str, base_url: str | list = allowed_domains):
52        """
53        RU  
54        api_key передавать api ключ, получить можно вот тут: https://sms-activate.page/profile
55        В base_url можно указать список адресов, модуль будет проходиться по всем, пока не найдёт рабочий
56        а можно указать один или вообще не указывать, если не указать будет браться из allowed_domains  
57        
58        EN  
59        api_key to transfer the api key, you can get it here: https://sms-activate.page/profile
60        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.
61        or you can specify one or not at all, if not specified, it will be taken from allowed_domains.
62        """
63        self._api_key = api_key
64        if isinstance(base_url, str):
65            base_url = [base_url]
66        self._base_urls = base_url
67        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:
100    async def get_balance(self, cashback: bool = False) -> float:
101        pattern = re.compile(r'ACCESS_BALANCE:(\d+\.\d{2})')
102        response = await self.__send_request('getBalance' if not cashback else 'getBalanceAndCashBack')
103        match = pattern.match(response)
104        if not match:
105            raise SmsActivateException('Invalid response sequence')
106
107        return float(match.group(1))
async def get_balance_and_cashback(self):
108    async def get_balance_and_cashback(self):
109        return await self.get_balance(cashback=True)
async def get_available_countries(self, service: str, freePrice: bool | str) -> dict[str, ...]:
111    async def get_available_countries(self, service: str, freePrice: bool | str) -> dict[str, ...]:
112        response = await self.__send_request('getTopCountriesByService', params={
113            'service': service,
114            'freePrice': str(freePrice).lower()
115        })
116        
117        if not is_json(response):
118            return response
119        
120        return json.loads(response)
async def get_count_numbers(self, country: str, operator: str) -> dict[str, ...]:
122    async def get_count_numbers(self, country: str, operator: str) -> dict[str, ...]:
123        response = await self.__send_request('getNumbersStatus', params={
124            'country': country,
125            'operator': operator
126        })
127        
128        if not is_json(response):
129            return response
130        
131        return json.loads(response)
async def get_operators(self, country: str = None) -> dict[str, ...]:
133    async def get_operators(self, country: str = None) -> dict[str, ...]:
134        params = {}
135        if country is not None:
136            params["country"] = country
137        response = await self.__send_request('getOperators', params=params)
138        
139        if not is_json(response):
140            return response
141        
142        return json.loads(response)
async def get_active_activations(self) -> dict[str, ...]:
144    async def get_active_activations(self) -> dict[str, ...]:
145        response = await self.__send_request('getActiveActivations')
146        
147        if not is_json(response):
148            return response
149        
150        return json.loads(response)
async def get_activation_status_v1( self, id: str) -> tuple[aiosmsactivate.types.ActivationStatus, str | None]:
152    async def get_activation_status_v1(self, id: str) -> tuple[ActivationStatus, str | None]:
153        response = await self.__send_request('getStatus', params={
154            'id': id
155        })
156
157        data = response.split(':')
158
159        match data[0]:
160            case 'STATUS_WAIT_CODE':
161                return ActivationStatus.WAIT, None
162            case 'STATUS_WAIT_RETRY':
163                return ActivationStatus.RETRY, data[1]
164            case 'STATUS_WAIT_RESEND':
165                return ActivationStatus.RESEND, None
166            case 'STATUS_CANCEL':
167                return ActivationStatus.CANCEL, None
168            case 'STATUS_OK':
169                return ActivationStatus.OK, data[1]
170            case _:
171                raise SmsActivateException('Invalid response sequence')
async def get_activation_status( self, id: str) -> tuple[aiosmsactivate.types.ActivationStatus, str | None] | dict:
173    async def get_activation_status(self, id: str) -> tuple[ActivationStatus, str | None] | dict:
174        response = await self.__send_request('getStatusV2', params={
175            'id': id
176        })
177
178        if not is_json(response):
179            return response
180        
181        return json.loads(response)
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) -> dict | str:
183    async def purchase(self, service: str, forward: bool | None = None, maxPrice: float | None = None,
184                       phoneException: str | None = None, operator: str | None = None,
185                       activationType: int | str | None = None, language: str | None = None,
186                       userId: str | int | None = None,
187                       ref: str | None = None, country: str | None = None,
188                       useCashBack: bool | None = None,
189                       orderId: str | int | None = None,
190                       _is_v2: bool = True
191                       ) -> dict | str:
192        response = await self.__send_request('getNumber' if not _is_v2 else 'getNumberV2', params={
193            'service': service,
194            **({'forward': 1 if forward else 0} if forward is not None else {}),
195            **({'maxPrice': str(maxPrice)} if maxPrice is not None else {}),
196            **({'phoneException': phoneException} if phoneException is not None else {}),
197            **({'operator': operator} if operator is not None else {}),
198            **({'activationType': str(activationType)} if activationType is not None else {}),
199            **({'language': str(language)} if language is not None else {}),
200            **({'userId': str(userId)} if userId is not None else {}),
201            **({'orderId': str(orderId)} if orderId is not None and _is_v2 else {}),
202            **({'ref': ref} if ref is not None else {}),
203            **({'country ': country} if country is not None else {}),
204            **({'useCashBack': str(useCashBack).lower()} if useCashBack is not None else {}),
205        })
206
207        if not is_json(response):
208            return response
209        
210        return json.loads(response)
async def get_number(self, *args, **kwargs):
212    async def get_number(self, *args, **kwargs):
213        kwargs["_is_v2"] = False
214        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:
216    async def get_multi_service_number(self, 
217                        multiService: str, multiForward: str | None = None,
218                        operator: str | None = None,
219                        ref: str | None = None, country: str | None = None,
220                       ) -> dict:
221        """
222        Get multiservice number.
223
224        :param multiService: service1,service2,service3 (Services separated by commas)
225        :param multiForward: 1,0,1 (forwards separated by commas, forwards count equal services count)
226        :return: dict object of response
227        """
228        response = await self.__send_request('getMultiServiceNumber', params={
229            'multiService': multiService,
230            **({'multiForward': multiForward} if multiForward is not None else {}),
231            **({'operator': operator} if operator is not None else {}),
232            **({'ref': ref} if ref is not None else {}),
233            **({'country ': country} if country is not None else {}),
234        })
235
236        if not is_json(response):
237            return response
238        
239        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, id: str, status: aiosmsactivate.types.SetActivationStatus, forward: str | None = None) -> aiosmsactivate.responses.SetActivationStatusResponse:
242    async def set_activation_status(self, id: str, status: SetActivationStatus,
243                                    forward: str | None = None) -> SetActivationStatusResponse:
244        members = {member.value: member for member in SetActivationStatusResponse}
245
246        response = await self.__send_request('setStatus', params={
247            'id': id,
248            'status': status.value,
249            **({'forward': forward} if forward is not None else {})
250        })
251
252        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:
254    async def get_history(self, 
255                          start: str | int = None,
256                          end: str | int = None,
257                          offset: str | int = None,
258                          limit: str | int = None,
259                       ) -> dict | list:
260        response = await self.__send_request('getHistory', params={
261            **({'start': str(start)} if start is not None else {}),
262            **({'end': str(end)} if end is not None else {}),
263            **({'offset': str(offset)} if offset is not None else {}),
264            **({'limit': str(limit)} if limit is not None else {}),
265        })
266
267        if not is_json(response):
268            return response
269        
270        return json.loads(response)
async def get_list_top_countries(self, service: str) -> dict | list:
272    async def get_list_top_countries(self, 
273                          service: str,
274                       ) -> dict | list:
275        response = await self.__send_request('getListOfTopCountriesByService', params={
276            'service': service
277        })
278
279        if not is_json(response):
280            return response
281        
282        return json.loads(response)
async def get_incoming_call_status(self, id: str | int = None) -> dict | list:
284    async def get_incoming_call_status(self, 
285                          id: str | int = None,
286                       ) -> dict | list:
287        response = await self.__send_request('getIncomingCallStatus', params={
288            'activationId': id
289        })
290
291        if not is_json(response):
292            return response
293        
294        return json.loads(response)
async def get_prices(self, service: str = None, country: str = None) -> dict | list:
296    async def get_prices(self, 
297                          service: str = None,
298                          country: str = None,
299                       ) -> dict | list:
300        response = await self.__send_request('getPrices', params={
301            **({'service': str(service)} if service is not None else {}),
302            **({'country': str(country)} if country is not None else {}),
303        })
304
305        if not is_json(response):
306            return response
307        
308        return json.loads(response)
async def get_prices_verification(self, service: str = None) -> dict | list:
310    async def get_prices_verification(self, 
311                          service: str = None,
312                       ) -> dict | list:
313        response = await self.__send_request('getPricesVerification', params={
314            **({'service': str(service)} if service is not None else {}),
315        })
316
317        if not is_json(response):
318            return response
319        
320        return json.loads(response)
async def get_countries(self) -> dict | list:
322    async def get_countries(self,
323                       ) -> dict | list:
324        response = await self.__send_request('getCountries', params={
325        })
326
327        if not is_json(response):
328            return response
329        
330        return json.loads(response)
async def get_service_list( self, country: str = None, lang: Literal['ru', 'en', 'es', 'cn'] = None) -> dict | list:
332    async def get_service_list(self, 
333                          country: str = None,
334                          lang: Literal['ru', 'en', 'es', 'cn'] = None,
335                       ) -> dict | list:
336        response = await self.__send_request('getServicesList', params={
337            **({'country': str(country)} if country is not None else {}),
338            **({'lang': str(lang)} if lang is not None else {}),
339        })
340
341        if not is_json(response):
342            return response
343        
344        return json.loads(response)
async def get_additional_service(self, service: str = None, id: str = None):
346    async def get_additional_service(self, 
347                          service: str = None,
348                          id: str = None,
349                       ):
350        """
351        Get additional service to activation its cost 5rub
352        return 2 values: addition activation id and phone number
353        
354        use like this: 
355        activation_id, phone_number = await getAdditionalService(service, activation id)
356        """
357        response = await self.__send_request('getAdditionalService', params={
358            'service': service,
359            'id':id
360        })
361
362        data = response.split(':')
363        if len(data) > 2:
364            return data[1], data[2]
365        
366        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):
368    async def get_extra_activation(self, 
369                          id: str = None,
370                       ):
371        """
372        return 2 values: addition activation id and phone number
373        
374        use like this: 
375        activation_id, phone_number = await getExtraActivation(activation id)
376        """
377        response = await self.__send_request('getExtraActivation', params={
378            'id':id
379        })
380
381        data = response.split(':')
382        if len(data) > 2:
383            return data[1], data[2]
384        
385        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:
387    async def check_extra_activation(self, 
388                          activationId: str | int
389                       ) -> dict | list:
390        response = await self.__send_request('checkExtraActivation', params={
391            'activationId': str(activationId)
392        })
393
394        if not is_json(response):
395            return response
396        
397        return json.loads(response)
async def parse_call(self, id: str | int, newLang: str) -> dict | list:
399    async def parse_call(self, 
400                          id: str | int,
401                          newLang: str,
402                       ) -> dict | list:
403        response = await self.__send_request('parseCall', params={
404            "id": id,
405            "newLang": newLang,
406        })
407
408        if not is_json(response):
409            return response
410        
411        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:
414    async def get_rent_services_and_countries(self,
415                       time: int | str | None = None,
416                       operator: str | None = None,
417                       country: str | None = None,
418                       currency: str | None = None,
419                       incomingCall: bool | None = None,
420                       ) -> dict | str:
421        response = await self.__send_request('getRentServicesAndCountries', params={
422            **({'time ': str(time )} if time is not None else {}),
423            **({'operator ': str(operator )} if operator is not None else {}),
424            **({'country ': str(country )} if country is not None else {}),
425            **({'currency ': str(currency )} if currency is not None else {}),
426            **({'incomingCall': str(incomingCall).lower()} if incomingCall is not None else {}),
427        })
428
429        if not is_json(response):
430            return response
431        
432        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:
434    async def get_rent_number(self,
435                        service: str,
436                        time: int | str | None = None,
437                        operator: str | None = None,
438                        country: str | None = None,
439                        url: str | None = None,
440                        incomingCall: bool | None = None,
441                       ) -> dict | str:
442        response = await self.__send_request('getRentNumber', params={
443            'service': service,
444            **({'time ': str(time )} if time is not None else {}),
445            **({'operator ': str(operator )} if operator is not None else {}),
446            **({'country ': str(country )} if country is not None else {}),
447            **({'url ': str(url )} if url is not None else {}),
448            **({'incomingCall': str(incomingCall).lower()} if incomingCall is not None else {}),
449        })
450
451        if not is_json(response):
452            return response
453        
454        return json.loads(response)
async def get_rent_status( self, id: str, page: int | str | None = None, size: int | str | None = None) -> dict | str:
456    async def get_rent_status(self,
457                        id: str,
458                        page: int | str | None = None,
459                        size: int | str | None = None,
460                       ) -> dict | str:
461        response = await self.__send_request('getRentStatus', params={
462            'id': id,
463            **({'page ': str(page)} if page is not None else {}),
464            **({'size ': str(size )} if size is not None else {}),
465        })
466
467        if not is_json(response):
468            return response
469        
470        return json.loads(response)
async def set_rent_status(self, id: str, status: Literal[1, 2, '1', '2']) -> dict | str:
472    async def set_rent_status(self,
473                        id: str,
474                        status: Literal[1, 2, '1', '2'],
475                       ) -> dict | str:
476        response = await self.__send_request('getRentStatus', params={
477            'id': str(id),
478            'status': str(status),
479        })
480
481        if not is_json(response):
482            return response
483        
484        return json.loads(response)
async def get_rent_list(self) -> dict | str:
486    async def get_rent_list(self,
487                       ) -> dict | str:
488        response = await self.__send_request('getRentList', params={
489        })
490
491        if not is_json(response):
492            return response
493        
494        return json.loads(response)
async def continue_rent_number(self, id: str, rent_time: int | str | None = 4) -> dict | str:
496    async def continue_rent_number(self,
497                        id: str,
498                        rent_time: int | str | None = 4,
499                       ) -> dict | str:
500        response = await self.__send_request('continueRentNumber', params={
501            'id': id,
502            'rent_time': str(rent_time)
503        })
504
505        if not is_json(response):
506            return response
507        
508        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:
510    async def get_continue_rent_price_number(self,
511                        id: str,
512                        rent_time: int | str | None = 4,
513                        currency: str | None = None
514                       ) -> dict | str:
515        response = await self.__send_request('getContinueRentPriceNumber', params={
516            'id': id,
517            'rent_time': str(rent_time),
518            **({'currency ': str(currency )} if currency is not None else {}),
519        })
520
521        if not is_json(response):
522            return response
523        
524        return json.loads(response)
async def buy_partner_product(self, id: str) -> dict | str:
527    async def buy_partner_product(self,
528                        id: str,
529                       ) -> dict | str:
530        response = await self.__send_request('buyPartnerProduct', params={
531            'id': id,
532        })
533
534        if not is_json(response):
535            return response
536        
537        return json.loads(response)
async def getBalance(self, cashback: bool = False) -> float:
100    async def get_balance(self, cashback: bool = False) -> float:
101        pattern = re.compile(r'ACCESS_BALANCE:(\d+\.\d{2})')
102        response = await self.__send_request('getBalance' if not cashback else 'getBalanceAndCashBack')
103        match = pattern.match(response)
104        if not match:
105            raise SmsActivateException('Invalid response sequence')
106
107        return float(match.group(1))
async def getBalanceAndCashBack(self):
108    async def get_balance_and_cashback(self):
109        return await self.get_balance(cashback=True)
async def getTopCountriesByService(self, service: str, freePrice: bool | str) -> dict[str, ...]:
111    async def get_available_countries(self, service: str, freePrice: bool | str) -> dict[str, ...]:
112        response = await self.__send_request('getTopCountriesByService', params={
113            'service': service,
114            'freePrice': str(freePrice).lower()
115        })
116        
117        if not is_json(response):
118            return response
119        
120        return json.loads(response)
async def getNumbersStatus(self, country: str, operator: str) -> dict[str, ...]:
122    async def get_count_numbers(self, country: str, operator: str) -> dict[str, ...]:
123        response = await self.__send_request('getNumbersStatus', params={
124            'country': country,
125            'operator': operator
126        })
127        
128        if not is_json(response):
129            return response
130        
131        return json.loads(response)
async def getOperators(self, country: str = None) -> dict[str, ...]:
133    async def get_operators(self, country: str = None) -> dict[str, ...]:
134        params = {}
135        if country is not None:
136            params["country"] = country
137        response = await self.__send_request('getOperators', params=params)
138        
139        if not is_json(response):
140            return response
141        
142        return json.loads(response)
async def getActiveActivations(self) -> dict[str, ...]:
144    async def get_active_activations(self) -> dict[str, ...]:
145        response = await self.__send_request('getActiveActivations')
146        
147        if not is_json(response):
148            return response
149        
150        return json.loads(response)
async def getStatus( self, id: str) -> tuple[aiosmsactivate.types.ActivationStatus, str | None]:
152    async def get_activation_status_v1(self, id: str) -> tuple[ActivationStatus, str | None]:
153        response = await self.__send_request('getStatus', params={
154            'id': id
155        })
156
157        data = response.split(':')
158
159        match data[0]:
160            case 'STATUS_WAIT_CODE':
161                return ActivationStatus.WAIT, None
162            case 'STATUS_WAIT_RETRY':
163                return ActivationStatus.RETRY, data[1]
164            case 'STATUS_WAIT_RESEND':
165                return ActivationStatus.RESEND, None
166            case 'STATUS_CANCEL':
167                return ActivationStatus.CANCEL, None
168            case 'STATUS_OK':
169                return ActivationStatus.OK, data[1]
170            case _:
171                raise SmsActivateException('Invalid response sequence')
async def getStatusV2( self, id: str) -> tuple[aiosmsactivate.types.ActivationStatus, str | None] | dict:
173    async def get_activation_status(self, id: str) -> tuple[ActivationStatus, str | None] | dict:
174        response = await self.__send_request('getStatusV2', params={
175            'id': id
176        })
177
178        if not is_json(response):
179            return response
180        
181        return 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) -> dict | str:
183    async def purchase(self, service: str, forward: bool | None = None, maxPrice: float | None = None,
184                       phoneException: str | None = None, operator: str | None = None,
185                       activationType: int | str | None = None, language: str | None = None,
186                       userId: str | int | None = None,
187                       ref: str | None = None, country: str | None = None,
188                       useCashBack: bool | None = None,
189                       orderId: str | int | None = None,
190                       _is_v2: bool = True
191                       ) -> dict | str:
192        response = await self.__send_request('getNumber' if not _is_v2 else 'getNumberV2', params={
193            'service': service,
194            **({'forward': 1 if forward else 0} if forward is not None else {}),
195            **({'maxPrice': str(maxPrice)} if maxPrice is not None else {}),
196            **({'phoneException': phoneException} if phoneException is not None else {}),
197            **({'operator': operator} if operator is not None else {}),
198            **({'activationType': str(activationType)} if activationType is not None else {}),
199            **({'language': str(language)} if language is not None else {}),
200            **({'userId': str(userId)} if userId is not None else {}),
201            **({'orderId': str(orderId)} if orderId is not None and _is_v2 else {}),
202            **({'ref': ref} if ref is not None else {}),
203            **({'country ': country} if country is not None else {}),
204            **({'useCashBack': str(useCashBack).lower()} if useCashBack is not None else {}),
205        })
206
207        if not is_json(response):
208            return response
209        
210        return json.loads(response)
async def purchase_v1(self, *args, **kwargs):
212    async def get_number(self, *args, **kwargs):
213        kwargs["_is_v2"] = False
214        return await self.purchase(*args, **kwargs)
async def getNumber(self, *args, **kwargs):
212    async def get_number(self, *args, **kwargs):
213        kwargs["_is_v2"] = False
214        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:
216    async def get_multi_service_number(self, 
217                        multiService: str, multiForward: str | None = None,
218                        operator: str | None = None,
219                        ref: str | None = None, country: str | None = None,
220                       ) -> dict:
221        """
222        Get multiservice number.
223
224        :param multiService: service1,service2,service3 (Services separated by commas)
225        :param multiForward: 1,0,1 (forwards separated by commas, forwards count equal services count)
226        :return: dict object of response
227        """
228        response = await self.__send_request('getMultiServiceNumber', params={
229            'multiService': multiService,
230            **({'multiForward': multiForward} if multiForward is not None else {}),
231            **({'operator': operator} if operator is not None else {}),
232            **({'ref': ref} if ref is not None else {}),
233            **({'country ': country} if country is not None else {}),
234        })
235
236        if not is_json(response):
237            return response
238        
239        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, id: str, status: aiosmsactivate.types.SetActivationStatus, forward: str | None = None) -> aiosmsactivate.responses.SetActivationStatusResponse:
242    async def set_activation_status(self, id: str, status: SetActivationStatus,
243                                    forward: str | None = None) -> SetActivationStatusResponse:
244        members = {member.value: member for member in SetActivationStatusResponse}
245
246        response = await self.__send_request('setStatus', params={
247            'id': id,
248            'status': status.value,
249            **({'forward': forward} if forward is not None else {})
250        })
251
252        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:
254    async def get_history(self, 
255                          start: str | int = None,
256                          end: str | int = None,
257                          offset: str | int = None,
258                          limit: str | int = None,
259                       ) -> dict | list:
260        response = await self.__send_request('getHistory', params={
261            **({'start': str(start)} if start is not None else {}),
262            **({'end': str(end)} if end is not None else {}),
263            **({'offset': str(offset)} if offset is not None else {}),
264            **({'limit': str(limit)} if limit is not None else {}),
265        })
266
267        if not is_json(response):
268            return response
269        
270        return json.loads(response)
async def getListOfTopCountriesByService(self, service: str) -> dict | list:
272    async def get_list_top_countries(self, 
273                          service: str,
274                       ) -> dict | list:
275        response = await self.__send_request('getListOfTopCountriesByService', params={
276            'service': service
277        })
278
279        if not is_json(response):
280            return response
281        
282        return json.loads(response)
async def getIncomingCallStatus(self, id: str | int = None) -> dict | list:
284    async def get_incoming_call_status(self, 
285                          id: str | int = None,
286                       ) -> dict | list:
287        response = await self.__send_request('getIncomingCallStatus', params={
288            'activationId': id
289        })
290
291        if not is_json(response):
292            return response
293        
294        return json.loads(response)
async def getPrices(self, service: str = None, country: str = None) -> dict | list:
296    async def get_prices(self, 
297                          service: str = None,
298                          country: str = None,
299                       ) -> dict | list:
300        response = await self.__send_request('getPrices', params={
301            **({'service': str(service)} if service is not None else {}),
302            **({'country': str(country)} if country is not None else {}),
303        })
304
305        if not is_json(response):
306            return response
307        
308        return json.loads(response)
async def getPricesVerification(self, service: str = None) -> dict | list:
310    async def get_prices_verification(self, 
311                          service: str = None,
312                       ) -> dict | list:
313        response = await self.__send_request('getPricesVerification', params={
314            **({'service': str(service)} if service is not None else {}),
315        })
316
317        if not is_json(response):
318            return response
319        
320        return json.loads(response)
async def getCountries(self) -> dict | list:
322    async def get_countries(self,
323                       ) -> dict | list:
324        response = await self.__send_request('getCountries', params={
325        })
326
327        if not is_json(response):
328            return response
329        
330        return json.loads(response)
async def getServicesList( self, country: str = None, lang: Literal['ru', 'en', 'es', 'cn'] = None) -> dict | list:
332    async def get_service_list(self, 
333                          country: str = None,
334                          lang: Literal['ru', 'en', 'es', 'cn'] = None,
335                       ) -> dict | list:
336        response = await self.__send_request('getServicesList', params={
337            **({'country': str(country)} if country is not None else {}),
338            **({'lang': str(lang)} if lang is not None else {}),
339        })
340
341        if not is_json(response):
342            return response
343        
344        return json.loads(response)
async def getAdditionalService(self, service: str = None, id: str = None):
346    async def get_additional_service(self, 
347                          service: str = None,
348                          id: str = None,
349                       ):
350        """
351        Get additional service to activation its cost 5rub
352        return 2 values: addition activation id and phone number
353        
354        use like this: 
355        activation_id, phone_number = await getAdditionalService(service, activation id)
356        """
357        response = await self.__send_request('getAdditionalService', params={
358            'service': service,
359            'id':id
360        })
361
362        data = response.split(':')
363        if len(data) > 2:
364            return data[1], data[2]
365        
366        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):
368    async def get_extra_activation(self, 
369                          id: str = None,
370                       ):
371        """
372        return 2 values: addition activation id and phone number
373        
374        use like this: 
375        activation_id, phone_number = await getExtraActivation(activation id)
376        """
377        response = await self.__send_request('getExtraActivation', params={
378            'id':id
379        })
380
381        data = response.split(':')
382        if len(data) > 2:
383            return data[1], data[2]
384        
385        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:
387    async def check_extra_activation(self, 
388                          activationId: str | int
389                       ) -> dict | list:
390        response = await self.__send_request('checkExtraActivation', params={
391            'activationId': str(activationId)
392        })
393
394        if not is_json(response):
395            return response
396        
397        return json.loads(response)
async def parseCall(self, id: str | int, newLang: str) -> dict | list:
399    async def parse_call(self, 
400                          id: str | int,
401                          newLang: str,
402                       ) -> dict | list:
403        response = await self.__send_request('parseCall', params={
404            "id": id,
405            "newLang": newLang,
406        })
407
408        if not is_json(response):
409            return response
410        
411        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:
414    async def get_rent_services_and_countries(self,
415                       time: int | str | None = None,
416                       operator: str | None = None,
417                       country: str | None = None,
418                       currency: str | None = None,
419                       incomingCall: bool | None = None,
420                       ) -> dict | str:
421        response = await self.__send_request('getRentServicesAndCountries', params={
422            **({'time ': str(time )} if time is not None else {}),
423            **({'operator ': str(operator )} if operator is not None else {}),
424            **({'country ': str(country )} if country is not None else {}),
425            **({'currency ': str(currency )} if currency is not None else {}),
426            **({'incomingCall': str(incomingCall).lower()} if incomingCall is not None else {}),
427        })
428
429        if not is_json(response):
430            return response
431        
432        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:
434    async def get_rent_number(self,
435                        service: str,
436                        time: int | str | None = None,
437                        operator: str | None = None,
438                        country: str | None = None,
439                        url: str | None = None,
440                        incomingCall: bool | None = None,
441                       ) -> dict | str:
442        response = await self.__send_request('getRentNumber', params={
443            'service': service,
444            **({'time ': str(time )} if time is not None else {}),
445            **({'operator ': str(operator )} if operator is not None else {}),
446            **({'country ': str(country )} if country is not None else {}),
447            **({'url ': str(url )} if url is not None else {}),
448            **({'incomingCall': str(incomingCall).lower()} if incomingCall is not None else {}),
449        })
450
451        if not is_json(response):
452            return response
453        
454        return json.loads(response)
async def getRentStatus( self, id: str, page: int | str | None = None, size: int | str | None = None) -> dict | str:
456    async def get_rent_status(self,
457                        id: str,
458                        page: int | str | None = None,
459                        size: int | str | None = None,
460                       ) -> dict | str:
461        response = await self.__send_request('getRentStatus', params={
462            'id': id,
463            **({'page ': str(page)} if page is not None else {}),
464            **({'size ': str(size )} if size is not None else {}),
465        })
466
467        if not is_json(response):
468            return response
469        
470        return json.loads(response)
async def getRentList(self) -> dict | str:
486    async def get_rent_list(self,
487                       ) -> dict | str:
488        response = await self.__send_request('getRentList', params={
489        })
490
491        if not is_json(response):
492            return response
493        
494        return json.loads(response)
async def continueRentNumber(self, id: str, rent_time: int | str | None = 4) -> dict | str:
496    async def continue_rent_number(self,
497                        id: str,
498                        rent_time: int | str | None = 4,
499                       ) -> dict | str:
500        response = await self.__send_request('continueRentNumber', params={
501            'id': id,
502            'rent_time': str(rent_time)
503        })
504
505        if not is_json(response):
506            return response
507        
508        return json.loads(response)
async def getContinueRentPriceNumber( self, id: str, rent_time: int | str | None = 4, currency: str | None = None) -> dict | str:
510    async def get_continue_rent_price_number(self,
511                        id: str,
512                        rent_time: int | str | None = 4,
513                        currency: str | None = None
514                       ) -> dict | str:
515        response = await self.__send_request('getContinueRentPriceNumber', params={
516            'id': id,
517            'rent_time': str(rent_time),
518            **({'currency ': str(currency )} if currency is not None else {}),
519        })
520
521        if not is_json(response):
522            return response
523        
524        return json.loads(response)
async def buyPartnerProduct(self, id: str) -> dict | str:
527    async def buy_partner_product(self,
528                        id: str,
529                       ) -> dict | str:
530        response = await self.__send_request('buyPartnerProduct', params={
531            'id': id,
532        })
533
534        if not is_json(response):
535            return response
536        
537        return json.loads(response)