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 onlinesimruimport 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"]))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.8Documentation: https://s00d.github.io/onlinesim-python-api/ · Changes: CHANGELOG.md · License: Apache-2.0