Connect to any API and receive webhooks with minimal code. Turn API docs into Python functions and handle incoming events easily.
Project description
🚀 Smart API Integrations
Connect to any API and receive webhooks with minimal code.
What This Package Does
Smart API Integrations eliminates boilerplate code for:
- API Integration - Connect to third-party APIs with simple function calls
- Webhook Handling - Process incoming events from external services
Before vs After
API Integration
Before Smart API Integrations:
import requests
import os
# Set up authentication
token = os.environ.get("GITHUB_TOKEN")
headers = {"Authorization": f"Bearer {token}"}
# Make the request
response = requests.get("https://api.github.com/users/octocat", headers=headers)
# Handle the response
if response.status_code == 200:
user = response.json()
print(f"User: {user['name']}")
else:
print(f"Error: {response.status_code}")
print(response.text)
After Smart API Integrations:
from smart_api_integrations import GithubAPIClient
# Create client (automatically uses GITHUB_TOKEN from environment)
github = GithubAPIClient()
# Make the request
user = github.get_user(username='octocat')
print(f"User: {user.data['name']}")
Webhook Handling
Before Smart API Integrations:
from flask import Flask, request, jsonify
import hmac
import hashlib
import os
app = Flask(__name__)
@app.route('/webhooks/stripe', methods=['POST'])
def stripe_webhook():
# Verify signature
signature = request.headers.get('Stripe-Signature')
secret = os.environ.get('STRIPE_WEBHOOK_SECRET')
if not signature or not secret:
return jsonify({"error": "Missing signature"}), 400
# Compute expected signature
payload = request.data
expected_sig = hmac.new(
secret.encode(),
payload,
hashlib.sha256
).hexdigest()
# Verify signature
if not hmac.compare_digest(expected_sig, signature):
return jsonify({"error": "Invalid signature"}), 401
# Process the event
event_data = request.json
event_type = event_data.get('type')
if event_type == 'payment_intent.succeeded':
# Handle payment success
amount = event_data['data']['object']['amount'] / 100
print(f"Payment received: ${amount}")
elif event_type == 'payment_intent.payment_failed':
# Handle payment failure
print("Payment failed")
return jsonify({"status": "success"})
if __name__ == '__main__':
app.run(port=5000)
After Smart API Integrations:
from flask import Flask
from smart_api_integrations.webhooks import smart_webhook_handler
from smart_api_integrations.frameworks.flask import register_webhook_routes
app = Flask(__name__)
@smart_webhook_handler('stripe', 'payment_intent.succeeded')
def handle_payment(event):
amount = event.payload['data']['object']['amount'] / 100
print(f"Payment received: ${amount}")
return {"status": "processed"}
@smart_webhook_handler('stripe', 'payment_intent.payment_failed')
def handle_payment_failure(event):
print("Payment failed")
return {"status": "handled"}
# Register all webhook routes
register_webhook_routes(app)
if __name__ == '__main__':
app.run(port=5000)
🚀 Quick Start
Installation
pip install smart-api-integrations
API Integration
from smart_api_integrations import UniversalAPIClient
# Create a client for any configured API provider
github = UniversalAPIClient('github') # Uses GITHUB_TOKEN from environment
# Call methods based on the provider's configuration
user = github.get_user(username='octocat')
print(f"User: {user.data['name']}")
Webhook Integration
from smart_api_integrations.webhooks import smart_webhook_handler
@smart_webhook_handler('stripe', 'payment_intent.succeeded')
def handle_payment(event):
amount = event.payload['data']['object']['amount'] / 100
print(f"Payment received: ${amount}")
return {"status": "processed"}
📚 Documentation
Getting Started
API Integration
Webhook Integration
Reference
Examples
🔧 Key Features
- ✅ Zero Boilerplate: Define endpoints once, use everywhere
- ✅ Type Safety: Full IDE support with generated type stubs
- ✅ Smart Parameters: Automatic handling of path/query/body parameters
- ✅ Framework Integration: Works with Flask, FastAPI, and Django
- ✅ Webhook Support: Easily handle incoming webhook events
- ✅ OpenAPI Support: Generate clients from API documentation
📄 License
MIT License - see LICENSE file for details.
Stop writing API boilerplate. Start building features. 🚀
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 smart_api_integrations-0.2.0.tar.gz.
File metadata
- Download URL: smart_api_integrations-0.2.0.tar.gz
- Upload date:
- Size: 119.0 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.12.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
971d44bdf87cc1edb39b82a2033f41274df29a4f5959808a182fe961b6f8b9f6
|
|
| MD5 |
9ba1e0f03884bda03bcf812e2b6f1d88
|
|
| BLAKE2b-256 |
aedba910ccb26d6ea855a03f977856048ac7d882f35568eeb0145c6c8188222a
|
Provenance
The following attestation bundles were made for smart_api_integrations-0.2.0.tar.gz:
Publisher:
python-publish.yml on behera116/smart-api-integrations
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
smart_api_integrations-0.2.0.tar.gz -
Subject digest:
971d44bdf87cc1edb39b82a2033f41274df29a4f5959808a182fe961b6f8b9f6 - Sigstore transparency entry: 247599101
- Sigstore integration time:
-
Permalink:
behera116/smart-api-integrations@d7eaa166b086d48035edf2cee36f65f04d958db5 -
Branch / Tag:
refs/tags/v0.2.1 - Owner: https://github.com/behera116
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
python-publish.yml@d7eaa166b086d48035edf2cee36f65f04d958db5 -
Trigger Event:
release
-
Statement type:
File details
Details for the file smart_api_integrations-0.2.0-py3-none-any.whl.
File metadata
- Download URL: smart_api_integrations-0.2.0-py3-none-any.whl
- Upload date:
- Size: 87.5 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.12.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
4bc78d1b62ea5b7aa895d926b66a59f86736c01242ee8d27049d5c8b0d72f965
|
|
| MD5 |
5d1e136074accdfa4004151a850f9d40
|
|
| BLAKE2b-256 |
be43b842a302ea78cd6532505cf01fcb4ccadbbd9b7ac4c712665cb04765712d
|
Provenance
The following attestation bundles were made for smart_api_integrations-0.2.0-py3-none-any.whl:
Publisher:
python-publish.yml on behera116/smart-api-integrations
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
smart_api_integrations-0.2.0-py3-none-any.whl -
Subject digest:
4bc78d1b62ea5b7aa895d926b66a59f86736c01242ee8d27049d5c8b0d72f965 - Sigstore transparency entry: 247599114
- Sigstore integration time:
-
Permalink:
behera116/smart-api-integrations@d7eaa166b086d48035edf2cee36f65f04d958db5 -
Branch / Tag:
refs/tags/v0.2.1 - Owner: https://github.com/behera116
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
python-publish.yml@d7eaa166b086d48035edf2cee36f65f04d958db5 -
Trigger Event:
release
-
Statement type: