Skip to main content

A python client for the HUVRdata API.

Project description

HUVR Client

A Python client (with examples) to connect to HUVRdata.

You must be an active customer of HUVRdata.com for this library to be useful.

The client is a thin wrapper around the Python requests library. It is provided as a convenience to help customers access their data.

See the https://docs.huvrdata.app for detailed specs on specific API endpoints. Along with guides for most common use cases.

Usage

Installation

Use pip to install the client. See pip/python installation best practices: https://docs.python-guide.org/starting/installation/

pip install huvr-client

Client Initialization

You will need a service account in the HUVRdata platform to use this client. Please contact your HUVRdata representative to get your credentials.

from huvr_client import get_huvr_client

# Create a client with your credentials
client = get_huvr_client(
    base_url="https://demo.huvrdata.app",
    client_id="my-company.service-account@demo.huvrdata.app",
    client_secret="my-secret"
)

Authentication

The client will be authenticated for 1 hour. After that, you will need to re-authenticate.

client.authenticate(
    client_id="my-company.service-account@demo.huvrdata.app",
    client_secret="my-secret"
)

Fetch Data Example

pass params to specify filters

for full list of available filters - see API docs

pagination_data = client.projects.list(params={
    "asset_search": "my-site/my-asset"
})

# some responses will contain pagination info {next, previous, count, results}
projects = pagination_data["results"]

# result data will be raw python dicts/lists etc
for project in projects:
    print(project["name"])

Post Data Example

pass json to request when creating/updating data

for full list of expected json data - see API docs

project = client.projects.create(json={
    "name": "My Project",
    "asset": 24,  # asset id
    "type": 36,  # project type id
})

# result data will be raw python dicts/lists etc
print(project["id"])

Raw Request Example

if requesting a non-json or "internal" endpoint, can make a raw request.

this will return a standard python requests.Response object

response = client.request(
    method="GET",
    path="/api/.../",
    # params={...},
    # json={...},
    # headers={...},
    # data={...},
)
response.content  # access raw bytes, or .json(), etc

Contributing / Internals

Docker Required: https://www.docker.com

Run Codegen

All API endpoints are generated from the OpenAPI spec.

To regenerate the client code, first, obtain a link to the latest OpenAPI spec at https://docs.huvrdata.app/openapi/. Then run the following command:

make generate_client open_api_url="https://docs.huvrdata.app/openapi/<version>"

If a new module is added to the spec, you will need to add it to the huvr_client/client.py file.

Test

create a tests/.env.yaml file based on the tests/.example.env.yaml file.

make test

can also open a shell in the test container

make ipython

then:

client = get_huvr_client(...)

Publish

Generate a Release on GitHub. This will trigger a GitHub Action to publish the package to PyPi.

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

huvr_client-0.3.7.tar.gz (18.1 kB view details)

Uploaded Source

Built Distribution

huvr_client-0.3.7-py3-none-any.whl (36.7 kB view details)

Uploaded Python 3

File details

Details for the file huvr_client-0.3.7.tar.gz.

File metadata

  • Download URL: huvr_client-0.3.7.tar.gz
  • Upload date:
  • Size: 18.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/5.1.0 CPython/3.12.4

File hashes

Hashes for huvr_client-0.3.7.tar.gz
Algorithm Hash digest
SHA256 2d092caf68329c01a7d49049ec52293b3a180230df39ab4e390e68f8d48c2084
MD5 b90d7d2460691f41d9802bea79dddf3f
BLAKE2b-256 ae673b73abe8d2f8be9aa0e579563cecd73a5f37eac4f65a5c589ad003d084a9

See more details on using hashes here.

File details

Details for the file huvr_client-0.3.7-py3-none-any.whl.

File metadata

  • Download URL: huvr_client-0.3.7-py3-none-any.whl
  • Upload date:
  • Size: 36.7 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/5.1.0 CPython/3.12.4

File hashes

Hashes for huvr_client-0.3.7-py3-none-any.whl
Algorithm Hash digest
SHA256 e2568cc528fe71d2456c657d1fd2e372bcdef5c2d3d0dc9056803aebc12446cd
MD5 445eaf5bd040df6198ac915263de99ce
BLAKE2b-256 22ee9d3b3dff44f26a37d3a7cac1b8320278e78549de0800a1ef99269c92c5ec

See more details on using hashes here.

Supported by

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