Skip to main content

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

  1. 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
  2. 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"
    
  3. 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

  1. First Run: Browser opens for Google OAuth authentication
  2. Token Storage: Creates token.json for future automatic authentication
  3. Auto-refresh: Automatically refreshes expired tokens
  4. Seamless Experience: No manual intervention needed after initial setup

🔧 Configuration Priority

bloggerkit uses the following priority order for authentication:

  1. Direct Parameters (client_id, client_secret)
  2. Environment Variables (GOOGLE_CLIENT_ID, GOOGLE_CLIENT_SECRET)
  3. 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

  1. Fork the repository
  2. Create your feature branch (git checkout -b feature/amazing-feature)
  3. Commit your changes (git commit -m 'Add amazing feature')
  4. Push to the branch (git push origin feature/amazing-feature)
  5. Open a Pull Request

📝 Change Log

See changelog.md for detailed version history.

📄 License

This project is licensed under the MIT License.

🆘 Support


Happy Blogging! 🚀📝

Metadata

Release files for bloggerkit 0.7.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for bloggerkit 0.7.0
File Size Uploaded
bloggerkit-0.7.0.tar.gz 8.1 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for bloggerkit 0.7.0
File Interpreter ABI Platform
bloggerkit-0.7.0-py3-none-any.whl Python 3 none any Details

Total release size: 16.4 kB

Release files / bloggerkit-0.7.0.tar.gz

Download URL bloggerkit-0.7.0.tar.gz
Size 8.1 kB
Tags Source
SHA-256 checksum
How to use checksums
8dcfa38731644ad7584722f28cf8d5c570d4cd1ad3455433c4f352bb5c970410
BLAKE2b-256 checksum
How to use checksums
0879d274db5814922880526bcc6392b3399862ec6cd3cadbaa14cf4f88753a97
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.6.2

Release files / bloggerkit-0.7.0-py3-none-any.whl

Download URL bloggerkit-0.7.0-py3-none-any.whl
Size 8.3 kB
Tags Python 3
SHA-256 checksum
How to use checksums
1fcfbf23296f396634b97881727966a8f500ecb8a2ef2cdad36462c200179741
BLAKE2b-256 checksum
How to use checksums
db337f3c8089d7c09a3be8939f41681d3d61e9903cf3d2aa7ae77fe77ab08653
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.6.2

Release history Release notifications | RSS feed

This release

0.7.0 This release

2 release files

0.6.2

2 release files

0.6.1

2 release files

0.6.0

2 release files

0.5.0

2 release files

0.4.2

2 release files

0.4.1

2 release files

0.4.0

2 release files

0.3.0

2 release files

0.2.0

2 release files

0.1.0

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page