# 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/
```bash
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.
```py
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.
```py
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](https://docs.huvrdata.app)_
```py
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](https://docs.huvrdata.app)_
```py
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
```py
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:
```bash
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.
```bash
make test
```
can also open a shell in the test container
```bash
make ipython
```
then:
```py
client = get_huvr_client(...)
```
### Publish
Generate a Release on GitHub. This will trigger a GitHub Action to publish the package to PyPi.
Raw data
{
"_id": null,
"home_page": "https://github.com/huvrdata/huvr-client",
"name": "huvr-client",
"maintainer": null,
"docs_url": null,
"requires_python": ">=3.6",
"maintainer_email": null,
"keywords": "huvr_client",
"author": "HUVRdata",
"author_email": "api@huvrdata.com",
"download_url": "https://files.pythonhosted.org/packages/ae/67/3b73abe8d2f8be9aa0e579563cecd73a5f37eac4f65a5c589ad003d084a9/huvr_client-0.3.7.tar.gz",
"platform": null,
"description": "# HUVR Client\n\nA Python client (with examples) to connect to HUVRdata.\n\nYou must be an active customer of HUVRdata.com for this library to be useful.\n\nThe client is a thin wrapper around the Python `requests` library. It is provided as\na convenience to help customers access their data.\n\nSee the https://docs.huvrdata.app for detailed specs on specific API endpoints. Along with guides for most common use cases.\n\n## Usage\n\n### Installation\n\nUse pip to install the client. See pip/python installation best practices: https://docs.python-guide.org/starting/installation/\n\n```bash\npip install huvr-client\n```\n\n### Client Initialization\n\nYou will need a service account in the HUVRdata platform to use this client. Please contact your HUVRdata representative to get your credentials.\n\n```py\nfrom huvr_client import get_huvr_client\n\n# Create a client with your credentials\nclient = get_huvr_client(\n base_url=\"https://demo.huvrdata.app\",\n client_id=\"my-company.service-account@demo.huvrdata.app\",\n client_secret=\"my-secret\"\n)\n```\n\n#### Authentication\n\nThe client will be authenticated for 1 hour. After that, you will need to re-authenticate.\n\n```py\nclient.authenticate(\n client_id=\"my-company.service-account@demo.huvrdata.app\",\n client_secret=\"my-secret\"\n)\n```\n\n### Fetch Data Example\n\npass `params` to specify filters\n\n_for full list of available filters - see [API docs](https://docs.huvrdata.app)_\n\n```py\npagination_data = client.projects.list(params={\n \"asset_search\": \"my-site/my-asset\"\n})\n\n# some responses will contain pagination info {next, previous, count, results}\nprojects = pagination_data[\"results\"]\n\n# result data will be raw python dicts/lists etc\nfor project in projects:\n print(project[\"name\"])\n```\n\n### Post Data Example\n\npass `json` to request when creating/updating data\n\n_for full list of expected json data - see [API docs](https://docs.huvrdata.app)_\n\n```py\nproject = client.projects.create(json={\n \"name\": \"My Project\",\n \"asset\": 24, # asset id\n \"type\": 36, # project type id\n})\n\n# result data will be raw python dicts/lists etc\nprint(project[\"id\"])\n```\n\n### Raw Request Example\n\nif requesting a non-json or \"internal\" endpoint, can make a raw request.\n\nthis will return a standard python `requests.Response` object\n\n```py\nresponse = client.request(\n method=\"GET\",\n path=\"/api/.../\",\n # params={...},\n # json={...},\n # headers={...},\n # data={...},\n)\nresponse.content # access raw bytes, or .json(), etc\n```\n\n## Contributing / Internals\n\nDocker Required: https://www.docker.com\n\n### Run Codegen\n\nAll API endpoints are generated from the OpenAPI spec.\n\nTo regenerate the client code, first, obtain a link to the latest OpenAPI spec at https://docs.huvrdata.app/openapi/. Then run the following command:\n\n```bash\nmake generate_client open_api_url=\"https://docs.huvrdata.app/openapi/<version>\"\n```\n\nIf a new _module_ is added to the spec, you will need to add it to the `huvr_client/client.py` file.\n\n### Test\n\ncreate a `tests/.env.yaml` file based on the `tests/.example.env.yaml` file.\n\n```bash\nmake test\n```\n\ncan also open a shell in the test container\n\n```bash\nmake ipython\n```\n\nthen:\n\n```py\nclient = get_huvr_client(...)\n```\n\n### Publish\n\nGenerate a Release on GitHub. This will trigger a GitHub Action to publish the package to PyPi.\n",
"bugtrack_url": null,
"license": null,
"summary": "A python client for the HUVRdata API.",
"version": "0.3.7",
"project_urls": {
"Homepage": "https://github.com/huvrdata/huvr-client"
},
"split_keywords": [
"huvr_client"
],
"urls": [
{
"comment_text": "",
"digests": {
"blake2b_256": "22ee9d3b3dff44f26a37d3a7cac1b8320278e78549de0800a1ef99269c92c5ec",
"md5": "445eaf5bd040df6198ac915263de99ce",
"sha256": "e2568cc528fe71d2456c657d1fd2e372bcdef5c2d3d0dc9056803aebc12446cd"
},
"downloads": -1,
"filename": "huvr_client-0.3.7-py3-none-any.whl",
"has_sig": false,
"md5_digest": "445eaf5bd040df6198ac915263de99ce",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": ">=3.6",
"size": 36663,
"upload_time": "2024-07-02T16:57:47",
"upload_time_iso_8601": "2024-07-02T16:57:47.702241Z",
"url": "https://files.pythonhosted.org/packages/22/ee/9d3b3dff44f26a37d3a7cac1b8320278e78549de0800a1ef99269c92c5ec/huvr_client-0.3.7-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"blake2b_256": "ae673b73abe8d2f8be9aa0e579563cecd73a5f37eac4f65a5c589ad003d084a9",
"md5": "b90d7d2460691f41d9802bea79dddf3f",
"sha256": "2d092caf68329c01a7d49049ec52293b3a180230df39ab4e390e68f8d48c2084"
},
"downloads": -1,
"filename": "huvr_client-0.3.7.tar.gz",
"has_sig": false,
"md5_digest": "b90d7d2460691f41d9802bea79dddf3f",
"packagetype": "sdist",
"python_version": "source",
"requires_python": ">=3.6",
"size": 18142,
"upload_time": "2024-07-02T16:57:48",
"upload_time_iso_8601": "2024-07-02T16:57:48.956165Z",
"url": "https://files.pythonhosted.org/packages/ae/67/3b73abe8d2f8be9aa0e579563cecd73a5f37eac4f65a5c589ad003d084a9/huvr_client-0.3.7.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2024-07-02 16:57:48",
"github": true,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"github_user": "huvrdata",
"github_project": "huvr-client",
"travis_ci": false,
"coveralls": false,
"github_actions": true,
"requirements": [
{
"name": "requests",
"specs": []
}
],
"lcname": "huvr-client"
}