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:
- Create a Google Cloud Project:
- Go to the Google Cloud Console.
- Create a new project or select an existing one.
- Enable the Blogger API:
- In the Cloud Console, navigate to "APIs & Services" > "Library".
- Search for "Blogger API" and enable it.
- 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".
- Download the client_secrets.json file:
- After creating the client ID, download the
client_secrets.jsonfile. - Place this file in your project directory.
- After creating the client ID, download the
Usage
from bloggerkit 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.jsonandPOST_IDwith your actual blog ID, the path to yourclient_secrets.jsonfile, and post ID. - The first time you run the script, it will open a web browser to authenticate with your Google account.
- A
token.jsonfile will be created to store your access token. If you change theclient_secrets.jsonfile, you may need to delete thetoken.jsonfile and re-authenticate. - The
BloggerClientnow takes the blog ID and the path to theclient_secrets.jsonfile 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
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
bloggerkit-0.6.0.tar.gz
(5.6 kB
view details)
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.6.0.tar.gz.
File metadata
- Download URL: bloggerkit-0.6.0.tar.gz
- Upload date:
- Size: 5.6 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.6.2
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
9974cfc731e1dd9fa6d8d98b8b46bb2cc48f4c9f049836c4c16102603297208e
|
|
| MD5 |
88f72c1bce3664fadd08459334c7de4f
|
|
| BLAKE2b-256 |
c8f68810998b3d00c3ae29b96ab7bce2b4b119d74b8aa8e45f29434c86ccd844
|
File details
Details for the file bloggerkit-0.6.0-py3-none-any.whl.
File metadata
- Download URL: bloggerkit-0.6.0-py3-none-any.whl
- Upload date:
- Size: 5.8 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.6.2
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
0cb5621151893b2391741538748c26d16000d375475cabf57d7656701033a590
|
|
| MD5 |
553f95a0849ec99c59776939b6b892a5
|
|
| BLAKE2b-256 |
a2f1abdffba186ad46eefe63d44673ac43af1288c4959566ba5d06e38b35e8fe
|