Python SDK
Official Python SDK for WebinOne API
Python SDK
The official Python SDK provides a pythonic interface to the WebinOne API with automatic authentication, error handling, and type hints.
Installation
pip install webinone-sdk
Quick Start
from webinone import Client
client = Client(
base_url='https://your-site.webinone.com',
client_id='YOUR_CLIENT_ID',
client_secret='YOUR_CLIENT_SECRET'
)
# List all pages
pages = client.pages.list()
# Create a new page
page = client.pages.create(
name='My New Page',
url_slug='my-new-page',
enabled=True
)
Features
- Automatic authentication: Token refresh handled automatically
- Type hints: Full type annotations for IDE autocomplete
- Error handling: Typed exceptions for different error cases
- Async support: Both sync and async clients available
- Pagination: Built-in iterator for large result sets
Working with Module Items
# Get module by name
module = client.modules.get_by_name('Products')
# List items with filtering
products = client.module_items.list(
module_id=module.id,
where={'$and': [{'$eq': {'Enabled': True}}]},
order_by='Name ASC',
limit=50
)
# Create an item
product = client.module_items.create(
module_id=module.id,
name='New Product',
url_slug='new-product',
enabled=True,
custom_properties={
'Price': '99.99',
'Description': 'Product description'
}
)
Async Client
from webinone import AsyncClient
import asyncio
async def main():
async with AsyncClient(
base_url='https://your-site.webinone.com',
client_id='YOUR_CLIENT_ID',
client_secret='YOUR_CLIENT_SECRET'
) as client:
pages = await client.pages.list()
for page in pages:
print(page.name)
asyncio.run(main())
Error Handling
from webinone.exceptions import (
AuthenticationError,
RateLimitError,
ValidationError,
NotFoundError
)
try:
page = client.pages.get(page_id=123)
except NotFoundError:
print('Page not found')
except RateLimitError as e:
print(f'Rate limited. Retry after {e.retry_after} seconds')
except ValidationError as e:
print(f'Validation failed: {e.errors}')
📚 Documentation
Full SDK documentation is available at python-sdk.webinone.com
Code Examples
# Full Example: Blog Post Manager
from webinone import Client
from datetime import datetime
class BlogManager:
def __init__(self, client):
self.client = client
self.blog_module = client.modules.get_by_name('Blog Posts')
def create_post(self, title, content, author, tags=None):
return self.client.module_items.create(
module_id=self.blog_module.id,
name=title,
url_slug=self._slugify(title),
enabled=True,
release_date=datetime.now(),
custom_properties={
'Content': content,
'Author': author,
'Tags': ','.join(tags or [])
}
)
def get_recent_posts(self, limit=10):
return self.client.module_items.list(
module_id=self.blog_module.id,
where={'$and': [{'$eq': {'Enabled': True}}]},
order_by='ReleaseDate DESC',
limit=limit
)
def _slugify(self, title):
import re
slug = title.lower()
slug = re.sub(r'[^a-z0-9]+', '-', slug)
return slug.strip('-')
# Usage
client = Client(
base_url='https://your-site.webinone.com',
client_id='YOUR_CLIENT_ID',
client_secret='YOUR_CLIENT_SECRET'
)
blog = BlogManager(client)
# Create a new post
post = blog.create_post(
title='Getting Started with WebinOne',
content='WebinOne is a powerful...
',
author='John Doe',
tags=['tutorial', 'beginner']
)
# Get recent posts
recent = blog.get_recent_posts(limit=5)
for post in recent:
print(f'{post.name} - {post.release_date}')