A Python API client for ORCATECH
Project description
ORCATECH Python API Client
A Python-based API client for interacting with the ORCATECH server API.
Overview
This library provides a programmatic interface to make HTTP requests to the ORCATECH API using specific endpoints and request methods. It includes support for authentication, data retrieval, and AWS integration capabilities.
Installation
pip install orcatech_client
Or install from source:
git clone <repository-url>
cd python
pip install -e .
Features
- API Client: Full-featured HTTP client for ORCATECH API endpoints
- Authentication: Bearer token authentication support
- Type Safety: Comprehensive schema types for observations, records, and data structures
- AWS Integration: Certificate management for AWS services
- Configuration: Environment-based configuration using
.envfiles
Quick Start
from orcatech_python_api_client.client import APIClient
from orcatech_python_api_client.config import Config, Scope
# Initialize configuration
Config.validate()
host = Config.HOST_URL
token = Config.AUTH_TOKEN
# Create client
client = APIClient(host)
client.headers["Authorization"] = f"Bearer {token}"
# Make API requests
scope = Scope["STUDY"]
scope_id = 2
data_schema = "com.orcatech.measure.access.period"
observation_uuid = "your-observation-uuid"
result = client.get_observation(
host,
scope,
scope_id,
data_schema,
observation_uuid
)
Configuration
Create a .env file in your project root:
HOST_URL=https://your-api-host.com
AUTH_TOKEN=your-bearer-token
AWS Certificate Management
The client includes support for managing AWS credentials and certificates for IoT devices.
Setting Up AWS Credentials
from orcatech_python_api_client.aws.aws_cert_manager import AWSCredentialManager
# Configuration
HOST = "https://test.c4.orcatech.org:8080/api/public"
SCOPE = "study"
SCOPE_ID = "1"
ITEM_ID = 1
SCHEMA = "com.orcatech.inventory.item"
AUTH_TOKEN = "your-auth-token"
# Read certificate and key files
with open("aws_cert.pem", "r") as cert_file:
cert_pem = cert_file.read()
with open("aws_key.pem", "r") as key_file:
key_pem = key_file.read()
# Combine certificate and key
combined_pem = cert_pem.strip() + "\n" + key_pem.strip()
# Initialize manager
manager = AWSCredentialManager(
host=HOST,
scope=SCOPE,
scope_id=SCOPE_ID,
auth_token=AUTH_TOKEN,
schema=SCHEMA,
demo_mode=False,
insecure_ssl=True # Set to False in production
)
# Create new AWS credentials
manager.create_aws_credentials(item_id=ITEM_ID, combined_pem=combined_pem)
# Or update existing credentials
manager.update_aws_credentials(item_id=ITEM_ID, combined_pem=combined_pem)
Certificate File Format
AWS certificates should be in PEM format:
aws_cert.pem- The device certificateaws_key.pem- The private key
Important: Never commit .pem files to version control. They are automatically ignored by .gitignore.
Available Methods
get_observation()- Retrieve specific observationsget()- Generic GET requestspost()- Generic POST requestsauthenticate()- Handle authentication
Requirements
- Python >= 3.6
- requests
- python-dotenv
Author
Kezman Saboi
License
MIT License
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file orcatech_client-0.1.18.tar.gz.
File metadata
- Download URL: orcatech_client-0.1.18.tar.gz
- Upload date:
- Size: 153.7 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.13.5
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
6931569b1366bb7c74d0da53308ed30540c8511e84f9ae322c93fc79dc37f4a0
|
|
| MD5 |
944be02b670f5eb8bed5fef1b492893b
|
|
| BLAKE2b-256 |
8ad07b62ff8692e55f4ab8e7457269c4ac5098ab76e9550595f6c275f64bfbf7
|
File details
Details for the file orcatech_client-0.1.18-py3-none-any.whl.
File metadata
- Download URL: orcatech_client-0.1.18-py3-none-any.whl
- Upload date:
- Size: 159.4 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.13.5
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
7a4a65cffc2dafd9c3ffaf3184f5043fe90918475b07bc84e2cd887dc6ae954c
|
|
| MD5 |
017ad3f34b7158dd7b88240211c8158a
|
|
| BLAKE2b-256 |
5c295eb94ef88d98c533b8dd0c035172ac8cd123a868f68b30223524a9f6d420
|