| Name | memberful JSON |
| Version |
0.1.0
JSON |
| download |
| home_page | None |
| Summary | Memberful service Python client for webhooks and API |
| upload_time | 2025-09-09 04:19:07 |
| maintainer | Michael Kennedy |
| docs_url | None |
| author | Michael Kennedy |
| requires_python | >=3.10 |
| license | MIT License Copyright (c) 2025 Michael Kennedy Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. |
| keywords |
api
memberful
membership
subscription
webhooks
|
| VCS |
 |
| bugtrack_url |
|
| requirements |
No requirements were recorded.
|
| Travis-CI |
No Travis.
|
| coveralls test coverage |
No coveralls.
|
# Memberful Python SDK
[](https://www.python.org/downloads/)
[](https://opensource.org/licenses/MIT)
[](https://docs.pydantic.dev/)
A modern, type-safe Python SDK for integrating with [Memberful](https://memberful.com)'s API and webhooks. Built with Pydantic models for comprehensive type hints and runtime validation.
## โจ Key Features
- **๐ Type Safety**: Full Pydantic model coverage for all API responses and webhook events
- **๐ Async First**: Built on `httpx` for high-performance async operations
- **โก GraphQL Powered**: Efficient data fetching with Memberful's GraphQL API
- **๐ Resilient**: Smart retry logic with exponential backoff handles network hiccups and rate limits automatically
- **๐ Auto-Complete Heaven**: Comprehensive type hints mean your IDE knows exactly what's available
- **๐ฏ Zero Guesswork**: No more digging through API docs to figure out response formats
- **๐ช Webhook Support**: Parse and validate webhook events with confidence
- **๐ Rich Documentation**: Detailed examples and comprehensive API documentation
- **๐งช Battle-Tested**: Extensive test suite ensures reliability
- **๐ Modern Python**: Supports Python 3.10+ with all the latest features
## ๐ฆ Installation
```bash
uv pip install memberful
```
Or with uv project management:
```bash
uv add memberful
```
## ๐ Quick Start
### API Client
```python
from memberful.api import MemberfulClient
# Initialize the client
async with MemberfulClient(api_key="YOUR_API_KEY") as client:
# Get all members with full type safety
members = await client.get_all_members()
for member in members:
print(f"{member.full_name} - {member.email}")
# Your IDE provides auto-complete for all attributes!
if member.subscriptions:
active_subs = [s for s in member.subscriptions if s.active]
print(f" Active subscriptions: {len(active_subs)}")
```
### Webhook Handling
```python
from memberful.webhooks import (
parse_payload,
validate_signature,
MemberSignupEvent,
SubscriptionCreatedEvent
)
import json
def handle_webhook(request_body: str, signature_header: str, webhook_secret: str):
# Verify the webhook signature
if not validate_signature(
payload=request_body,
signature=signature_header,
secret_key=webhook_secret
):
raise ValueError("Invalid webhook signature")
# Parse the event with full type safety
event = parse_payload(json.loads(request_body))
# Handle different event types with isinstance checks
match event:
case MemberSignupEvent():
print(f"New member: {event.member.email}")
case SubscriptionCreatedEvent():
print(f"New subscription for: {event.member.email}")
case _:
print(f"Received {event.event} event")
```
## ๐ Documentation
### Comprehensive Guides
- **[API Documentation](reference/api.md)** - Complete guide to using the API client with examples
- **[Webhook Documentation](reference/webhooks.md)** - Detailed webhook event reference and handling guide
### Quick Examples
Check out the [examples directory](examples/) for ready-to-run code:
- [Basic API Usage](examples/basic_api_usage.py) - Simple examples to get started
- [Webhook Usage](examples/basic_webhook_usage.py) - Webhook handling patterns
- [Webhook Parsing](examples/webhook_parsing.py) - Detailed webhook parsing examples
- [FastAPI Integration](examples/fastapi_webhook_example/) - Complete FastAPI webhook server
## ๐ ๏ธ Core Features
### API Client Capabilities
- โ
Fetch members (individual, paginated, or all)
- โ
Retrieve subscriptions with full plan details
- โ
Automatic pagination handling
- โ
**Smart retry logic** with exponential backoff (3 attempts, handles network errors)
- โ
Configurable timeouts and retries
- โ
Type-safe responses with Pydantic models
- โ
Comprehensive error handling
### Webhook Features
- โ
Type-safe parsing of all webhook event types
- โ
Automatic signature verification
- โ
Support for all 16 Memberful webhook events:
- **Member events**: signup, updated, deleted
- **Subscription events**: created, updated, activated, deleted, renewed
- **Order events**: completed, suspended
- **Plan events**: created, updated, deleted
- **Download events**: created, updated, deleted
- โ
Pydantic models for each event type
- โ
Helper functions for event handling
## ๐๏ธ Architecture
This SDK is built with modern Python best practices:
- **GraphQL API** - leverages Memberful's GraphQL endpoint for efficient data fetching
- **Async/await** for efficient I/O operations
- **Pydantic v2** for fast data validation and serialization
- **Type hints** throughout for better IDE support
- **Minimal dependencies** - just `httpx`, `pydantic`, and `stamina` for resilient retries
- **100% test coverage** for reliability
## ๐งช Testing
The SDK includes a comprehensive test suite. Run tests with:
```bash
# Install dev dependencies
uv pip install -e ".[dev]"
# Run tests
pytest
# Run with coverage
pytest --cov=memberful
```
## ๐ค Contributing
We love contributions! If you've found a bug or have a feature request:
1. **Check existing issues** first to avoid duplicates
2. **Open an issue** to discuss the change
3. **Submit a PR** with your improvements
### Development Setup
```bash
# Clone the repo
git clone https://github.com/mikeckennedy/memberful.git
cd memberful
# Create virtual environment
python -m venv venv
source venv/bin/activate # On Windows: venv\Scripts\activate
# Install in development mode
uv pip install -e ".[dev]"
# Run tests
pytest
# Format code
ruff format
# Run linter
ruff check
```
## ๐ Project Status
This SDK is under active development and currently supports:
- โ
Member operations (read)
- โ
Subscription operations (read)
- โ
All webhook event types
- โ
Signature verification
- โณ Member operations (create/update) - coming soon
- โ
GraphQL API integration with automatic retries
## ๐ License
This project is licensed under the MIT License - see the [LICENSE](LICENSE) file for details.
## ๐ Acknowledgments
- Built with โค๏ธ for the [Memberful](https://memberful.com) community
- Inspired by modern Python SDK design patterns
- Special thanks to all contributors
## ๐ฌ Support
- ๐ [Read the documentation](reference/)
- ๐ [Report bugs](https://github.com/mikeckennedy/memberful/issues)
- ๐ก [Request features](https://github.com/mikeckennedy/memberful/issues)
- ๐ฌ [Discussions](https://github.com/mikeckennedy/memberful/discussions)
---
**Ready to integrate Memberful into your Python application? [Get started now!](#-quick-start)**
Raw data
{
"_id": null,
"home_page": null,
"name": "memberful",
"maintainer": "Michael Kennedy",
"docs_url": null,
"requires_python": ">=3.10",
"maintainer_email": null,
"keywords": "api, memberful, membership, subscription, webhooks",
"author": "Michael Kennedy",
"author_email": null,
"download_url": "https://files.pythonhosted.org/packages/57/12/ccad8c2e3b1e7d910d793dec1863930bc4fb2a2a2e3de8c34ab9137b8ce0/memberful-0.1.0.tar.gz",
"platform": null,
"description": "# Memberful Python SDK\n\n[](https://www.python.org/downloads/)\n[](https://opensource.org/licenses/MIT)\n[](https://docs.pydantic.dev/)\n\nA modern, type-safe Python SDK for integrating with [Memberful](https://memberful.com)'s API and webhooks. Built with Pydantic models for comprehensive type hints and runtime validation.\n\n## \u2728 Key Features\n\n- **\ud83d\udd12 Type Safety**: Full Pydantic model coverage for all API responses and webhook events\n- **\ud83d\ude80 Async First**: Built on `httpx` for high-performance async operations\n- **\u26a1 GraphQL Powered**: Efficient data fetching with Memberful's GraphQL API\n- **\ud83d\udd04 Resilient**: Smart retry logic with exponential backoff handles network hiccups and rate limits automatically\n- **\ud83d\udcdd Auto-Complete Heaven**: Comprehensive type hints mean your IDE knows exactly what's available\n- **\ud83c\udfaf Zero Guesswork**: No more digging through API docs to figure out response formats\n- **\ud83e\ude9d Webhook Support**: Parse and validate webhook events with confidence\n- **\ud83d\udcda Rich Documentation**: Detailed examples and comprehensive API documentation\n- **\ud83e\uddea Battle-Tested**: Extensive test suite ensures reliability\n- **\ud83d\udc0d Modern Python**: Supports Python 3.10+ with all the latest features\n\n## \ud83d\udce6 Installation\n\n```bash\nuv pip install memberful\n```\n\nOr with uv project management:\n\n```bash\nuv add memberful\n```\n\n## \ud83d\ude80 Quick Start\n\n### API Client\n\n```python\nfrom memberful.api import MemberfulClient\n\n# Initialize the client\nasync with MemberfulClient(api_key=\"YOUR_API_KEY\") as client:\n # Get all members with full type safety\n members = await client.get_all_members()\n \n for member in members:\n print(f\"{member.full_name} - {member.email}\")\n \n # Your IDE provides auto-complete for all attributes!\n if member.subscriptions:\n active_subs = [s for s in member.subscriptions if s.active]\n print(f\" Active subscriptions: {len(active_subs)}\")\n```\n\n### Webhook Handling\n\n```python\nfrom memberful.webhooks import (\n parse_payload, \n validate_signature,\n MemberSignupEvent,\n SubscriptionCreatedEvent\n)\nimport json\n\ndef handle_webhook(request_body: str, signature_header: str, webhook_secret: str):\n # Verify the webhook signature\n if not validate_signature(\n payload=request_body,\n signature=signature_header,\n secret_key=webhook_secret\n ):\n raise ValueError(\"Invalid webhook signature\")\n \n # Parse the event with full type safety\n event = parse_payload(json.loads(request_body))\n \n # Handle different event types with isinstance checks\n match event:\n case MemberSignupEvent():\n print(f\"New member: {event.member.email}\")\n case SubscriptionCreatedEvent():\n print(f\"New subscription for: {event.member.email}\")\n case _:\n print(f\"Received {event.event} event\")\n```\n\n## \ud83d\udcd6 Documentation\n\n### Comprehensive Guides\n\n- **[API Documentation](reference/api.md)** - Complete guide to using the API client with examples\n- **[Webhook Documentation](reference/webhooks.md)** - Detailed webhook event reference and handling guide\n\n### Quick Examples\n\nCheck out the [examples directory](examples/) for ready-to-run code:\n- [Basic API Usage](examples/basic_api_usage.py) - Simple examples to get started\n- [Webhook Usage](examples/basic_webhook_usage.py) - Webhook handling patterns\n- [Webhook Parsing](examples/webhook_parsing.py) - Detailed webhook parsing examples\n- [FastAPI Integration](examples/fastapi_webhook_example/) - Complete FastAPI webhook server\n\n## \ud83d\udee0\ufe0f Core Features\n\n### API Client Capabilities\n\n- \u2705 Fetch members (individual, paginated, or all)\n- \u2705 Retrieve subscriptions with full plan details\n- \u2705 Automatic pagination handling\n- \u2705 **Smart retry logic** with exponential backoff (3 attempts, handles network errors)\n- \u2705 Configurable timeouts and retries\n- \u2705 Type-safe responses with Pydantic models\n- \u2705 Comprehensive error handling\n\n### Webhook Features\n\n- \u2705 Type-safe parsing of all webhook event types\n- \u2705 Automatic signature verification\n- \u2705 Support for all 16 Memberful webhook events:\n - **Member events**: signup, updated, deleted\n - **Subscription events**: created, updated, activated, deleted, renewed\n - **Order events**: completed, suspended\n - **Plan events**: created, updated, deleted\n - **Download events**: created, updated, deleted\n- \u2705 Pydantic models for each event type\n- \u2705 Helper functions for event handling\n\n## \ud83c\udfd7\ufe0f Architecture\n\nThis SDK is built with modern Python best practices:\n\n- **GraphQL API** - leverages Memberful's GraphQL endpoint for efficient data fetching\n- **Async/await** for efficient I/O operations\n- **Pydantic v2** for fast data validation and serialization\n- **Type hints** throughout for better IDE support\n- **Minimal dependencies** - just `httpx`, `pydantic`, and `stamina` for resilient retries\n- **100% test coverage** for reliability\n\n## \ud83e\uddea Testing\n\nThe SDK includes a comprehensive test suite. Run tests with:\n\n```bash\n# Install dev dependencies\nuv pip install -e \".[dev]\"\n\n# Run tests\npytest\n\n# Run with coverage\npytest --cov=memberful\n```\n\n## \ud83e\udd1d Contributing\n\nWe love contributions! If you've found a bug or have a feature request:\n\n1. **Check existing issues** first to avoid duplicates\n2. **Open an issue** to discuss the change\n3. **Submit a PR** with your improvements\n\n### Development Setup\n\n```bash\n# Clone the repo\ngit clone https://github.com/mikeckennedy/memberful.git\ncd memberful\n\n# Create virtual environment\npython -m venv venv\nsource venv/bin/activate # On Windows: venv\\Scripts\\activate\n\n# Install in development mode\nuv pip install -e \".[dev]\"\n\n# Run tests\npytest\n\n# Format code\nruff format\n\n# Run linter\nruff check\n```\n\n## \ud83d\udcca Project Status\n\nThis SDK is under active development and currently supports:\n\n- \u2705 Member operations (read)\n- \u2705 Subscription operations (read)\n- \u2705 All webhook event types\n- \u2705 Signature verification\n- \u23f3 Member operations (create/update) - coming soon\n- \u2705 GraphQL API integration with automatic retries\n\n## \ud83d\udcc4 License\n\nThis project is licensed under the MIT License - see the [LICENSE](LICENSE) file for details.\n\n## \ud83d\ude4f Acknowledgments\n\n- Built with \u2764\ufe0f for the [Memberful](https://memberful.com) community\n- Inspired by modern Python SDK design patterns\n- Special thanks to all contributors\n\n## \ud83d\udcec Support\n\n- \ud83d\udcd6 [Read the documentation](reference/)\n- \ud83d\udc1b [Report bugs](https://github.com/mikeckennedy/memberful/issues)\n- \ud83d\udca1 [Request features](https://github.com/mikeckennedy/memberful/issues)\n- \ud83d\udcac [Discussions](https://github.com/mikeckennedy/memberful/discussions)\n\n---\n\n**Ready to integrate Memberful into your Python application? [Get started now!](#-quick-start)**\n",
"bugtrack_url": null,
"license": "MIT License Copyright (c) 2025 Michael Kennedy Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the \"Software\"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.",
"summary": "Memberful service Python client for webhooks and API",
"version": "0.1.0",
"project_urls": {
"Changelog": "https://github.com/mikeckennedy/memberful/blob/main/CHANGELOG.md",
"Homepage": "https://github.com/mikeckennedy/memberful",
"Issues": "https://github.com/mikeckennedy/memberful/issues",
"Repository": "https://github.com/mikeckennedy/memberful.git"
},
"split_keywords": [
"api",
" memberful",
" membership",
" subscription",
" webhooks"
],
"urls": [
{
"comment_text": null,
"digests": {
"blake2b_256": "cf7ec6c992a2a303da1684258a88d93f6e06016eb097dc658d49a880809673ff",
"md5": "bb0344bee1397486b6354eea2d5654e3",
"sha256": "cb96032f8019d4ef9a17f270a2123b5f4b6a1f8b9b9dbbe5d6f53766417bacbc"
},
"downloads": -1,
"filename": "memberful-0.1.0-py3-none-any.whl",
"has_sig": false,
"md5_digest": "bb0344bee1397486b6354eea2d5654e3",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": ">=3.10",
"size": 15822,
"upload_time": "2025-09-09T04:19:05",
"upload_time_iso_8601": "2025-09-09T04:19:05.732124Z",
"url": "https://files.pythonhosted.org/packages/cf/7e/c6c992a2a303da1684258a88d93f6e06016eb097dc658d49a880809673ff/memberful-0.1.0-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": null,
"digests": {
"blake2b_256": "5712ccad8c2e3b1e7d910d793dec1863930bc4fb2a2a2e3de8c34ab9137b8ce0",
"md5": "042c3e1b5728034a0f307f3a2ae15678",
"sha256": "42806a08888000e5f7691c8fc6da42a51d26fb1fc1529b8a38ea1615660d0ec5"
},
"downloads": -1,
"filename": "memberful-0.1.0.tar.gz",
"has_sig": false,
"md5_digest": "042c3e1b5728034a0f307f3a2ae15678",
"packagetype": "sdist",
"python_version": "source",
"requires_python": ">=3.10",
"size": 14316,
"upload_time": "2025-09-09T04:19:07",
"upload_time_iso_8601": "2025-09-09T04:19:07.053396Z",
"url": "https://files.pythonhosted.org/packages/57/12/ccad8c2e3b1e7d910d793dec1863930bc4fb2a2a2e3de8c34ab9137b8ce0/memberful-0.1.0.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2025-09-09 04:19:07",
"github": true,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"github_user": "mikeckennedy",
"github_project": "memberful",
"travis_ci": false,
"coveralls": false,
"github_actions": false,
"lcname": "memberful"
}