Skip to content

About

Python Wrapper for automatic reception of SMS-messages by onlinesim.ru

Topics

Resources

Stars

30 stars

Watchers

3 watching

Forks

Latest commit

 

History

67 Commits

Folders and files

Repository files navigation

onlinesim-python-api

PyPI CI

Typed Python client for the OnlineSim API: SMS numbers, rent, account and free numbers. Zero runtime dependencies (standard library urllib), Python 3.9+, type hints (py.typed).

pip install onlinesimru
import os

from onlinesimru import OnlineSim

client = OnlineSim(os.environ["ONLINESIM_KEY"])

b = client.user.balance()
print(f"available: {b['balance'] - max(b['zbalance'], 0)} USD")

order = client.numbers.get_with_number("google", 44)
print(f"enter {order['number']} in the app")
print("code:", client.numbers.wait_code(order["tzid"]))

Testing

MockOnlineSim is a built-in offline fake of the API: test your integration without network, key or money. More in the testing guide.

from onlinesimru import MockOnlineSim

mock = MockOnlineSim(balance=10)
client = mock.client()

tzid = client.numbers.get("google", 44)
mock.add_sms_after(tzid, "Your code: 123-456", 2)  # arrives on the third poll
assert client.numbers.wait_code(tzid, interval=0) == "123456"
assert mock.balance() == 9.8

Documentation: https://s00d.github.io/onlinesim-python-api/ · Changes: CHANGELOG.md · License: Apache-2.0

About

Python Wrapper for automatic reception of SMS-messages by onlinesim.ru

Topics

Resources

Stars

30 stars

Watchers

3 watching

Forks

Releases

Packages

Contributors

Languages