A Python library for interacting with the MyWebLog API
Project description
pyMyweblog Python Library
pyMyweblog is a Python library for interacting with the MyWebLog API, designed to fetch objects and bookings for aviation-related data. It is intended for use in Home Assistant integrations or other Python applications requiring access to MyWebLog services.
Installation
Install the library via pip:
pip install pyMyweblog
Alternatively, for local development, clone the repository and install it in editable mode:
git clone https://github.com/faanskit/pyMyweblog.git
cd pyMyweblog
pip install -e .
Project Structure
pyMyweblog/— Main package, contains the API client (client.py).scripts/myweblog.py— Interactive CLI utility for querying MyWebLog API.tests/test_client.py— Unit tests for the API client.
Prerequisites
To use the library or CLI, you need:
- A valid MyWebLog username and password.
- A valid App Secret (not app_token) for the MyWebLog API.
Set these as environment variables:
MYWEBLOG_USERNAMEMYWEBLOG_PASSWORDAPP_SECRET
Usage
Interactive CLI Utility
You can use the interactive CLI to fetch objects, bookings, balance, transactions, and flight logs:
python -m scripts.myweblog
You will be prompted to select an operation and, for bookings, to select an airplane. Make sure the required environment variables are set or exported before running.
Booking CLI Utility (scripts/booking_cli.py)
This script provides an interactive command-line interface for managing airplane bookings via the MyWebLog API.
Features:
- View available airplanes
- Create new bookings with confirmation prompts
- Delete your own bookings with confirmation prompts
- User-friendly and structured output
How to Run:
python -m scripts.booking_cli
Requirements:
- Environment variables must be set:
MYWEBLOG_USERNAME,MYWEBLOG_PASSWORD,APP_SECRET - The
questionarypackage must be installed for interactive prompts:
pip install questionary
Usage Flow:
- On start, you will be welcomed and asked to select an airplane
- You can view, create, or delete bookings for the selected airplane
- All critical actions (creation/deletion) require confirmation before proceeding
- Exit the CLI at any time by selecting "Exit" from the menu
Library Usage: MyWebLogClient
You can also use the API client in your own Python code:
from pyMyweblog.client import MyWebLogClient
import asyncio
import os
async def main():
client = MyWebLogClient(
username=os.getenv("MYWEBLOG_USERNAME"),
password=os.getenv("MYWEBLOG_PASSWORD"),
app_token=None, # Will be fetched using APP_SECRET
)
await client.obtainAppToken(os.getenv("APP_SECRET"))
objects = await client.getObjects()
print(objects)
await client.close()
asyncio.run(main())
Testing
Unit tests are located in tests/test_client.py and use the unittest framework. To run all tests:
python -m unittest discover tests
You can also run a specific test file:
python -m unittest tests.test_client
Requirements
For development and running tests, install all dependencies (including test and CLI requirements):
pip install -e .[dev]
If you only want to use the CLI utility, you must also install questionary:
pip install questionary
Development
Setting Up the Development Environment
-
Clone the repository:
git clone https://github.com/faanskit/pyMyweblog.git cd pyMyweblog
-
Create and activate a virtual environment:
python -m venv venv # On Unix/macOS: source venv/bin/activate # On Windows: .\venv\Scripts\activate
-
Install dependencies:
pip install -e .[dev]
-
Format and lint your code:
black . flake8 .
-
Run unit tests:
python -m unittest discover tests
Modifying the Code
- The main API client is in
pyMyweblog/client.py. - Add or update methods in
MyWebLogClientfor additional API endpoints as needed. - The CLI utility is in
scripts/myweblog.pyand can be extended for more interactive features.
CI/CD and Publishing to PyPI and TestPyPI
This project uses GitHub Actions to automatically build and publish the package to TestPyPI and PyPI. Two separate workflows are configured:
🔁 Publishing to TestPyPI
This workflow runs on every push to main if the commit message contains [dev-release].
How to trigger a TestPyPI release:
-
Update the version in
pyproject.toml
Use a development version (ending in.devN), for example:version = "0.2.0.dev1"
-
Commit and push with a trigger message:
git add pyproject.toml git commit -m "test release 0.2.0.dev1 [dev-release]" git push origin main
-
The workflow will run and upload the package to:
https://test.pypi.org/project/pyMyweblog
🚀 Publishing to PyPI (Production)
This workflow runs only when a GitHub Release is published. Use this for stable releases (i.e., versions without .dev).
How to publish a production release:
-
Update the version in
pyproject.toml, for example:version = "0.2.0"
-
Commit and push:
git add pyproject.toml git commit -m "release 0.2.0" git push origin main
-
Create a GitHub Release:
- Go to Releases
- Click "Draft a new release"
- Tag:
v0.2.0 - Title/message:
Release 0.2.0 - Click "Publish release"
-
The workflow will run and upload the package to:
https://pypi.org/project/pyMyweblog
🔐 API Tokens
To enable publishing from CI/CD, you need to configure the following GitHub Secrets:
Add these under:
GitHub Repo → Settings → Secrets and variables → Actions → New repository secret
Contributing
Contributions are welcome! Please submit issues or pull requests to the GitHub repository.
License
This project is licensed under the MIT License. See the LICENSE file for details.
For support, contact the maintainer at [marcus.karlsson@usa.net].
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 pymyweblog-0.6.0.tar.gz.
File metadata
- Download URL: pymyweblog-0.6.0.tar.gz
- Upload date:
- Size: 16.0 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
5ec1554a9e436f5a6f3a9c5616388444020635add712fa5b86342b18533fdc6c
|
|
| MD5 |
aacd2271ddf687899641d2c0b52fd0cb
|
|
| BLAKE2b-256 |
532a567a6f647f9a7091a87aa3e09b898b82729ee50d7d913cff93019eb3834c
|
File details
Details for the file pymyweblog-0.6.0-py3-none-any.whl.
File metadata
- Download URL: pymyweblog-0.6.0-py3-none-any.whl
- Upload date:
- Size: 9.5 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
baf719527374ab974f9506638f2250787bdba5aa1b3b5e1bc6e07ff207931f85
|
|
| MD5 |
0c26bc9c72f3d2ff320052b0d48b0a25
|
|
| BLAKE2b-256 |
7330536cfdb66fbbd16acdec9195601901bd71cba4cfe57fc73909b785b53a61
|