Skip to main content

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_USERNAME
  • MYWEBLOG_PASSWORD
  • APP_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.

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

  1. Clone the repository:

    git clone https://github.com/faanskit/pyMyweblog.git
    cd pyMyweblog
    
  2. Create and activate a virtual environment:

    python -m venv venv
    # On Unix/macOS:
    source venv/bin/activate
    # On Windows:
    .\venv\Scripts\activate
    
  3. Install dependencies:

    pip install -e .[dev]
    
  4. Format and lint your code:

    black .
    flake8 .
    
  5. 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 MyWebLogClient for additional API endpoints as needed.
  • The CLI utility is in scripts/myweblog.py and 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:

  1. Update the version in pyproject.toml
    Use a development version (ending in .devN), for example:

    version = "0.2.0.dev1"
    
  2. 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
    
  3. 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:

  1. Update the version in pyproject.toml, for example:

    version = "0.2.0"
    
  2. Commit and push:

    git add pyproject.toml
    git commit -m "release 0.2.0"
    git push origin main
    
  3. 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"
  4. 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:

  • TEST_PYPI_API_TOKEN – from TestPyPI
  • PYPI_API_TOKEN – from PyPI

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


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

pymyweblog-0.5.0.tar.gz (12.1 kB view details)

Uploaded Source

Built Distribution

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

pymyweblog-0.5.0-py3-none-any.whl (8.2 kB view details)

Uploaded Python 3

File details

Details for the file pymyweblog-0.5.0.tar.gz.

File metadata

  • Download URL: pymyweblog-0.5.0.tar.gz
  • Upload date:
  • Size: 12.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.12.9

File hashes

Hashes for pymyweblog-0.5.0.tar.gz
Algorithm Hash digest
SHA256 3f19d163c55ea77716d8a9b2f07d7f6e6e2a5e379354df0599b08a7a221eab5d
MD5 7fa08102f44972a97a9849ae6a0f3b18
BLAKE2b-256 207f45863f47163a736e392a4e1953cee3b98cfa92b3a74024f2f6b294418c1f

See more details on using hashes here.

File details

Details for the file pymyweblog-0.5.0-py3-none-any.whl.

File metadata

  • Download URL: pymyweblog-0.5.0-py3-none-any.whl
  • Upload date:
  • Size: 8.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.12.9

File hashes

Hashes for pymyweblog-0.5.0-py3-none-any.whl
Algorithm Hash digest
SHA256 426015d2855a847a7dc7fe8440b51b10d56736c269e04c285f450270e1e00637
MD5 f274d82d2094781e71f69b85dbc20a2e
BLAKE2b-256 31cabec8fcac7f275da39547fce860a7e55ec6ad3f3813c77fa75fd793bf8c4d

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