Skip to main content

Python library for Alby Wallet API

Project description

pyalby

A python library of methods for accessing Alby Wallet API.

Contributors Forks Issues MIT License

Table of Contents
  1. About The Project
  2. Getting Started
  3. Roadmap
  4. Contributing
  5. License
  6. Contact

About The Project

The python library pyalby contains methods for accessing Alby Wallet API. The main purpose of this library is to provide a simple way to interact with the Alby API when using python.

Note: Custodial Wallets are not recommended for the use of storing large amounts. This library is for experimental purposes in the area of micro-payments. Use it at your own risk. This library is not a replacement for the official Alby API documentation. It is recommended to read the official documentation before using this library.

Getting Started

Clone the repo

Requires Python 3.10 or 3.11

git clone https://github.com/f418me/pyalby.git
cd pyalby
python3 -m venv venv
source venv/bin/activate
pip install -r requirements.txt
pip install -e .

Library Installation

pip install pyalby

Alby Access Token

You need an alby account and generate an access token to use the API. Copy .env-example to .env and update the variables with your Alby token. Or just set the environment variable ALBY_ACCESS_TOKEN.

BASE_URL = https://api.getalby.com
ALBY_ACCESS_TOKEN = XYZ
LOG_LEVEL = INFO

Usage

After the import of pyalby you can access the complete API using the related methods. In the tests folder you find all examples of the usage of the library.

from pyalby import Account, Invoice, Payment
import logging
import os

# Load environment variables
load_dotenv()

def main():
   
   account = Account()
   invoice = Invoice()
   payment = Payment()

   logging.basicConfig(format='%(asctime)s - %(levelname)s - %(message)s', level=str(os.getenv("LOG_LEVEL")))

   # Fetch account summary
   summary_data = account.get_account_summary()
   print("Account Summary:", summary_data)

   # Create an invoice
   inv = invoice.create_invoice(amount=100, description="Alby Test Invoice")
   print("Invoice created successfully")
   print(inv)

   # Pay an invoice
   pay = payment.bolt11_payment("lnbc110n1pn...")
   print(pay)


if __name__ == "__main__":
   main()

Roadmap

  • Add Webhook API
  • Add GitHub Docs pages
  • Add Support of async requests
  • CI pipeline
  • Add OAuth2 support
  • Add Python 3.12 support

See the open issues for a full list of proposed features (and known issues).

Contributing

Contributions are what make the open source community such an amazing place to learn, inspire, and create. Any contributions you make are greatly appreciated.

If you have a suggestion that would make this better, please fork the repo and create a pull request. You can also simply open an issue with the tag "enhancement".

  1. Fork the Project
  2. Create your Feature Branch (git checkout -b feature/AmazingFeature)
  3. Commit your Changes (git commit -m 'Add some AmazingFeature')
  4. Push to the Branch (git push origin feature/AmazingFeature)
  5. Open a Pull Request

Other

Be aware that the integration tests send real keysend payments.

License

The projec pyalby is released under the terms of the MIT license. See https://opensource.org/licenses/MIT for further information.

Contact

[f418.me](https://f418_me - Twitter - info@f418.me

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

pyalby-0.0.1.tar.gz (9.7 kB view hashes)

Uploaded Source

Built Distribution

pyalby-0.0.1-py3-none-any.whl (9.2 kB view hashes)

Uploaded Python 3

Supported by

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