Overview
Automate deal hunting, coupon finding, and even complete purchases to save time and money.Smart Deal Finder
Find the best deals across multiple retailers.- JavaScript
- Python
- HTTPie
Copy
import { AGIClient } from 'agi';
const client = new AGIClient({ apiKey: 'your_api_key' });
const session = await client.createSession('agi-0');
const maxPrice = 350;
const result = await session.runTask(`
Find the best deals on: Sony WH-1000XM5 (under $${maxPrice})
Search across: Amazon, eBay, Walmart, Best Buy, Target, Newegg, B&H Photo, Deal aggregator sites (Slickdeals, DealNews).
For each option: Retailer name, Current price, Original/list price, Discount percentage, Deal type, Condition, Shipping cost, Total cost, Product URL, Deal expiration, Stock status, User ratings.
Also include: Coupon codes, Cashback opportunities, Price match policies, Bundle deals, Student/military discounts.
Return as JSON sorted by total cost (lowest first) with summary: Best overall deal, Best deal for new items only, Fastest shipping option, Best value.
`);
await session.delete();
Copy
from pyagi import AGIClient
client = AGIClient(api_key="your_api_key")
with client.session("agi-0") as session:
max_price = 350
result = session.run_task(f"""
Find the best deals on: Sony WH-1000XM5 (under ${max_price})
Search across: Amazon, eBay, Walmart, Best Buy, Target, Newegg, B&H Photo, Deal aggregator sites (Slickdeals, DealNews).
For each option: Retailer name, Current price, Original/list price, Discount percentage, Deal type, Condition, Shipping cost, Total cost, Product URL, Deal expiration, Stock status, User ratings.
Also include: Coupon codes, Cashback opportunities, Price match policies, Bundle deals, Student/military discounts.
Return as JSON sorted by total cost (lowest first) with summary: Best overall deal, Best deal for new items only, Fastest shipping option, Best value.
""")
Copy
export AGI_API_KEY="your_api_key"
SESSION=$(http POST https://api.agi.tech/v1/sessions \
Authorization:"Bearer $AGI_API_KEY" \
agent_name=agi-0 | jq -r '.session_id')
http POST https://api.agi.tech/v1/sessions/$SESSION/message \
Authorization:"Bearer $AGI_API_KEY" \
message="Find the best deals on: Sony WH-1000XM5 (under $350). Search across Amazon, eBay, Walmart, Best Buy, Target, Newegg, B&H Photo, deal aggregator sites. Include retailer, price, discount, deal type, condition, shipping, total cost, URL, expiration, stock, ratings, coupons, cashback. Return JSON sorted by total cost with summary."
# Poll for results
while true; do
STATUS=$(http GET https://api.agi.tech/v1/sessions/$SESSION/status \
Authorization:"Bearer $AGI_API_KEY" | jq -r '.status')
if [ "$STATUS" = "finished" ]; then
http GET https://api.agi.tech/v1/sessions/$SESSION/messages \
Authorization:"Bearer $AGI_API_KEY" | jq '.messages[] | select(.type=="DONE")'
break
fi
sleep 2
done
# Cleanup
http DELETE https://api.agi.tech/v1/sessions/$SESSION \
Authorization:"Bearer $AGI_API_KEY"
Coupon & Promo Code Finder
Automatically find and apply coupon codes.- JavaScript
- Python
- HTTPie
Copy
const result = await session.runTask(`
Find active coupon codes for Best Buy in laptops
Search: Retailer's official coupon page, RetailMeNot, Honey, Slickdeals, Reddit (r/deals), Retailer's email newsletter/homepage.
For each coupon: Code, Discount (% off or $ off), Minimum purchase requirement, Exclusions, Expiration date, Verified/tested recently, Success rate, Source URL.
Return as JSON with retailer, coupons array, stacking_opportunities, best_code.
Prioritize: Currently active codes, Highest discount value, No minimum purchase, Recently verified.
`);
const bestCode = result.best_code.code;
Copy
result = session.run_task("""
Find active coupon codes for Best Buy in laptops
Search: Retailer's official coupon page, RetailMeNot, Honey, Slickdeals, Reddit (r/deals), Retailer's email newsletter/homepage.
For each coupon: Code, Discount (% off or $ off), Minimum purchase requirement, Exclusions, Expiration date, Verified/tested recently, Success rate, Source URL.
Return as JSON with retailer, coupons array, stacking_opportunities, best_code.
Prioritize: Currently active codes, Highest discount value, No minimum purchase, Recently verified.
""")
best_code = result['best_code']['code']
Copy
http POST https://api.agi.tech/v1/sessions/$SESSION/message \
Authorization:"Bearer $AGI_API_KEY" \
message="Find active coupon codes for Best Buy in laptops. Search RetailMeNot, Honey, Slickdeals, Reddit. For each coupon extract code, discount, minimum, exclusions, expiration, verified status, success rate, source. Return JSON with coupons array and best_code."
Automated Deal Monitoring
Monitor for deals and get alerts when price drops.Copy
from datetime import datetime
import time
class DealMonitor:
def __init__(self, api_key, notification_callback):
self.api_key = api_key
self.notification_callback = notification_callback
self.monitored_products = {}
def add_product(self, product_name, target_price, retailers=None):
"""Add product to deal monitoring"""
self.monitored_products[product_name] = {
'target_price': target_price,
'retailers': retailers or ["Amazon", "Best Buy", "Walmart"],
'current_best': None,
'alert_sent': False
}
def check_deals(self):
"""Check for deals on all monitored products"""
for product_name, config in self.monitored_products.items():
session_id = create_session(self.api_key, agent_name="agi-0-fast")
try:
retailers_str = '\n'.join(f'- {r}' for r in config['retailers'])
send_message(session_id, f"""
Quick price check for: {product_name}
Retailers:
{retailers_str}
For each retailer:
- Current price (including any visible coupons/sales)
- In stock: yes/no
- URL
Return JSON array with results.
""")
result = wait_for_completion(session_id, timeout=45)
# Find lowest price
in_stock_options = [r for r in result if r.get('in_stock')]
if in_stock_options:
best_deal = min(in_stock_options, key=lambda x: x['price'])
# Check if price meets target
if best_deal['price'] <= config['target_price']:
if not config['alert_sent']:
self.notification_callback({
'product': product_name,
'target_price': config['target_price'],
'current_price': best_deal['price'],
'retailer': best_deal['retailer'],
'url': best_deal['url'],
'savings': config['target_price'] - best_deal['price']
})
config['alert_sent'] = True
config['current_best'] = best_deal
finally:
delete_session(session_id)
def monitor(self, check_interval=3600):
"""Start monitoring (default: check every hour)"""
print(f"Monitoring {len(self.monitored_products)} products...")
while True:
self.check_deals()
time.sleep(check_interval)
# Usage
def send_deal_alert(alert_data):
print(f"🎉 DEAL ALERT: {alert_data['product']}")
print(f"Target: ${alert_data['target_price']}")
print(f"Current: ${alert_data['current_price']} at {alert_data['retailer']}")
print(f"Save ${alert_data['savings']:.2f}!")
print(f"Buy now: {alert_data['url']}")
monitor = DealMonitor(API_KEY, send_deal_alert)
monitor.add_product("iPad Air M2", target_price=499)
monitor.add_product("AirPods Pro 2", target_price=189)
monitor.monitor(check_interval=1800) # Check every 30 minutes
Flash Sale Hunter
Monitor for time-limited flash sales.- JavaScript
- Python
- HTTPie
Copy
const categories = ["Electronics", "Home & Garden", "Fashion"];
const retailers = ["Amazon", "Best Buy", "Woot", "TechBargains"];
const result = await session.runTask(`
Find active flash sales and lightning deals
Categories: ${categories.join(', ')}
Retailers: ${retailers.join(', ')}
For each retailer: Check flash sale/lightning deal sections, Check "Deal of the Day", Check time-limited promotions.
For each deal: Product name, Category, Original price, Sale price, Discount percentage, Time remaining (countdown), Stock available, Deal URL, Claimed percentage.
Return as JSON sorted by discount percentage (highest first) with flash_sales array, expiring_soon (deals expiring in < 1 hour), and best_deals (top 5 by discount).
`);
Copy
categories = ["Electronics", "Home & Garden", "Fashion"]
retailers = ["Amazon", "Best Buy", "Woot", "TechBargains"]
result = session.run_task(f"""
Find active flash sales and lightning deals
Categories: {', '.join(categories)}
Retailers: {', '.join(retailers)}
For each retailer: Check flash sale/lightning deal sections, Check "Deal of the Day", Check time-limited promotions.
For each deal: Product name, Category, Original price, Sale price, Discount percentage, Time remaining (countdown), Stock available, Deal URL, Claimed percentage.
Return as JSON sorted by discount percentage (highest first) with flash_sales array, expiring_soon (deals expiring in < 1 hour), and best_deals (top 5 by discount).
""")
Copy
http POST https://api.agi.tech/v1/sessions/$SESSION/message \
Authorization:"Bearer $AGI_API_KEY" \
message="Find active flash sales and lightning deals. Categories: Electronics, Home & Garden, Fashion. Retailers: Amazon, Best Buy, Woot, TechBargains. For each deal extract product, category, prices, discount, time remaining, stock, URL. Return JSON sorted by discount with flash_sales, expiring_soon, and best_deals."
Bundle Deal Finder
Find bundle deals and package savings.- JavaScript
- Python
- HTTPie
Copy
const products = [
"PlayStation 5",
"Extra DualSense Controller",
"Spider-Man 2 Game",
"PlayStation Plus Subscription"
];
const result = await session.runTask(`
Find bundle deals that include these products: ${products.join(', ')}
Search for: Pre-made bundles, "Buy together and save" deals, Multi-buy discounts, Retailer-created bundles, Manufacturer bundles.
For each bundle: Items included, Bundle price, Individual prices (sum if bought separately), Total savings, Bundle URL, Retailer, Stock status.
Also calculate: Best combination of bundles to get all items, Optimal purchasing strategy, Maximum possible savings.
Return as JSON with bundles array and optimal_strategy (bundles_to_buy, total_cost, individual_cost, total_savings, savings_pct).
`);
Copy
products = [
"PlayStation 5",
"Extra DualSense Controller",
"Spider-Man 2 Game",
"PlayStation Plus Subscription"
]
result = session.run_task(f"""
Find bundle deals that include these products: {', '.join(products)}
Search for: Pre-made bundles, "Buy together and save" deals, Multi-buy discounts, Retailer-created bundles, Manufacturer bundles.
For each bundle: Items included, Bundle price, Individual prices (sum if bought separately), Total savings, Bundle URL, Retailer, Stock status.
Also calculate: Best combination of bundles to get all items, Optimal purchasing strategy, Maximum possible savings.
Return as JSON with bundles array and optimal_strategy (bundles_to_buy, total_cost, individual_cost, total_savings, savings_pct).
""")
Copy
http POST https://api.agi.tech/v1/sessions/$SESSION/message \
Authorization:"Bearer $AGI_API_KEY" \
message="Find bundle deals for: PlayStation 5, Extra DualSense Controller, Spider-Man 2 Game, PlayStation Plus Subscription. Search for pre-made bundles, buy together deals, multi-buy discounts. For each bundle extract items, prices, savings, URL, retailer, stock. Calculate optimal strategy. Return JSON with bundles and optimal_strategy."
Cashback & Rewards Maximizer
Find the best cashback and rewards opportunities.- JavaScript
- Python
- HTTPie
Copy
const creditCards = ["Chase Sapphire Reserve", "Amex Gold"];
const result = await session.runTask(`
Find best cashback opportunities for: MacBook Pro 14-inch
Consider: Cashback portals (Rakuten, TopCashback, BeFrugal), Credit card rewards: ${creditCards.join(', ')}, Retailer loyalty programs, Browser extensions (Honey, Capital One Shopping), Shopping apps with rewards.
For each opportunity: Source (portal/card/program), Cashback rate (% or $), Estimated cashback amount, Stacking possible (yes/no), Requirements/minimums, Redemption terms.
Calculate: Best single source, Best stacking combination, Maximum total cashback possible.
Return as JSON with opportunities array and best_stack (sources, total_cashback, effective_discount, final_cost).
`);
Copy
credit_cards = ["Chase Sapphire Reserve", "Amex Gold"]
result = session.run_task(f"""
Find best cashback opportunities for: MacBook Pro 14-inch
Consider: Cashback portals (Rakuten, TopCashback, BeFrugal), Credit card rewards: {', '.join(credit_cards)}, Retailer loyalty programs, Browser extensions (Honey, Capital One Shopping), Shopping apps with rewards.
For each opportunity: Source (portal/card/program), Cashback rate (% or $), Estimated cashback amount, Stacking possible (yes/no), Requirements/minimums, Redemption terms.
Calculate: Best single source, Best stacking combination, Maximum total cashback possible.
Return as JSON with opportunities array and best_stack (sources, total_cashback, effective_discount, final_cost).
""")
Copy
http POST https://api.agi.tech/v1/sessions/$SESSION/message \
Authorization:"Bearer $AGI_API_KEY" \
message="Find best cashback opportunities for: MacBook Pro 14-inch. Consider cashback portals, credit card rewards (Chase Sapphire Reserve, Amex Gold), loyalty programs, browser extensions. For each opportunity extract source, rate, estimated amount, stacking, requirements. Calculate best single source, best stack, maximum cashback. Return JSON with opportunities and best_stack."
Automated Checkout
Automate the checkout process (with proper authorization).- JavaScript
- Python
- HTTPie
Copy
async function automatedCheckout(sessionId, productUrl, paymentToken, shippingAddress) {
// IMPORTANT: Only use with proper authorization and secure payment tokens
const summary = await session.runTask(`
Complete checkout for product at: ${productUrl}
Steps:
1. Navigate to the product page
2. Click "Add to Cart"
3. Go to cart
4. Proceed to checkout
5. Enter shipping address: ${JSON.stringify(shippingAddress)}
6. Select fastest available shipping
7. Apply payment using token: ${paymentToken}
8. Review order details
9. STOP and provide order summary for confirmation
DO NOT complete the purchase yet.
Return JSON with ready_to_purchase, order_summary (items, subtotal, tax, shipping, total, estimated_delivery), payment_method, shipping_method.
Wait for explicit confirmation before completing purchase.
`);
return summary;
}
async function confirmAndCompletePurchase(sessionId) {
const result = await session.runTask(`
User confirmed. Complete the purchase:
1. Click final "Place Order" or "Complete Purchase" button
2. Wait for order confirmation
3. Capture order number
4. Take screenshot of confirmation page
Return JSON with order_placed, order_number, confirmation_email, estimated_delivery.
`);
return result;
}
// Usage (with user confirmation required)
const summary = await automatedCheckout(
sessionId,
"https://www.amazon.com/...",
"guest_token_123", // Use secure payment tokens
{
name: "John Doe",
street: "123 Main St",
city: "San Francisco",
state: "CA",
zip: "94102"
}
);
console.log(`Order Total: $${summary.order_summary.total}`);
console.log(`Delivery: ${summary.order_summary.estimated_delivery}`);
// Get user confirmation
const userConfirms = await getUserInput("Confirm purchase? (yes/no): ");
if (userConfirms.toLowerCase() === 'yes') {
const result = await confirmAndCompletePurchase(sessionId);
console.log(`Order #${result.order_number} placed successfully!`);
}
Copy
def automated_checkout(session_id, product_url, payment_token, shipping_address):
"""
Automate checkout process
IMPORTANT: Only use with proper authorization and secure payment tokens
"""
result = session.run_task(f"""
Complete checkout for product at: {product_url}
Steps:
1. Navigate to the product page
2. Click "Add to Cart"
3. Go to cart
4. Proceed to checkout
5. Enter shipping address: {shipping_address}
6. Select fastest available shipping
7. Apply payment using token: {payment_token}
8. Review order details
9. STOP and provide order summary for confirmation
DO NOT complete the purchase yet.
Return JSON with ready_to_purchase, order_summary (items, subtotal, tax, shipping, total, estimated_delivery), payment_method, shipping_method.
Wait for explicit confirmation before completing purchase.
""")
return result
def confirm_and_complete_purchase(session_id):
result = session.run_task("""
User confirmed. Complete the purchase:
1. Click final "Place Order" or "Complete Purchase" button
2. Wait for order confirmation
3. Capture order number
4. Take screenshot of confirmation page
Return JSON with order_placed, order_number, confirmation_email, estimated_delivery.
""")
return result
# Usage (with user confirmation required)
summary = automated_checkout(
session_id,
product_url="https://www.amazon.com/...",
payment_token="guest_token_123", # Use secure payment tokens
shipping_address={
"name": "John Doe",
"street": "123 Main St",
"city": "San Francisco",
"state": "CA",
"zip": "94102"
}
)
print(f"Order Total: ${summary['order_summary']['total']}")
print(f"Delivery: {summary['order_summary']['estimated_delivery']}")
user_confirms = input("Confirm purchase? (yes/no): ")
if user_confirms.lower() == 'yes':
result = confirm_and_complete_purchase(session_id)
print(f"Order #{result['order_number']} placed successfully!")
Copy
# Step 1: Prepare checkout
SUMMARY=$(http POST https://api.agi.tech/v1/sessions/$SESSION_ID/message \
Authorization:"Bearer $AGI_API_KEY" \
message="Complete checkout for product at: $PRODUCT_URL. Steps: Navigate, Add to Cart, Go to cart, Proceed to checkout, Enter shipping address, Select shipping, Apply payment token, Review order, STOP and provide order summary. Return JSON with ready_to_purchase, order_summary, payment_method, shipping_method.")
# Show summary to user
echo "$SUMMARY" | jq '.order_summary'
# Step 2: Confirm and complete (after user confirmation)
http POST https://api.agi.tech/v1/sessions/$SESSION_ID/message \
Authorization:"Bearer $AGI_API_KEY" \
message="User confirmed. Complete the purchase: Click Place Order, Wait for confirmation, Capture order number, Take screenshot. Return JSON with order_placed, order_number, confirmation_email, estimated_delivery."
Automated checkout requires explicit user authorization and should use secure payment tokens. Never store or hardcode payment credentials. Always provide order summary and require confirmation before completing purchases.
Deal Aggregator
Aggregate deals from multiple sources into a single feed.Copy
class DealAggregator:
def __init__(self, api_key):
self.api_key = api_key
def get_daily_deals(self, categories=None, min_discount=20):
"""Get aggregated deals from multiple sources"""
session_id = create_session(self.api_key, agent_name="agi-0")
categories_str = '\n'.join(f'- {c}' for c in categories) if categories else "All categories"
send_message(session_id, f"""
Aggregate today's best deals from multiple sources:
Sources to check:
- Slickdeals (front page deals)
- RedFlagDeals (if applicable)
- DealNews
- TechBargains
- Amazon Gold Box
- Best Buy Deal of the Day
- RetailMeNot trending deals
Filters:
- Categories: {categories_str}
- Minimum discount: {min_discount}%
- Active deals only (not expired)
For each deal:
- Product name
- Category
- Retailer
- Original price
- Deal price
- Discount percentage
- Deal type (sale, coupon, rebate, etc.)
- Upvotes/popularity (if shown)
- Expiration
- URL
Return as JSON sorted by popularity/upvotes:
{{
"deals": [...],
"hot_deals": [...], // Trending/most popular
"expiring_soon": [...], // Expire in < 24 hours
"categories": {{...}} // Deals grouped by category
}}
""")
result = wait_for_completion(session_id)
delete_session(session_id)
return result
def get_personalized_deals(self, interests, price_range=None):
"""Get deals personalized to user interests"""
session_id = create_session(self.api_key, agent_name="agi-0")
interests_str = '\n'.join(f'- {i}' for i in interests)
price_str = f"between ${price_range[0]} and ${price_range[1]}" if price_range else "any price"
send_message(session_id, f"""
Find personalized deals based on these interests:
{interests_str}
Price range: {price_str}
Search across all deal sites and retailers for products matching these interests.
Return top 20 deals sorted by relevance and value.
""")
result = wait_for_completion(session_id)
delete_session(session_id)
return result
# Usage
aggregator = DealAggregator(API_KEY)
# Daily deals in specific categories
deals = aggregator.get_daily_deals(
categories=["Electronics", "Computers", "Gaming"],
min_discount=25
)
# Personalized deals
personal_deals = aggregator.get_personalized_deals(
interests=["Mechanical keyboards", "Gaming monitors", "Productivity software"],
price_range=(50, 500)
)
Best Practices
Verify Deals
Always verify deal prices and availability before purchasing
Stack Savings
Combine coupons, cashback, and rewards for maximum savings
Secure Payments
Use secure payment tokens and never store credentials
Set Price Alerts
Monitor target prices to catch the best deals