Skip to main content

Lightwheel SDK Python

A Python SDK for interacting with the Lightwheel API, featuring comprehensive logging capabilities.

Features

  • Authentication Management: Secure login/logout with token caching and refresh
  • Comprehensive Logging: Detailed logging throughout the SDK for debugging and monitoring
  • CLI Interface: Command-line tools for easy interaction
  • Error Handling: Robust exception handling with detailed error logging

Installation

pip install lightwheel-sdk

Quick Start

Basic Usage

from lightwheel_sdk.loader import LightwheelClient

# Initialize client
client = LightwheelClient(host="https://api.lightwheel.net")

# Login
client.login(username="your_username", password="your_password")

# Make API calls
response = client.post("/api/your/endpoint", data={"key": "value"})

CLI Usage

# Login
lightwheel login --username your_username --password your_password

# Logout
lightwheel logout

Logging Configuration

The SDK includes comprehensive logging capabilities that can be configured through environment variables or programmatically.

Environment Variables

  • LW_SDK_LOG_LEVEL: Set the logging level (DEBUG, INFO, WARNING, ERROR, CRITICAL)
  • LW_SDK_LOG_FILE: Optional path to log file
  • LW_API_ENDPOINT: API endpoint URL

Programmatic Configuration

from lightwheel_sdk.logger import setup_logger

# Configure logger
logger = setup_logger(
    name="my_app",
    level="DEBUG",
    log_file="/path/to/logfile.log"
)

Logging Levels

  • DEBUG: Detailed information for debugging
  • INFO: General information about SDK operations
  • WARNING: Warning messages for potential issues
  • ERROR: Error messages for failed operations
  • CRITICAL: Critical errors that may cause the application to stop

Log Categories

The SDK uses different logger names for different components:

  • lightwheel_sdk.client: Client operations and API calls
  • lightwheel_sdk.login: Authentication and login management
  • lightwheel_sdk.cli: Command-line interface operations
  • lightwheel_sdk.exception: Exception handling and error logging

Example Log Output

2025-01-27 10:30:15,123 - lightwheel_sdk.client - INFO - Initializing LightwheelClient with host: https://api.lightwheel.net
2025-01-27 10:30:15,124 - lightwheel_sdk.client - INFO - Starting login process
2025-01-27 10:30:15,125 - lightwheel_sdk.client - INFO - Performing authentication with API
2025-01-27 10:30:15,200 - lightwheel_sdk.client - INFO - Login successful for user: john_doe
2025-01-27 10:30:15,201 - lightwheel_sdk.client - DEBUG - Making POST request to /api/your/endpoint
2025-01-27 10:30:15,250 - lightwheel_sdk.client - DEBUG - POST request to /api/your/endpoint completed successfully

API Reference

LightwheelClient

Main client class for interacting with the Lightwheel API.

Methods

  • login(force_login=False, username=None, password=None): Authenticate with the API
  • logout(): Clear authentication and remove cached credentials
  • post(path, data=None, timeout=None): Make POST requests to the API

Login Manager

High-level interface for authentication management.

Methods

  • login(force_login=False, username=None, password=None): Login to the API
  • logout(): Logout from the API
  • get_headers(): Get authentication headers

Error Handling

The SDK provides comprehensive error handling with detailed logging:

  • ApiException: API-related errors with status codes and response details
  • AuthenticationFailedException: Authentication failures
  • UnknownException: Unexpected errors

All exceptions include detailed logging for debugging purposes.

Configuration

Environment Variables

Variable Description Default
LW_API_ENDPOINT API endpoint URL https://api.lightwheel.net
LW_SDK_LOG_LEVEL Logging level INFO
LW_SDK_LOG_FILE Log file path None (console only)
LW_SDK_HEADERS_* Custom headers None
LoaderUserName Username for authentication None
LoaderToken Token for authentication None

Custom Headers

You can set custom headers using environment variables with the prefix LW_SDK_HEADERS_:

export LW_SDK_HEADERS_X_CUSTOM_HEADER="custom_value"

Development

Running Tests

python -m pytest tests/

Building

python -m build

License

Copyright 2025 Lightwheel Team

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

Metadata

Release files for lightwheel-sdk 1.0.3

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Built distribution (wheel)

Table of built distributions (wheels) for lightwheel-sdk 1.0.3
File Interpreter ABI Platform Actions
lightwheel_sdk-1.0.3-py3-none-any.whl Python 3 none any Details for lightwheel_sdk-1.0.3-py3-none-any.whl

Release files / lightwheel_sdk-1.0.3-py3-none-any.whl

Download URL lightwheel_sdk-1.0.3-py3-none-any.whl
Size 523.2 kB
Tags Python 3
SHA-256 checksum
How to use checksums
841ec064ab21a403de024e1e860541e9949e0ea2330d51961b1fdf49d0ec21cd
BLAKE2b-256 checksum
How to use checksums
21e368448f351bea9e1412bf13b62aa69eaf67ce652fd99a4aeafa4a5da3e1fb
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.10.18

Security for lightwheel-sdk 1.0.3

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

1.0.3 This release

1 release file No provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page