Skip to main content

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

SkopeClient

__init__(api_key: str, base_url: str = "https://api.useskope.com")

Initialize a new Skope client.

  • api_key: Your Skope API key
  • base_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 identifier
  • unit: str (required) - The billing unit name
  • value: int (optional) - The value to aggregate over

Project details


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.2.tar.gz (5.1 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

skope_py-0.1.2-py3-none-any.whl (3.6 kB view details)

Uploaded Python 3

File details

Details for the file skope_py-0.1.2.tar.gz.

File metadata

  • Download URL: skope_py-0.1.2.tar.gz
  • Upload date:
  • Size: 5.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.10.10

File hashes

Hashes for skope_py-0.1.2.tar.gz
Algorithm Hash digest
SHA256 12391136e573e2f8d821f0aaa6d3ee9e83bb5131467ecd36c567fa06c459476d
MD5 3251f3772703052b82ddb53607ce2ae1
BLAKE2b-256 5bf49cb44036c3a69a785957c65f970cf55a24d2fa62ba86ad3a644dad0711a9

See more details on using hashes here.

File details

Details for the file skope_py-0.1.2-py3-none-any.whl.

File metadata

  • Download URL: skope_py-0.1.2-py3-none-any.whl
  • Upload date:
  • Size: 3.6 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.10.10

File hashes

Hashes for skope_py-0.1.2-py3-none-any.whl
Algorithm Hash digest
SHA256 6e1e275d872fe4278e8def92205bf802fe23cb9811aa7d05354fb06478f16a68
MD5 5c66d7a6eb1fdf1d10b750f5b1b7264c
BLAKE2b-256 09dcb4d2f679561531beec338ad4403ac8535e408ceaa773c5ee5549bfb22e3a

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page