Current collected state Current
Observed since 20 Oct, 19:54 UTC
No superseded metadata states collected. Unchanged observations do not create new revisions.
adsonai
Python SDK for AdsonAI contextual advertising platform
Python SDK for AdsonAI - AI-powered contextual advertising platform.
pip install adsonai-sdk
adsonai_)from adsonai_sdk import AdsonAI
# Initialize client
client = AdsonAI(api_key="your_adsonai_api_key")
# Get contextual ads
ads = client.get_contextual_ads("I need running shoes", max_ads=3)
# Display results
for ad in ads:
print(f"🏷️ {ad.brand_name} - {ad.product_name}")
print(f"💬 {ad.ad_text}")
print(f"💰 Bid: ${ad.bid_amount}")
if ad.landing_url:
print(f"🔗 {ad.landing_url}")
print()
client.close()
AdsonAI(api_key, base_url=None, timeout=30)Initialize the AdsonAI client.
Parameters:
api_key (str): Your AdsonAI API keybase_url (str, optional): Custom API base URLtimeout (int, optional): Request timeout in secondstest_connection()Test connection to the AdsonAI API.
Returns: bool - True if successful
get_contextual_ads(query, max_ads=3, context=None)Get contextual ads using AI matching.
Parameters:
query (str): User query or conversation contextmax_ads (int): Maximum ads to return (1-10)context (dict, optional): Additional context for matchingReturns: List[Ad] - List of matched ads
Properties:
id: Unique ad identifierbrand_name: Brand or company nameproduct_name: Product or service namedescription: Ad descriptionad_text: Display text for the adbid_amount: Bid amount in USDlanding_url: Landing page URL (optional)target_keywords: Target keywordsstatus: Ad statusfrom adsonai_sdk import AdsonAI, AuthenticationError, APIError, ValidationError
try:
client = AdsonAI(api_key="your_key")
ads = client.get_contextual_ads("search query")
except AuthenticationError:
print("Invalid API key")
except APIError as e:
print(f"API error: {e}")
except ValidationError as e:
print(f"Validation error: {e}")
with AdsonAI(api_key="your_key") as client:
ads = client.get_contextual_ads("smart home devices")
for ad in ads:
print(f"{ad.brand_name}: {ad.ad_text}")
from adsonai_sdk import get_ads
# Quick one-liner
ads = get_ads("your_key", "gaming laptop", max_ads=5)
def get_sponsored_suggestion(user_message):
try:
ads = get_ads(API_KEY, user_message, max_ads=1)
if ads:
ad = ads[0]
return f"💡 {ad.brand_name}: {ad.ad_text}"
except Exception:
pass
return None
# In your chatbot
user_input = "I need a new coffee maker"
suggestion = get_sponsored_suggestion(user_input)
if suggestion:
print(suggestion)
def show_sponsored_products(search_query):
with AdsonAI(api_key=API_KEY) as client:
ads = client.get_contextual_ads(search_query, max_ads=3)
print("🎯 Sponsored Products:")
for ad in ads:
print(f"• {ad.brand_name} - {ad.product_name}")
print(f" {ad.ad_text}")
print(f" ${ad.bid_amount} | {ad.landing_url}")
context = {
'user_location': 'San Francisco',
'user_age': '25-34',
'interests': ['fitness', 'technology'],
'budget': 'mid-range'
}
ads = client.get_contextual_ads(
"workout equipment",
max_ads=5,
context=context
)
import time
from adsonai_sdk import AdsonAI, APIError
def get_ads_with_retry(query, max_retries=3):
for attempt in range(max_retries):
try:
with AdsonAI(api_key=API_KEY) as client:
return client.get_contextual_ads(query)
except APIError as e:
if e.status_code == 429: # Rate limit
time.sleep(2 ** attempt) # Exponential backoff
continue
raise
return []
# Set your API key
export ADSONAI_API_KEY="your_actual_api_key"
# Run tests
python -m pytest tests/
# Run integration test
python test_live_api.py
MIT License - see LICENSE file for details.
aiohttpDownload counts and popularity will appear here as the collector receives them.
| Package / target | Requirement | Relationship |
|---|---|---|
httpxEnvironment{
"extras": "",
"marker": null,
"requires_python": ">=3.7",
"evaluation": "NOT_EVALUATED"
} | httpx>=0.24.0 | runtime |
pytestEnvironment{
"extras": "",
"marker": "extra == \"dev\"",
"requires_python": ">=3.7",
"evaluation": "NOT_EVALUATED"
} | pytest>=6.0; extra == "dev" | runtime |
pytest-asyncioEnvironment{
"extras": "",
"marker": "extra == \"dev\"",
"requires_python": ">=3.7",
"evaluation": "NOT_EVALUATED"
} | pytest-asyncio>=0.14.0; extra == "dev" | runtime |
pytest-mockEnvironment{
"extras": "",
"marker": "extra == \"dev\"",
"requires_python": ">=3.7",
"evaluation": "NOT_EVALUATED"
} | pytest-mock>=3.0; extra == "dev" | runtime |
blackEnvironment{
"extras": "",
"marker": "extra == \"dev\"",
"requires_python": ">=3.7",
"evaluation": "NOT_EVALUATED"
} | black>=21.0; extra == "dev" | runtime |
flake8Environment{
"extras": "",
"marker": "extra == \"dev\"",
"requires_python": ">=3.7",
"evaluation": "NOT_EVALUATED"
} | flake8>=3.8; extra == "dev" | runtime |
mypyEnvironment{
"extras": "",
"marker": "extra == \"dev\"",
"requires_python": ">=3.7",
"evaluation": "NOT_EVALUATED"
} | mypy>=0.800; extra == "dev" | runtime |
bdist_wheel · 15.43 KB · Python py3
sdist · 19.8 KB · Python source
Shared repository data · GitHub
Observed since 20 Oct, 19:54 UTC
No superseded metadata states collected. Unchanged observations do not create new revisions.
package_version:cc3d65029066aa09e50602fbbf6da5193bda278f49427f6d152a4f682975bc3a