Python SDK for AdsOverAI - Native advertising for AI chat interfaces
Features
- 🎯 Context-Aware Ads - Display relevant ads based on AI conversation context
- ⚡ Fast & Lightweight - Optimized for performance with built-in caching
- 🔒 Type Safe - Full type hints and validation
- 🛡️ Error Handling - Comprehensive exception handling
- 🌙 Theme Support - Light, dark, and auto theme modes
- 📝 Logging - Debug mode with detailed logging
Installation
pip install adsoverai
Quick Start
from adsoverai import AdsOverAI
# Initialize the client
client = AdsOverAI(
api_key="your-api-key",
max_ads=3,
theme="auto"
)
# Fetch ads based on conversation context
ads = client.get_ads(
query="What are the best running shoes?",
response="Here are some great running shoe options..."
)
# Display ads
for ad in ads:
print(f"Title: {ad.title}")
print(f"Description: {ad.description}")
print(f"URL: {ad.url}")
print("---")
Convenience Function
from adsoverai import get_ads
ads = get_ads(
api_key="your-api-key",
query="best headphones",
response="Here are top-rated headphones...",
max_ads=2
)
API Reference
AdsOverAI
Main client class for the SDK.
Parameters
api_key(str, required): Your AdsOverAI API keymax_ads(int, default=3): Maximum number of ads to return (1-10)theme(str, default="auto"): Theme preference ("light", "dark", "auto")api_url(str): API endpoint URLdebug_mode(bool, default=False): Enable debug loggingtimeout(int, default=10): Request timeout in secondscache_ttl(int, default=300): Cache time-to-live in seconds
Methods
get_ads(query, response, max_ads=None, use_cache=True)
Fetch contextual ads based on conversation.
clear_cache()
Clear all cached results.
update_config(max_ads=None, theme=None, debug_mode=None)
Update client configuration.
close()
Close the session and cleanup resources.
AdResult
Data class representing an ad result.
Attributes
title(str): Ad titledescription(str): Ad descriptionurl(str): Ad URLimage_url(str, optional): Ad image URLadvertiser(str, optional): Advertiser namecta_text(str): Call-to-action textmetadata(dict): Additional metadata
Advanced Usage
Context Manager
with AdsOverAI(api_key="your-key") as client:
ads = client.get_ads(query="...", response="...")
for ad in ads:
print(ad.title)
# Session automatically closed
Error Handling
from adsoverai import AdsOverAI, AuthenticationError, APIError
try:
client = AdsOverAI(api_key="your-key")
ads = client.get_ads(query="...", response="...")
except AuthenticationError:
print("Invalid API key")
except APIError as e:
print(f"API error: {e}")
Debug Mode
client = AdsOverAI(
api_key="your-key",
debug_mode=True # Enable detailed logging
)
Cache Control
# Disable cache for a specific request
ads = client.get_ads(
query="...",
response="...",
use_cache=False
)
# Clear all cached results
client.clear_cache()
Examples
See the examples/ directory for more usage examples:
basic_usage.py- Simple usage exampleadvanced_usage.py- Advanced featuresdjango_integration.py- Django integration example
Development
Setup
git clone https://github.com/adsoverai/python-sdk.git
cd python-sdk
pip install -e ".[dev]"
Run Tests
pytest
Code Formatting
black adsoverai/ tests/
flake8 adsoverai/ tests/
mypy adsoverai/
Support
- 📧 Email: hello@adsoverai.com
- 🌐 Website: https://www.adsoverai.com
- 📚 Documentation: https://docs.adsoverai.com
- 🐛 Issues: https://github.com/adsoverai/python-sdk/issues
License
MIT © AdsOverAI Team
Metadata
Release files for adsoverai 1.0.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | |
|---|---|---|---|---|
| adsoverai-1.0.0.tar.gz | 13.2 kB | Without provenance | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| adsoverai-1.0.0-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 17.2 kB
Release files / adsoverai-1.0.0.tar.gz
| Download URL | adsoverai-1.0.0.tar.gz |
|---|---|
| Size | 13.2 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
377fb18fd874373925d8406f6c67106d3deedce41865934427f3d911b56015e9
|
|
BLAKE2b-256 checksum How to use checksums |
7c70a71be3c74a224dfbe4bd8d8b14f08bb7e41a1290b54aa16418af66560cdc
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.13.7
|
Release files / adsoverai-1.0.0-py3-none-any.whl
| Download URL | adsoverai-1.0.0-py3-none-any.whl |
|---|---|
| Size | 4.0 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
65c476143ea8c037e5f6c891abdf33a724c6000a5589b1b8ac4251135d7ed62c
|
|
BLAKE2b-256 checksum How to use checksums |
fb2a091f96deda2b8b084ad8c365f64053db4bcf9eee32d0a910344199a055b9
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.13.7
|
Security for adsoverai 1.0.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.