Skip to main content

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.

Metadata

Release files for huvr-client 0.3.7

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for huvr-client 0.3.7
File Size Uploaded
huvr_client-0.3.7.tar.gz 18.1 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for huvr-client 0.3.7
File Interpreter ABI Platform
huvr_client-0.3.7-py3-none-any.whl Python 3 none any Details

Total release size: 54.8 kB

Release files / huvr_client-0.3.7.tar.gz

Download URL huvr_client-0.3.7.tar.gz
Size 18.1 kB
Tags Source
SHA-256 checksum
How to use checksums
2d092caf68329c01a7d49049ec52293b3a180230df39ab4e390e68f8d48c2084
BLAKE2b-256 checksum
How to use checksums
ae673b73abe8d2f8be9aa0e579563cecd73a5f37eac4f65a5c589ad003d084a9
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/5.1.0 CPython/3.12.4

Release files / huvr_client-0.3.7-py3-none-any.whl

Download URL huvr_client-0.3.7-py3-none-any.whl
Size 36.7 kB
Tags Python 3
SHA-256 checksum
How to use checksums
e2568cc528fe71d2456c657d1fd2e372bcdef5c2d3d0dc9056803aebc12446cd
BLAKE2b-256 checksum
How to use checksums
22ee9d3b3dff44f26a37d3a7cac1b8320278e78549de0800a1ef99269c92c5ec
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/5.1.0 CPython/3.12.4

Release history Release notifications | RSS feed

This release

0.3.7 This release

2 release files

0.3.6

2 release files

0.3.5

2 release files

0.3.3

2 release files

0.2.9

2 release files

0.2.8

2 release files

0.2.7

2 release files

0.2.6

2 release files

0.2.5

2 release files

0.2.4

2 release files

0.2.2

2 release files

0.2.1

2 release files

0.2.0

2 release files

0.1.0

2 release files

0.0.0

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page