Pax8 API Manager is a Python project designed to integrate with the Pax8 subscription management API. It handles authentication via OAuth2, retrieves company, product, and subscription details, and allows you to update subscriptions as needed. This project is structured to provide a clean, modular, and scalable codebase.
.
├── app
│ ├── enums
│ │ └── BillingTerm.py
│ ├── manager
│ │ ├── __init__.py
│ │ ├── Pax8Manager.py
│ │ └── pax8_manager.py
│ ├── models
│ │ ├── request
│ │ │ └── SubscriptionRequest.py
│ │ └── response
│ │ ├── __init__.py
│ │ ├── company_response.py
│ │ ├── error_response.py
│ │ ├── page_response.py
│ │ ├── product_response.py
│ │ ├── response.py
│ │ ├── subscription_response.py
│ │ └── token_response.py
│ └── settings
│ ├── __init__.py
│ └── pax8_settings.py
├── tests
│ ├── __init__.py
│ ├── test_manager.py
│ ├── test_settings.py
│ └── test_token.py
├── venv
│ └── .env
├── .gitignore
├── main.py
├── README.md
└── requirements.txt
-
Clone the Repository
git clone https://github.com/your-username/pax8-api-manager.git cd pax8-api-manager -
Create a Virtual Environment Create an isolated Python environment:
python -m venv venv
Activate the virtual environment:
- On Windows:
venv\Scripts\activate
- On macOS/Linux:
source venv/bin/activate
- On Windows:
-
Install Dependencies Install the required packages:
pip install -r requirements.txt
-
Set Up Environment Variables Create a
.envfile (you can place it at the project root or inside your virtual environment directory) with the following contents:PAX8_AUDIENCE=api://p8p.client PAX8_BASE_URL=https://api.pax8.com/v1 PAX8_CLIENT_ID=your_client_id PAX8_CLIENT_SECRET=your_client_secret PAX8_GRANT_TYPE=client_credentials
Replace
your_client_idandyour_client_secretwith your actual credentials.
The main application is run via the main.py file. This file initializes the Pax8Manager, handles token authentication, retrieves company details, and fetches all subscriptions for a given company.
To run the application:
python main.pyInside main.py, you’ll find an example code on how to use the manager.
Tests are located in the tests directory and use pytest as the testing framework. To run the tests, execute:
pytestThis command will discover and run all test files (e.g., test_manager.py, test_settings.py, test_token.py).
Contributions are welcome. Follow these steps to contribute:
- Fork the Repository
- Create a New Branch
git checkout -b feature/your-feature-name
- Commit Your Changes
git commit -am "Description of your changes" - Push to the Branch
git push origin feature/your-feature-name
- Create a Pull Request Provide a clear description of your changes and reference any related issues.
This project is licensed under the MIT License. See the LICENSE file for details.
Happy coding!