Skip to main content

Teltonika Device API Client

Project description

Ponika

Ponika is a Python library for interacting with the Teltonika devices.

Installation

You can install Ponika using pip:

pip install ponika

Usage

To use Ponika, you need to create an instance of PonikaClient with the appropriate parameters. Here's a basic example:

from ponika import PonikaClient

client = PonikaClient(
    host="192.168.1.1",
    username="your_username",
    password="your_password",
    # port=80,       # Optional, default is 443 if tls=True else 80
    # tls=False,     # Optional, default is True
    # verify_tls=False,  # Optional, default is True
)

The library follows the structure of the Teltonika API endpoints. For example, to get the internet status from the endpoint /api/v1/internet_connection/status, you can do the following:

response = client.internet_connection.get_status()

if response.success and response.data:
    print("Internet Status:")
    print("IPv4:", response.data.ipv4_status)
    print("IPv6:", response.data.ipv6_status)
    print("DNS: ", response.data.dns_status)
else:
    print("Error:", response.errors)

[!NOTE] Not all endpoints are implemented. If you need a specific endpoint that's missing, the existing endpoints should be a good reference for how to implement new ones.

Examples

Get Internet Status

response = client.internet_connection.get_status()

if response.success and response.data:
    print("Internet Status:")
    print("IPv4:", response.data.ipv4_status)
    print("IPv6:", response.data.ipv6_status)
    print("DNS: ", response.data.dns_status)
else:
    print("Error:", response.errors)

Get GPS Position

response = client.gps.position.get_status()

if response.success and response.data:
    print("GPS Position:")
    print("Latitude:", response.data.latitude)
    print("Longitude:", response.data.longitude)
    print("Altitude:", response.data.altitude)
else:
    print("Error:", response.errors)

Contributing

If you want to contribute to Ponika, feel free to open a pull request on the GitHub repository. Contributions are welcome!

The project is setup to use uv for development and requires prior installation. Once you've cloned the repository, you can set up the development environment by running:

uv sync

To run the tests, you can use the following command, updating the environment variables as needed:

# Required variables
# ---------------------
export TELTONIKA_HOST=192.168.1.1
export TELTONIKA_USERNAME=admin
export TELTONIKA_PASSWORD=password

# Optional variables
# ---------------------
# Enables SMS sending tests
export MOBILE_NUMBER=441234567890

# Run the tests
uv run pytest

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

ponika-0.2.0.tar.gz (15.5 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

ponika-0.2.0-py3-none-any.whl (10.5 kB view details)

Uploaded Python 3

File details

Details for the file ponika-0.2.0.tar.gz.

File metadata

  • Download URL: ponika-0.2.0.tar.gz
  • Upload date:
  • Size: 15.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.7.11

File hashes

Hashes for ponika-0.2.0.tar.gz
Algorithm Hash digest
SHA256 d810f4dff5e24c17c10491389c8c7d72c93c56d9829c8c23f55e67c7f3365e0a
MD5 0d581877e3b11891eef6028de49540d3
BLAKE2b-256 163beba7a1503478fb86894d6a311231dacc253b483d30729cb44d523c1daf6f

See more details on using hashes here.

File details

Details for the file ponika-0.2.0-py3-none-any.whl.

File metadata

  • Download URL: ponika-0.2.0-py3-none-any.whl
  • Upload date:
  • Size: 10.5 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.7.11

File hashes

Hashes for ponika-0.2.0-py3-none-any.whl
Algorithm Hash digest
SHA256 4d6d5d9128363cc64deeba558680849dc8fee2c40bc18c114c5333f5ea60ad07
MD5 c5f52003c19bd553663d6c32deab1734
BLAKE2b-256 127c6148d33bc5e9c1dbc63e99e7813e8138658479dbe99956b80dc4f865352c

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page