Python SDK for the Skope API
Project description
Skope SDK
A Python SDK for interacting with the Skope API.
Installation
pip install skope-sdk
Usage
from skope import Skope, Event
# Initialize the client
client = Skope(
api_key="your_api_key_here",
base_url="https://api.useskope.com" # Optional, defaults to production
)
# Create events for billing
events = [
Event(
user_id="customer_123",
unit="api_calls",
value=100
),
Event(
user_id="customer_456",
unit="storage_gb",
value=5
)
]
# Upload events in batch
result = client.upload_events(events)
print(f"Upload result: {result}")
Error Handling
The SDK will raise HTTP exceptions if API requests fail:
import requests
try:
result = client.upload_events(events)
except requests.exceptions.HTTPError as e:
print(f"Failed to upload events: {e}")
except requests.exceptions.RequestException as e:
print(f"Request failed: {e}")
API Reference
Skope
__init__(api_key: str, base_url: str = "https://api.useskope.com")
Initialize a new Skope client.
api_key: Your Skope API keybase_url: The base URL of the Skope API (optional)
upload_events(events: List[Event]) -> Dict[str, Any]
Upload multiple events for billing in one request.
events: A list of Event objects- Returns: The response data containing upload status
Event
A Pydantic model representing a billing event.
Fields:
user_id: str (required) - The customer identifierunit: str (required) - The billing unit namevalue: int (optional) - The value to aggregate over
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
skope_py-0.1.3.tar.gz
(7.3 kB
view details)
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 skope_py-0.1.3.tar.gz.
File metadata
- Download URL: skope_py-0.1.3.tar.gz
- Upload date:
- Size: 7.3 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.10.10
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
3a1154f5549950d6314ef0f86712a0a7ee816b07123ff5b5d51a0bae9c1e6147
|
|
| MD5 |
41364e65f0615ae0244cc401399f8259
|
|
| BLAKE2b-256 |
5299f3556acba18e9c37d50827493879d3d02c6446b44c7eb91e8eeda2335ab8
|
File details
Details for the file skope_py-0.1.3-py3-none-any.whl.
File metadata
- Download URL: skope_py-0.1.3-py3-none-any.whl
- Upload date:
- Size: 4.7 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.10.10
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
7269c498a5443287d66c1b5f8ec07f59c65e25e785537ca88c64e3de09e906d7
|
|
| MD5 |
b7d2ec9d81697df39ac9d884b053d653
|
|
| BLAKE2b-256 |
810e871fb637901a8a91e4cce0e31dd761122b3d83702a0751a636ac64370fa0
|