A minimal Python SDK for the Claremont Computer Network API
Project description
Claremont
A minimal Python SDK for the Claremont Computer Network API.
Installation
pip install claremont
Quick Start
from claremont import Claremont
# Initialize with API key
client = Claremont(api_key="your-api-key")
# Login to get Bearer token
client.login()
# Verify token
client.verify()
# Make authenticated requests
response = client.get("/api/user/info")
# Logout
client.logout()
Configuration
Environment Variables
export CLAREMONT_API_KEY="your-api-key"
export CLAREMONT_BASE_URL="https://api.claremontcomputer.net"
Programmatic
client = Claremont(
api_key="your-api-key",
base_url="https://api.claremontcomputer.net",
timeout=30.0
)
API Reference
Claremont
The main client class.
Parameters
api_key(str, optional): API key for authentication. Can also set viaCLAREMONT_API_KEYenv var.base_url(str, optional): Base URL for the API. Defaults tohttps://api.claremontcomputer.net.timeout(float, optional): Request timeout in seconds. Defaults to 30.0.
Methods
login(api_key=None)
Login with API key and obtain a Bearer token.
client.login("your-api-key")
# Or use the one from constructor
client.login()
Returns: {"token": "...", "email": "..."}
logout()
Logout and invalidate the Bearer token.
client.logout()
Returns: {"message": "Logged out"}
register(email)
Register a new account. Note: Requires email verification on server.
client.register("user@example.com")
Returns: {"status": "registered", "email": "..."}
get(path, **kwargs)
Make a GET request.
response = client.get("/api/user/info")
post(path, **kwargs)
Make a POST request.
response = client.post("/api/data", data={"key": "value"})
CLI Usage
# Show version
claremont -v
Examples
Full Authentication Flow
from claremont import Claremont
# Initialize
client = Claremont(api_key="your-api-key")
# Login
result = client.login()
print(f"Logged in as: {result['email']}")
# Make authenticated request
user_info = client.get("/api/user/info")
print(user_info)
# Logout
client.logout()
Using Context Manager
from claremont import Claremont
with Claremont(api_key="your-api-key") as client:
client.login()
response = client.get("/api/user/info")
# Token automatically invalidated on exit
Register New User
from claremont import Claremont
client = Claremont(api_key="admin-api-key")
client.register("newuser@example.com")
CLI Usage
# Register a new account
claremont register user@example.com
# Login
claremont login user@example.com
# Logout (requires token from login)
claremont logout -t YOUR_TOKEN
# Specify custom URL
claremont --url https://api.claremontcomputer.net login user@example.com
Requirements
- Python 3.7+
- No external dependencies (uses stdlib only)
License
GPL-3.0
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 claremont-0.1.0.tar.gz.
File metadata
- Download URL: claremont-0.1.0.tar.gz
- Upload date:
- Size: 5.0 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.9.16
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
8b122e14ec1822de9de17a1ca217bc3c5a87b9f7cff7d36364764dc698d23275
|
|
| MD5 |
b67b541e22b7126862efca7157edeb04
|
|
| BLAKE2b-256 |
db9763492e80fd5a621aeb9599297188261ac1748cf8511c3e1361b012bf4fd6
|
File details
Details for the file claremont-0.1.0-py3-none-any.whl.
File metadata
- Download URL: claremont-0.1.0-py3-none-any.whl
- Upload date:
- Size: 4.8 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.9.16
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
d3c222c7f2e484cbf0815189d5c57e3e955a17793265b628b8a849f5cd08f1d4
|
|
| MD5 |
ddb21cf33590def05733464e8e2476b2
|
|
| BLAKE2b-256 |
e7180067c54528b5ecc98cf784cb9a07b9d8fde8198ac629eca5063cf6625629
|