Skip to main content

A package to utilize the tukan API.

Project description

tukan_python

A Python package to interact with the TukanMX API, retrieve table metadata, and build and execute queries with flexible filters, groupings, and aggregations.

Installation

Once the package is published to PyPI, install it using:

pip install tukan_python

Usage

Authentication

You need an API token to use the TukanMX API. You can provide it directly to the Tukan or Query classes, or set it as an environment variable:

export API_TUKAN=your_api_token

Main Classes

Tukan

Handles authentication and requests to the TukanMX API. Provides methods for retrieving tables, indicators, and metadata, as well as sending and receiving data.

from tukan_python.tukan import Tukan

tukan = Tukan(token="your_api_token")

# Retrieve metadata for a table
metadata = tukan.get_table_metadata("table_name")

# Retrieve a list of tables
all_tables = tukan.get_tables()

# Retrieve a list of indicators
indicators = tukan.get_indicators()

Query

Helper class for building and executing queries against the TukanMX API. Supports filters, groupings, aggregations, and execution.

from tukan_python.query import Query

# Create a Query instance
query = Query("table_name", token="your_api_token")

# Add filters, groupings, or aggregations as needed
query.set_where([{ "reference": "column", "eq": "value" }])
query.set_group_by([{ "reference": "column" }])
query.set_aggregate([{ "indicator": "indicator_name", "operation": "sum" }])

# Execute the query
result = query.execute_query()
print(result["df"])  # result is a dict with 'indicators' and a pandas DataFrame

Utility Functions

  • create_identity_query_for_table(table_name, language)
  • create_identity_query_for_table_with_date_filters(table_name, language, from_date, to_date)
  • create_query_from_query_id_or_name(query_id_or_name)
  • create_query_from_payload(payload)

These functions help build queries quickly from table names, IDs, or payloads.

License

See the LICENSE file for license information.


For more details, see the code in tukan_python/tukan.py and tukan_python/query.py.

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

tukan_python-0.1.0.tar.gz (12.1 kB view details)

Uploaded Source

Built Distribution

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

tukan_python-0.1.0-py3-none-any.whl (12.0 kB view details)

Uploaded Python 3

File details

Details for the file tukan_python-0.1.0.tar.gz.

File metadata

  • Download URL: tukan_python-0.1.0.tar.gz
  • Upload date:
  • Size: 12.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.12.4

File hashes

Hashes for tukan_python-0.1.0.tar.gz
Algorithm Hash digest
SHA256 9cd20d2c67be5daa76b661e6e16894e12a0b44e65f2bcb9e71959639be50c0a1
MD5 e0124a2e8b8dbd5e4cda4ac05e27f37a
BLAKE2b-256 47b67d9cc1cfe61e31cad5a26049cf4e9e342f1fc840ffbb9d94d83e3659b702

See more details on using hashes here.

File details

Details for the file tukan_python-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: tukan_python-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 12.0 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.12.4

File hashes

Hashes for tukan_python-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 7ddc5a956b156d4f704b1144e9c38d03f5fb2ca94c5cadf430d3e0d9827e4e49
MD5 fc1cfc16543b13bd3d03e5ec39a51d27
BLAKE2b-256 1309e0a64debbc04f806af6aa6d5ff8a57e5ee1d60b5e486798965fabcfafa84

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