A toolkit for interacting with the Google Blogger API
Project description
Bloggerkit
A Python toolkit for interacting with the Google Blogger API with simplified authentication and enhanced features.
โจ What's New in v0.7.0
๐ง Environment Variable Support - No more manual credentials.json management!
๐ Auto-generated Credentials - Automatically creates credentials from environment variables
๐ Full Backward Compatibility - All existing code continues to work unchanged
๐ Enhanced Post Features - Added labels and is_draft parameters
๐ฌ Improved User Experience - Better error messages and helpful logging
๐ฆ Installation
pip install bloggerkit
๐ Quick Start
Method 1: Environment Variables (Recommended)
-
Set up Google Cloud Console:
- Go to Google Cloud Console
- Create a new project or select existing one
- Enable the Blogger API
- Go to APIs & Services โ Credentials
- Create OAuth 2.0 Client ID (Desktop Application)
- Copy the Client ID and Client Secret
-
Set environment variables:
# Add to your .env file or export directly export GOOGLE_CLIENT_ID="your_client_id_here" export GOOGLE_CLIENT_SECRET="your_client_secret_here" export BLOG_ID="your_blog_id_here"
-
Use bloggerkit:
from bloggerkit.client import BloggerClient # Simple initialization - uses environment variables automatically client = BloggerClient("your_blog_id") # Create a post post = client.create_post( title="My First Post", content="<p>Hello World!</p>", labels=["python", "blogging"], is_draft=False ) print(f"โ Post created: {post['url']}")
Method 2: Traditional credentials.json (Still Supported)
from bloggerkit.client import BloggerClient
client = BloggerClient(
blog_id="your_blog_id",
client_secrets_file="path/to/credentials.json"
)
Method 3: Direct Parameters
from bloggerkit.client import BloggerClient
client = BloggerClient(
blog_id="your_blog_id",
client_id="your_client_id",
client_secret="your_client_secret"
)
๐ Usage Examples
List Posts
posts = client.list_posts()
if posts:
for post in posts.items:
print(f"๐ {post.title}: {post.url}")
Create a Post
# Basic post
new_post = client.create_post(
title="My New Post",
content="<p>This is my new blog post content.</p>"
)
# Advanced post with labels and draft mode
draft_post = client.create_post(
title="Draft Post",
content="<p>This is a draft post.</p>",
labels=["draft", "work-in-progress"],
is_draft=True
)
Get a Specific Post
post = client.get_post("POST_ID")
if post:
print(f"๐ Title: {post.title}")
print(f"๐ URL: {post.url}")
print(f"๐ท๏ธ Labels: {post.labels}")
Update a Post
updated_post = client.update_post(
post_id="POST_ID",
title="Updated Title",
content="<p>Updated content goes here.</p>",
labels=["updated", "python"]
)
Delete a Post
client.delete_post("POST_ID")
print("๐๏ธ Post deleted successfully!")
๐ Authentication Flow
- First Run: Browser opens for Google OAuth authentication
- Token Storage: Creates
token.jsonfor future automatic authentication - Auto-refresh: Automatically refreshes expired tokens
- Seamless Experience: No manual intervention needed after initial setup
๐ง Configuration Priority
bloggerkit uses the following priority order for authentication:
- Direct Parameters (
client_id,client_secret) - Environment Variables (
GOOGLE_CLIENT_ID,GOOGLE_CLIENT_SECRET) - Credentials File (
client_secrets_file)
๐ท๏ธ API Reference
BloggerClient
BloggerClient(
blog_id: str,
client_secrets_file: str = None,
client_id: str = None,
client_secret: str = None
)
Methods
| Method | Description | Parameters |
|---|---|---|
list_posts() |
Get all posts | None |
create_post() |
Create new post | title, content, labels=None, is_draft=False |
get_post() |
Get specific post | post_id |
update_post() |
Update existing post | post_id, title, content, labels=None |
delete_post() |
Delete post | post_id |
๐ Migration Guide
From v0.6.x to v0.7.0
No changes required! Your existing code works exactly the same:
# This still works perfectly
client = BloggerClient(blog_id, client_secrets_file)
Optional enhancement - Simplify with environment variables:
# Before (v0.6.x)
client = BloggerClient("blog_id", "credentials.json")
# After (v0.7.0) - Optional improvement
os.environ['GOOGLE_CLIENT_ID'] = 'your_id'
os.environ['GOOGLE_CLIENT_SECRET'] = 'your_secret'
client = BloggerClient("blog_id") # Much cleaner!
๐ ๏ธ Development Setup
git clone https://github.com/StatPan/bloggerkit.git
cd bloggerkit
pip install -e .
๐ Requirements
- Python 3.10+
- Google Blogger API access
- OAuth 2.0 credentials
๐ค Contributing
- Fork the repository
- Create your feature branch (
git checkout -b feature/amazing-feature) - Commit your changes (
git commit -m 'Add amazing feature') - Push to the branch (
git push origin feature/amazing-feature) - Open a Pull Request
๐ Change Log
See changelog.md for detailed version history.
๐ License
This project is licensed under the MIT License.
๐ Support
- ๐ Documentation
- ๐ Issues
- ๐ฌ Discussions
Happy Blogging! ๐๐
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 bloggerkit-0.7.0.tar.gz.
File metadata
- Download URL: bloggerkit-0.7.0.tar.gz
- Upload date:
- Size: 8.1 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.6.2
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
8dcfa38731644ad7584722f28cf8d5c570d4cd1ad3455433c4f352bb5c970410
|
|
| MD5 |
9f130a7d995b2387a73aab0cbd05afa7
|
|
| BLAKE2b-256 |
0879d274db5814922880526bcc6392b3399862ec6cd3cadbaa14cf4f88753a97
|
File details
Details for the file bloggerkit-0.7.0-py3-none-any.whl.
File metadata
- Download URL: bloggerkit-0.7.0-py3-none-any.whl
- Upload date:
- Size: 8.3 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.6.2
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
1fcfbf23296f396634b97881727966a8f500ecb8a2ef2cdad36462c200179741
|
|
| MD5 |
1d2b5d593e91c0c8917d4aa6ac66debf
|
|
| BLAKE2b-256 |
db337f3c8089d7c09a3be8939f41681d3d61e9903cf3d2aa7ae77fe77ab08653
|