Skip to main content

A toolkit for interacting with the Google Blogger API

Project description

Bloggerkit

A Python toolkit for interacting with the Google Blogger API.

Installation

pip install bloggerkit

Authentication

This library now uses OAuth 2.0 for authentication. Follow these steps to set up your credentials:

  1. Create a Google Cloud Project:
  2. Enable the Blogger API:
    • In the Cloud Console, navigate to "APIs & Services" > "Library".
    • Search for "Blogger API" and enable it.
  3. Create OAuth 2.0 Credentials:
    • Go to "APIs & Services" > "Credentials".
    • Click "Create Credentials" > "OAuth client ID".
    • Select "Desktop app" as the application type.
    • Give your client ID a name and click "Create".
  4. Download the client_secrets.json file:
    • After creating the client ID, download the client_secrets.json file.
    • Place this file in your project directory.

Usage

from bloggerkit.client import BloggerClient

# Replace with your blog ID and the path to your client_secrets.json file
BLOG_ID = "YOUR_BLOG_ID"
CLIENT_SECRETS_FILE = "path/to/your/client_secrets.json"

client = BloggerClient(BLOG_ID, CLIENT_SECRETS_FILE)

# List posts
posts = client.list_posts()
if posts and "items" in posts:
    for post in posts["items"]:
        print(post['title'], post['url'])

# Create a new post
new_post = client.create_post("My New Post", "Content of my new post.")
if new_post:
    print(f"New post created: {new_post['url']}")

# Get a specific post
post = client.get_post("POST_ID")  # Replace with the actual post ID
if post:
    print(f"Post title: {post['title']}")

# Update a post
updated_post = client.update_post("POST_ID", "Updated Title", "Updated content.")  # Replace with the actual post ID
if updated_post:
    print(f"Post updated: {updated_post['url']}")

# Delete a post
client.delete_post("POST_ID")  # Replace with the actual post ID
print("Post deleted successfully.")

Note:

  • Make sure to replace YOUR_BLOG_ID, path/to/your/client_secrets.json and POST_ID with your actual blog ID, the path to your client_secrets.json file, and post ID.
  • The first time you run the script, it will open a web browser to authenticate with your Google account.
  • A token.json file will be created to store your access token. If you change the client_secrets.json file, you may need to delete the token.json file and re-authenticate.
  • The BloggerClient now takes the blog ID and the path to the client_secrets.json file as arguments.

Features

  • list_posts(): Retrieves a list of all posts in the blog.
  • create_post(title, content): Creates a new post with the given title and content.
  • get_post(post_id): Retrieves a specific post by its ID.
  • update_post(post_id, title, content): Updates an existing post with the given ID, title, and content.
  • delete_post(post_id): Deletes a post with the given ID.

Change Log

See changelog.md for details.

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

bloggerkit-0.6.2.tar.gz (5.6 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

bloggerkit-0.6.2-py3-none-any.whl (5.9 kB view details)

Uploaded Python 3

File details

Details for the file bloggerkit-0.6.2.tar.gz.

File metadata

  • Download URL: bloggerkit-0.6.2.tar.gz
  • Upload date:
  • Size: 5.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.6.8

File hashes

Hashes for bloggerkit-0.6.2.tar.gz
Algorithm Hash digest
SHA256 7a33075eac9e3969789fc6bc395ec9849fff10b1382311a0fd893ebc58d2b970
MD5 dcc5fb580ff335a7e9363083fc6a0df7
BLAKE2b-256 39d722639952311a1948c86c2c4801d2e210bf962c0181a0c5a0b218a4bb7410

See more details on using hashes here.

File details

Details for the file bloggerkit-0.6.2-py3-none-any.whl.

File metadata

File hashes

Hashes for bloggerkit-0.6.2-py3-none-any.whl
Algorithm Hash digest
SHA256 6d70c37fff7bb4bb201ab0f77f3487009eb1410af61c32a14d5eb059cae9f364
MD5 055442e5773469c1a67629c590d7a640
BLAKE2b-256 e236d8543a9eda516ae5c06f3c3db7ee0c5b5f7a99ed1896fdaada2e3687b678

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page