Client library for the ExcelJet API
Project description
ExcelJet API Client
A Python client for the ExcelJet API. This client library provides convenient access to the ExcelJet API from Python applications.
Installation
# Install the package
pip install exceljet-api-client
# For developers: Install with development dependencies
pip install "exceljet-api-client[dev]"
# For local development from source
git clone https://github.com/exceljet2/exceljet-api-client.git
cd exceljet-api-client
pip install -e ".[dev]"
Usage
from exceljet_client import ExceljetClient
from exceljet_client.models import ContentType
# Initialize the client
client = ExceljetClient(api_key="your_api_key")
# List nodes with optional filtering
nodes = client.list_nodes(content_type=ContentType.FUNCTION, limit=10)
print(f"Found {nodes.count} nodes")
# Get a specific node
node = client.get_node(node_id=123)
print(f"Node title: {node.title}")
# Get node as markdown
markdown = client.get_node_markdown(node_id=123)
print(markdown)
# Create a new node
from exceljet_client.models import BackdropNode
new_node = BackdropNode(
nid=456,
title="New Function Example",
type="function",
path="functions/new-example",
created=int(time.time()),
changed=int(time.time()),
status=True,
body="Example function body"
)
created_node = client.create_node(new_node)
print(f"Created node: {created_node.nid}")
# Update an existing node
updated_node = client.update_node(node_id=456, node=new_node)
# Delete a node
client.delete_node(node_id=456)
Bulk Operations
The client supports bulk operations for creating, updating, and deleting multiple nodes:
# Bulk create nodes
nodes_to_create = [node1, node2, node3]
result = client.create_nodes_bulk(nodes_to_create)
print(f"Created {result.created} nodes")
# Bulk update nodes
result = client.update_nodes_bulk(nodes_to_update)
print(f"Updated {result.updated} nodes")
# Bulk delete nodes
result = client.delete_nodes_bulk([123, 456, 789])
print(f"Deleted {result.deleted} nodes")
Error Handling
The client raises typed exceptions for different error cases:
from exceljet_client.exceptions import ExceljetApiError, NodeNotFoundError
try:
node = client.get_node(node_id=999999)
except NodeNotFoundError:
print("Node not found")
except ExceljetApiError as e:
print(f"API error: {e.status_code} - {e.detail}")
Running Integration Tests
The library includes integration tests that can be run against a local or remote API server:
# Run integration tests against localhost:8000 (the default)
pytest tests/test_integration.py
# Skip integration tests
SKIP_INTEGRATION_TESTS=true pytest
# Run against a different server
EXCELJET_API_URL=http://api.example.com EXCELJET_API_KEY=your_key pytest tests/test_integration.py
The integration tests require a running ExcelJet API server. By default, they connect to http://localhost:8000 using the API key integration_test_key. You can customize these using environment variables:
EXCELJET_API_URL- The base URL of the API serverEXCELJET_API_KEY- The API key to use for authenticationSKIP_INTEGRATION_TESTS- Set to "true" to skip integration tests
API Reference
See the full API reference for detailed documentation.
License
MIT
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
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 exceljet_client-0.1.1.tar.gz.
File metadata
- Download URL: exceljet_client-0.1.1.tar.gz
- Upload date:
- Size: 12.6 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.10.8
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
034b2f79c8da5337aa76a5f8a1a9cc3bd2366c06d56355b794d7a91eed8bf969
|
|
| MD5 |
3b89daf0b93ad3533e3feb1776d1d8cd
|
|
| BLAKE2b-256 |
995896ec030c1a2890b1452ffe4cea61ea5e29041002e3af89dddd7c60b3d7f1
|
File details
Details for the file exceljet_client-0.1.1-py3-none-any.whl.
File metadata
- Download URL: exceljet_client-0.1.1-py3-none-any.whl
- Upload date:
- Size: 8.8 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.10.8
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
0d9e2764b7dfbb0cfa04d73525c897683c77de1e6b37dac69d2d3152a4e936d1
|
|
| MD5 |
6fa2cd809b0c62dfb6024303ac9ffffe
|
|
| BLAKE2b-256 |
bb6f0fb760e4cea5c48f0999e0d97ad428d266ee693ba41e4b75c0903ffa120c
|