A CLI tool for interacting with the Blogger API
Project description
Blogger CLI
A command-line interface for interacting with the Blogger API. This tool allows you to fetch posts, pages, and other data from your Blogger blog using Google's official API.
Features
- Fetch posts and pages from your Blogger blog
- Export data to JSON
- Run tests to verify API access and configuration
Getting Started
1. Create config.json
The CLI requires a config.json file for authentication and configuration. Create it according to the following structure:
{
"api_key": "YOUR_GOOGLE_API_KEY",
"blog_id": "YOUR_BLOG_ID",
"base_url": "https://www.googleapis.com/blogger/v3",
"user_id": "self",
"blog_url": "https://yourblog.blogspot.com/"
}
api_key: Your Google API key (see below for instructions)blog_id: The numeric ID of your Blogger blog. To find your blog ID:- Go to Blogger and sign in.
- Select your blog.
- Look at the URL in your browser's address bar. It will look like:
https://www.blogger.com/blog/posts/XXXXXXXXXXXXXXXThe long number (XXXXXXXXXXXXXXX) is your blog ID. - Alternatively, you can find your blog ID in the Blogger dashboard under Settings > Basic > Blog ID.
base_url: (optional) The Blogger API base URL, usuallyhttps://www.googleapis.com/blogger/v3user_id: (optional) Useselffor accessing your own blogblog_url: (optional) The public URL of your blog
2. How to Get a Google API Key
To use the Blogger CLI, you need a Google API key with access to the Blogger API. Follow these steps:
- Go to the Google Cloud Console.
- Create a new project (or select an existing one).
- In the left sidebar, navigate to APIs & Services > Library.
- Search for "Blogger API v3" and click Enable.
- Go to APIs & Services > Credentials.
- Click Create credentials and select API key.
- Copy the generated API key.
- Paste the API key into your
config.jsonfile under theapi_keyfield.
You may restrict the API key to specific referrers or IP addresses for security, but for development, you can leave it unrestricted. Make sure the API key is enabled for the Blogger API in your project.
Note: The API key provided in this project is approved for read-only access. You can only fetch data, not modify it. For write access, you must request additional permissions from Google.
3. Usage
Run the CLI using:
python -m blogger_api_cli [OPTIONS]
Main Options
-b,--blogger: Run Blogger API test-p,--permission: Run Blogger API permission test-x,--xml-to-json: Convert XML blog backup entries to JSON--export-posts: Export posts via Blogger API--export-pages: Export pages via Blogger API--search QUERY: Search for posts in the blog--get-blog: Retrieve blog information using ID/URL from config.json
Additional Arguments
-
--post-id,--pid: Post ID for testing -
--page-id,--pgid: Page ID for testing -
-c,--comment-id: Comment ID for testing -
-u,--user-id: User ID for testing -
--test-post-title,-pt: Title for test posts (default: "Test Post") -
--test-page-title,-pg: Title for test pages (default: "Test Page") -
-t,--test-content: Content for test posts/pages (default: "This is test content") -
-f,--xml-file: Path to the XML blog backup file (required for XML to JSON conversion) -
--posts-json,-pj: Path to save posts JSON -
--pages-json,-gj: Path to save pages JSON -
--config-file,-cf: Path to the config file -
-o,--output: Path to save the exported data -
--max-results: Maximum number of results to return for search (default: 10) -
--include-drafts,-d: Include draft posts and pages in the JSON output (for XML to JSON)
Example Commands
- Run Blogger API test:
python -m blogger_api_cli -b
- Run permission test:
python -m blogger_api_cli -p
- Convert XML to JSON:
python -m blogger_api_cli -x -f path/to/blog-export.xml --include-drafts
- Export posts:
python -m blogger_api_cli --export-posts -o my-posts.json
- Search for posts:
python -m blogger_api_cli --search "query" --max-results 20
- Get blog info:
python -m blogger_api_cli --get-blog -o blog-info.json
Refer to the code or use --help for more details on all options.
Troubleshooting
- Ensure your
config.jsonis present and correctly formatted - Make sure your API key has access to the Blogger API
- For write access, you must request additional permissions from Google
License
MIT
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 blogger_api_cli-0.2.1.tar.gz.
File metadata
- Download URL: blogger_api_cli-0.2.1.tar.gz
- Upload date:
- Size: 15.4 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.12.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
d58b2002116806ff9226cf625ac74b492b4095b66dce203b455f75b89c84a8a6
|
|
| MD5 |
e166c84a55d47d414fb8a2c8dafa3836
|
|
| BLAKE2b-256 |
f45911978e9cf15aa19fd1578a5b819c3ec11b90215dfe051a596fd9f6ae8f17
|
Provenance
The following attestation bundles were made for blogger_api_cli-0.2.1.tar.gz:
Publisher:
python-publish-cli.yml on Asura-Codes/spa-on-blogger-api
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
blogger_api_cli-0.2.1.tar.gz -
Subject digest:
d58b2002116806ff9226cf625ac74b492b4095b66dce203b455f75b89c84a8a6 - Sigstore transparency entry: 273062501
- Sigstore integration time:
-
Permalink:
Asura-Codes/spa-on-blogger-api@664add34301a539cd327730ff8566ca565b597a0 -
Branch / Tag:
refs/heads/main - Owner: https://github.com/Asura-Codes
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
python-publish-cli.yml@664add34301a539cd327730ff8566ca565b597a0 -
Trigger Event:
workflow_dispatch
-
Statement type:
File details
Details for the file blogger_api_cli-0.2.1-py3-none-any.whl.
File metadata
- Download URL: blogger_api_cli-0.2.1-py3-none-any.whl
- Upload date:
- Size: 16.9 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.12.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
62661730d75797ac083ea4b2ec50ba9ec053b4bd80b29eb204ecb694fdf1efff
|
|
| MD5 |
1c5836229d85929ec63d83089c5c90a7
|
|
| BLAKE2b-256 |
59728b023ad697d5c1b8fcfba8ec6ed20079b790f62e3eba314f08095ce2b8d9
|
Provenance
The following attestation bundles were made for blogger_api_cli-0.2.1-py3-none-any.whl:
Publisher:
python-publish-cli.yml on Asura-Codes/spa-on-blogger-api
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
blogger_api_cli-0.2.1-py3-none-any.whl -
Subject digest:
62661730d75797ac083ea4b2ec50ba9ec053b4bd80b29eb204ecb694fdf1efff - Sigstore transparency entry: 273062504
- Sigstore integration time:
-
Permalink:
Asura-Codes/spa-on-blogger-api@664add34301a539cd327730ff8566ca565b597a0 -
Branch / Tag:
refs/heads/main - Owner: https://github.com/Asura-Codes
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
python-publish-cli.yml@664add34301a539cd327730ff8566ca565b597a0 -
Trigger Event:
workflow_dispatch
-
Statement type: