{"id":28214959,"url":"https://github.com/hakaiinstitute/hakai-api-client-py","last_synced_at":"2025-10-11T23:42:48.657Z","repository":{"id":53190411,"uuid":"95804516","full_name":"HakaiInstitute/hakai-api-client-py","owner":"HakaiInstitute","description":"Make authenticated requests for data to the Hakai API with Python","archived":false,"fork":false,"pushed_at":"2025-09-12T18:49:56.000Z","size":185,"stargazers_count":4,"open_issues_count":2,"forks_count":0,"subscribers_count":8,"default_branch":"main","last_synced_at":"2025-09-12T21:07:36.094Z","etag":null,"topics":["api","api-client","api-wrapper","eims","python","python-library"],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/HakaiInstitute.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":"CODEOWNERS","security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2017-06-29T17:52:40.000Z","updated_at":"2025-09-12T18:49:59.000Z","dependencies_parsed_at":"2025-06-12T01:35:15.889Z","dependency_job_id":"ad59d011-e76d-4968-b180-d94fbd8d8ee9","html_url":"https://github.com/HakaiInstitute/hakai-api-client-py","commit_stats":null,"previous_names":[],"tags_count":11,"template":false,"template_full_name":null,"purl":"pkg:github/HakaiInstitute/hakai-api-client-py","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/HakaiInstitute%2Fhakai-api-client-py","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/HakaiInstitute%2Fhakai-api-client-py/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/HakaiInstitute%2Fhakai-api-client-py/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/HakaiInstitute%2Fhakai-api-client-py/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/HakaiInstitute","download_url":"https://codeload.github.com/HakaiInstitute/hakai-api-client-py/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/HakaiInstitute%2Fhakai-api-client-py/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":279009404,"owners_count":26084580,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-10-11T02:00:06.511Z","response_time":55,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["api","api-client","api-wrapper","eims","python","python-library"],"created_at":"2025-05-17T21:08:48.142Z","updated_at":"2025-10-11T23:42:48.650Z","avatar_url":"https://github.com/HakaiInstitute.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Hakai Api Python Client\n\nThis project exports a single Python class that can be used to make HTTP requests to the\nHakai API resource server.\nThe exported `Client` class extends the functionality of the\nPython [requests library](https://docs.python-requests.org/en/master/) to supply Hakai\nOAuth2 credentials with url requests.\n\n![PyPI](https://img.shields.io/pypi/v/hakai-api)   [![tests](https://github.com/HakaiInstitute/hakai-api-client-py/actions/workflows/test.yaml/badge.svg)](https://github.com/HakaiInstitute/hakai-api-client-py/actions/workflows/test.yaml)  [![License: MIT](https://img.shields.io/badge/License-MIT-black.svg)](https://opensource.org/licenses/MIT)\n\n\u003cdetails\u003e\n\n\u003csummary\u003eTable of Contents\u003c/summary\u003e\n\n[Installation](#installation)\n\n[Quickstart](#quickstart)\n- [Desktop OAuth Flow](#desktop-oauth-flow)\n- [User Agent Configuration](#user-agent-configuration)\n\n[Methods](#methods)\n\n[API endpoints](#api-endpoints)\n\n[Advanced usage](#advanced-usage)\n- [Custom API Endpoints](#custom-api-endpoints)\n- [Relative Endpoint Support](#relative-endpoint-support)\n- [Credentials Configuration](#credentials-configuration)\n\n[Contributing](#contributing)\n\n\u003c/details\u003e\n\n# Installation\n\nPython 3.8 or higher is required. Install with pip:\n\n```bash\npip install hakai-api\n```\n\n# Quickstart\n\n```python\nfrom hakai_api import Client\n\n# Get the api request client\nclient = Client()  # Follow stdout prompts to get an API token\n\n# Make a data request for chlorophyll data (using relative endpoint)\nresponse = client.get('/eims/views/output/chlorophyll?limit=50')\n\nprint(response.json())\n# [{'action': '', 'event_pk': 7064, 'rn': '1', 'date': '2012-05-17', 'work_area': 'CALVERT'...\n```\n\n## Desktop OAuth Flow\n\nFor native applications and automated scripts, use the desktop OAuth flow with PKCE:\n\n```python\nfrom hakai_api import Client\n\n# Use desktop OAuth flow (opens browser, more secure)\nclient = Client(auth_flow=\"desktop\")\n\n# Or use the factory method\nclient = Client.create_desktop_client()\n\n# Make requests using relative endpoints\nresponse = client.get('/eims/views/output/stations')\nprint(response.json())\n```\n\n## User Agent Configuration\n\n**Important**: Set a descriptive user agent to help identify your application on the backend. Often the repository url is a good way to identify yourself:\n\n```python\nfrom hakai_api import Client\nimport os\n\n# Set user agent during initialization\nclient = Client(user_agent=\"MyApp/1.0 (contact@example.com)\")\n\n# Or set via environment variable\nos.environ['HAKAI_API_USER_AGENT'] = \"MyApp/1.0 (contact@example.com)\"\nclient = Client()\n```\n\n# Methods\n\nThis library exports a single client name `Client`. Instantiating this class produces\na `requests.Session` client from the Python requests library. The Hakai API Python\nClient inherits directly from `requests.Session` thus all methods available on that\nparent class are available. For details see\nthe [requests documentation](http://docs.python-requests.org/).\n\nThe hakai_api `Client` class also contains a property `api_root` which is useful for\nconstructing urls to access data from the API. The\nabove [Quickstart example](#quickstart) demonstrates using this property to construct a\nurl to access project names.\n\n# API endpoints\n\nFor details about the API, including available endpoints where data can be requested\nfrom, see the [Hakai API documentation](https://github.com/HakaiInstitute/hakai-api).\n\n# Advanced usage\n\n## Custom API Endpoints\n\nYou can specify which API to access when instantiating the Client. By default, the API\nuses `https://hecate.hakai.org/api` as the API root. It may be useful to use this\nlibrary to access a locally running API instance or to access the Goose API for testing\npurposes. If you are always going to be accessing data from a locally running API\ninstance, you are better off using the requests.py library directly since Authorization\nis not required for local requests.\n\n```python\nfrom hakai_api import Client\n\n# Get a client for a locally running API instance\nclient = Client(\"http://localhost:8666\")\nprint(client.api_root)  # http://localhost:8666\n```\n\n## Relative Endpoint Support\n\nThe client supports relative endpoints that automatically prepend the API root:\n\n```python\nfrom hakai_api import Client\n\nclient = Client()\n\n# These are equivalent:\nresponse1 = client.get('/eims/views/output/stations')\nresponse2 = client.get('https://hecate.hakai.org/api/eims/views/output/stations')\n```\n\n## Credentials Configuration\n\n### Direct Credentials\n\nYou can pass in the credentials string retrieved from the hakai API login page\nwhile initiating the Client class.\n\n```python\nfrom hakai_api import Client\n\n# Pass a credentials token as the Client Class is initiated\nclient = Client(credentials=\"CREDENTIAL_TOKEN\")\n```\n\n### Environment Variables\n\nSet credentials using the `HAKAI_API_CREDENTIALS` environment variable. This is useful\nfor e.g. setting credentials in a docker container. The value of the environment variable\nshould be the credentials token retrieved from the Hakai API login page.\n\n```bash\nexport HAKAI_API_CREDENTIALS=\"your_credential_token_here\"\n```\n\n### Custom Credentials File Location\n\nBy default, credentials are saved to `~/.hakai-api-auth`. You can customize this location:\n\n```python\nfrom hakai_api import Client\n\n# Set custom credentials file path\nclient = Client(credentials_file=\"/path/to/my/credentials\")\n\n# Or use environment variable\n# export HAKAI_API_CREDENTIALS=\"/path/to/my/credentials\"\nclient = Client()\n```\n\n# Contributing\n\nSee [CONTRIBUTING](CONTRIBUTING.md)\n\n# License\n\nSee [LICENSE](LICENSE.md)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhakaiinstitute%2Fhakai-api-client-py","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fhakaiinstitute%2Fhakai-api-client-py","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhakaiinstitute%2Fhakai-api-client-py/lists"}