Python client for the Nuclino API
Project description
Nuclino Python API Client
A Python client library for interacting with the Nuclino API. This library provides a clean, Pythonic interface to Nuclino's REST API, making it easy to manage workspaces, items, and collections programmatically.
Features
- Full support for Nuclino API v0
- Object-oriented interface with proper type hints
- Automatic rate limiting handling
- Comprehensive error handling
- Convenient helper methods for common operations
- Support for both items and collections management
- Built-in pagination handling
Installation
pip install nuclino
Quick Start
from nuclino import NuclinoAPI
# Initialize the client
client = NuclinoAPI(api_key="your-api-key")
# Get items from a workspace
items = client.get_items(workspace_id="your-workspace-id")
# Create a new item
new_item = client.create_item(
workspace_id="your-workspace-id",
title="My New Item",
content="This is the content of my new item"
)
# Update an item
updated_item = client.update_item(
item_id="your-item-id",
title="Updated Title",
content="Updated content"
)
# Delete an item
client.delete_item("your-item-id")
Features in Detail
Items and Collections
The library supports all operations on both items and collections:
- Create, read, update, and delete items
- Create, read, update, and delete collections
- Organize items within collections
- Manage item content and metadata
Error Handling
The library provides detailed error handling with specific exception classes:
NuclinoAuthenticationError: Authentication failuresNuclinoPermissionError: Permission-related issuesNuclinoValidationError: Invalid request parametersNuclinoNotFoundError: Resource not foundNuclinoRateLimitError: Rate limit exceededNuclinoServerError: Server-side errors
Rate Limiting
Built-in rate limiting support helps prevent API quota exhaustion:
- Automatic request rate monitoring
- Built-in retry mechanism
- Configurable requests per minute limit
Type Safety
The library is fully typed with Python type hints:
- All methods have proper return type annotations
- TypedDict definitions for API request/response data
- Support for IDE autocompletion
- Mypy compatibility
API Reference
Main Client
class Client:
def __init__(self, api_key: str, base_url: str = "https://api.nuclino.com/v0", requests_per_minute: int = 140)
Item Operations
def get_items(
team_id: Optional[str] = None,
workspace_id: Optional[str] = None,
limit: Optional[int] = None,
after: Optional[str] = None
) -> List[Union[Item, Collection]]
def get_item(item_id: str) -> Union[Item, Collection]
def create_item(
workspace_id: Optional[str] = None,
parent_id: Optional[str] = None,
object: str = 'item',
title: Optional[str] = None,
content: Optional[str] = None,
index: Optional[int] = None
) -> Union[Item, Collection]
def update_item(
item_id: str,
title: Optional[str] = None,
content: Optional[str] = None
) -> Union[Item, Collection]
def delete_item(item_id: str) -> BaseDeleteResponse
Collection Operations
def get_collection(collection_id: str) -> Collection
def create_collection(
workspace_id: Optional[str] = None,
parent_id: Optional[str] = None,
title: Optional[str] = None,
index: Optional[int] = None
) -> Collection
def update_collection(
collection_id: str,
title: Optional[str] = None
) -> Collection
def delete_collection(collection_id: str) -> BaseDeleteResponse
Error Handling
try:
client.get_item("non-existent-id")
except NuclinoNotFoundError:
print("Item not found")
except NuclinoAuthenticationError:
print("Invalid API key")
except NuclinoPermissionError:
print("Insufficient permissions")
except NuclinoRateLimitError as e:
print(f"Rate limit exceeded. Try again in {e.retry_after} seconds")
Contributing
Contributions are welcome! Please feel free to submit a Pull Request.
License
This project is licensed under the MIT License - see the LICENSE file for details.
Acknowledgments
- Built for the Nuclino API
- Inspired by modern Python API client design patterns
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 nuclino-0.1.0.tar.gz.
File metadata
- Download URL: nuclino-0.1.0.tar.gz
- Upload date:
- Size: 24.0 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.6.10
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
5502db3be1f339b2934db09cdf0355a884dc3b55f8cb18d69fec47f9dbbc0cae
|
|
| MD5 |
def64f7cf96c6cc44448c0f6f27ae5fe
|
|
| BLAKE2b-256 |
3dcf4aa5484f62cac8ec00aee04d5841d9d839b7bdc0f522b9004bb27188cd4a
|
File details
Details for the file nuclino-0.1.0-py3-none-any.whl.
File metadata
- Download URL: nuclino-0.1.0-py3-none-any.whl
- Upload date:
- Size: 20.6 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.6.10
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
9a2b669272c5d0e83074d0c7b80f1afc97108855122e87479ce192ba246b6b92
|
|
| MD5 |
de7f1484c62d1c1c8581b49d1804bf3d
|
|
| BLAKE2b-256 |
1d90345224613619680f59ca3ada45b646d42c982b4d9a60f18021a9bc03487c
|