dc0d72c8964c7588f84ac178000b77342210a3f1
Implement Phase 3 improvements: intelligent caching and batch operations
to significantly enhance SDK performance and usability.
**1. Caching Layer Implementation**
Added complete caching infrastructure with LRU eviction and TTL support:
- `wikijs/cache/base.py`: Abstract BaseCache interface with CacheKey structure
- `wikijs/cache/memory.py`: MemoryCache implementation with:
* LRU (Least Recently Used) eviction policy
* Configurable TTL (time-to-live) expiration
* Cache statistics (hits, misses, hit rate)
* Resource-specific invalidation
* Automatic cleanup of expired entries
**Cache Integration:**
- Modified `WikiJSClient` to accept optional `cache` parameter
- Integrated caching into `PagesEndpoint.get()`:
* Check cache before API request
* Store successful responses in cache
* Invalidate cache on write operations (update, delete)
**2. Batch Operations**
Added efficient batch methods to Pages API:
- `create_many(pages_data)`: Batch create multiple pages
- `update_many(updates)`: Batch update pages with partial success handling
- `delete_many(page_ids)`: Batch delete with detailed error reporting
All batch methods include:
- Partial success support (continue on errors)
- Detailed error tracking with indices
- Comprehensive error messages
**3. Comprehensive Testing**
Added 27 new tests (all passing):
- `tests/test_cache.py`: 17 tests for caching (99% coverage)
* CacheKey string generation
* TTL expiration
* LRU eviction policy
* Cache invalidation (specific & all resources)
* Statistics tracking
- `tests/endpoints/test_pages_batch.py`: 10 tests for batch operations
* Successful batch creates/updates/deletes
* Partial failure handling
* Empty list edge cases
* Validation error handling
**Performance Benefits:**
- Caching reduces API calls for frequently accessed pages
- Batch operations reduce network overhead for bulk actions
- Configurable cache size and TTL for optimization
**Example Usage:**
```python
from wikijs import WikiJSClient
from wikijs.cache import MemoryCache
# Enable caching
cache = MemoryCache(ttl=300, max_size=1000)
client = WikiJSClient('https://wiki.example.com', auth='key', cache=cache)
# Cached GET requests
page = client.pages.get(123) # Fetches from API
page = client.pages.get(123) # Returns from cache
# Batch operations
pages = client.pages.create_many([
PageCreate(title="Page 1", path="page-1", content="Content 1"),
PageCreate(title="Page 2", path="page-2", content="Content 2"),
])
updates = client.pages.update_many([
{"id": 1, "content": "Updated content"},
{"id": 2, "is_published": False},
])
result = client.pages.delete_many([1, 2, 3])
print(f"Deleted {result['successful']} pages")
```
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude <noreply@anthropic.com>
Wiki.js Python SDK
A professional Python SDK for Wiki.js API integration.
🎉 Status: Phase 1 MVP Complete! Ready for production use
Current Version: v0.1.0 with complete Wiki.js Pages API integration Next Milestone: v0.2.0 with Users, Groups, and Assets API support
🚀 Quick Start
Installation
# Install directly from Gitea
pip install git+https://gitea.hotserv.cloud/lmiranda/wikijs-sdk-python.git
# Or clone and install locally
git clone https://gitea.hotserv.cloud/lmiranda/wikijs-sdk-python.git
cd wikijs-python-sdk
pip install -e .
Basic Usage
from wikijs import WikiJSClient
# Initialize client
client = WikiJSClient('https://wiki.example.com', auth='your-api-key')
# List pages
pages = client.pages.list()
# Get a specific page
page = client.pages.get(123)
# Create a new page
from wikijs.models import PageCreate
new_page = client.pages.create(PageCreate(
title="Getting Started",
path="getting-started",
content="# Welcome\n\nThis is your first page!"
))
🎯 Current Development Status
Phase 1: MVP Development ✅ COMPLETE
- ✅ Complete: Professional-grade Wiki.js Python SDK
- 🎯 Goal: Basic Wiki.js integration with Pages API
- 📦 Deliverable: Installable package with core functionality
| Component | Status | Description |
|---|---|---|
| Project Setup | ✅ Complete | Repository structure, packaging, CI/CD |
| Core Client | ✅ Complete | HTTP client with authentication and retry logic |
| Pages API | ✅ Complete | Full CRUD operations for wiki pages |
| Testing | ✅ Complete | 87%+ test coverage with comprehensive test suite |
| Documentation | ✅ Complete | Complete API reference, user guide, and examples |
Planned Features
- v0.2.0: Complete API coverage (Users, Groups, Assets)
- v0.3.0: Production features (retry logic, caching, monitoring)
- v1.0.0: Enterprise features (async support, plugins, advanced CLI)
📚 Documentation
For Users
- Quick Start: Basic setup and usage
- API Reference: Complete SDK documentation
- User Guide: Comprehensive usage guide with examples
- Examples: Real-world usage examples and code samples
For Contributors
- Contributing Guide: How to contribute to the project
- Development Guide: Setup and development workflow
- Changelog: Version history and changes
For Maintainers
- Architecture: Technical design and patterns
- Development Plan: Complete roadmap and milestones
- Development Notes: Development workflow and coordination
🤝 Contributing
We welcome contributions! This project showcases systematic development with professional standards.
Getting Started:
- Check our Development Plan for current priorities
- Review the Architecture for technical context
- See Development Notes for development workflow
- Start with issues labeled
good first issue(Coming soon)
Community:
- 💬 GitHub Discussions: Questions and community chat (Coming soon)
- 🐛 GitHub Issues: Bug reports and feature requests (Coming soon)
🛠️ Development Setup
Prerequisites
- Python 3.8+
- Git
- Wiki.js instance for testing
Local Development
# Clone and setup
git clone https://gitea.hotserv.cloud/lmiranda/wikijs-sdk-python.git
cd wikijs-python-sdk
pip install -e ".[dev]"
# Run tests
pytest
# Run quality checks
pre-commit run --all-files
🏆 Project Features
Current (MVP Complete)
- ✅ Synchronous HTTP client with connection pooling and retry logic
- ✅ Multiple authentication methods (API key, JWT, custom)
- ✅ Complete Pages API with CRUD operations, search, and filtering
- ✅ Comprehensive error handling with specific exception types
- ✅ Type-safe models with validation using Pydantic
- ✅ Extensive test coverage (87%+) with robust test suite
- ✅ Complete documentation with API reference and user guide
- ✅ Practical examples and code samples
Planned Enhancements
- ⚡ Async/await support
- 💾 Intelligent caching
- 🔄 Retry logic with backoff
- 💻 CLI tools
- 🔧 Plugin system
- 🛡️ Advanced security features
📄 License
This project is licensed under the MIT License - see the LICENSE file for details.
🙏 Acknowledgments
- Wiki.js: The excellent knowledge management platform this SDK supports
- leomiranda: Developer who created this SDK
- Python Community: For exceptional tools and development standards
Ready to contribute? Check out our development documentation or explore the development workflow to see how this project is built!
Languages
Python
100%