API Playground
Explore the power of LoyaltyDog AI with interactive code examples. See what's possible with our customer engagement and AI analytics APIs.
Interactive Playground Features
We're building powerful tools to help you test and explore our API capabilities.
Interactive Code Editor
Write and test API calls in real-time with syntax highlighting and auto-completion.
Live API Testing
Connect your API key and test real endpoints with your actual data.
Response Visualization
Beautiful charts and graphs to visualize API responses and data insights.
Code Generation
Generate client code in multiple languages (Python, JavaScript, PHP, etc.).
API Code Examples
Explore real API examples to understand what you can build with LoyaltyDog AI.
Customer Segmentation
Use AI to automatically segment customers based on behavior patterns and preferences.
// Segment customers using AI
const segments = await client.ai.segment({
criteria: 'high_value_at_risk',
model: 'behavioral_clustering_v3',
timeframe: '90d',
minClusterSize: 100
});
console.log('Segments found:', segments.data);
// Output:
// [
// {
// id: 'hvr_001',
// name: 'High Value At Risk',
// size: 1247,
// characteristics: ['high_ltv', 'declining_engagement'],
// recommendations: ['retention_campaign', 'personalized_offers']
// }
// ]
API Response
{
"segments": [
{
"id": "hvr_001",
"name": "High Value At Risk",
"size": 1247,
"revenue_impact": "$84,000",
"churn_probability": 0.73
},
{
"id": "loy_002",
"name": "Loyal Champions",
"size": 892,
"revenue_impact": "$156,000",
"engagement_score": 0.94
}
]
}
Churn Prediction
Predict which customers are likely to churn and when, with confidence scores.
// Predict customer churn risk
const prediction = await client.ai.predict({
customer_id: 'cust_12345',
models: ['churn_risk', 'lifetime_value'],
horizon: '30d'
});
// Get personalized retention strategies
const strategies = await client.ai.recommend({
customer_id: 'cust_12345',
context: 'retention',
budget: 50
});
API Response
{
"churn_risk": 0.78,
"confidence": 0.92,
"risk_factors": [
"decreased_login_frequency",
"reduced_feature_usage",
"support_ticket_spike"
],
"retention_strategies": [
{
"action": "personalized_discount",
"discount": 25,
"success_probability": 0.64
},
{
"action": "feature_tutorial",
"success_probability": 0.41
}
]
}
Real-time Personalization
Generate personalized content and offers based on customer behavior and context.
// Get personalized offers
const offers = await client.ai.personalize({
customer_id: 'cust_67890',
context: 'checkout_page',
products: ['prod_001', 'prod_002', 'prod_003'],
count: 3
});
// Track personalization performance
await client.events.track({
event: 'personalization_shown',
customer_id: 'cust_67890',
offers: offers.map(o => o.id),
context: 'checkout'
});
API Response
{
"offers": [
{
"id": "offer_001",
"type": "bundle_discount",
"discount": 15,
"products": ["prod_001", "prod_002"],
"message": "Complete your setup with 15% off!",
"confidence": 0.87
},
{
"id": "offer_002",
"type": "loyalty_points",
"points": 500,
"message": "Earn 500 bonus points today!",
"confidence": 0.74
}
]
}
Advanced Analytics
Get deep insights into customer journeys, conversion funnels, and engagement patterns.
// Analyze customer journey
const journey = await client.analytics.journey({
customer_id: 'cust_54321',
events: ['page_view', 'purchase', 'support_contact'],
timeframe: '6months'
});
// Generate cohort analysis
const cohorts = await client.analytics.cohort({
metric: 'retention',
period: 'monthly',
segments: ['new_users', 'returning_users']
});
API Response
{
"journey": {
"total_touchpoints": 47,
"conversion_events": 3,
"average_session_duration": "8m 34s",
"key_milestones": [
{
"event": "first_purchase",
"days_from_signup": 3,
"value": 49.99
},
{
"event": "feature_adoption",
"days_from_signup": 12,
"feature": "loyalty_program"
}
]
}
}
Campaign Optimization
AI-powered campaign optimization with A/B testing and performance tracking.
// Create optimized campaign
const campaign = await client.campaigns.create({
name: 'Q4 Retention Campaign',
audience: 'high_value_at_risk',
ai_optimization: {
optimize_for: 'conversion_rate',
test_variants: ['discount', 'points', 'upgrade'],
duration: '14d'
}
});
// Get campaign insights
const insights = await client.campaigns.insights(campaign.id);
API Response
{
"campaign": {
"id": "camp_001",
"status": "running",
"audience_size": 1247,
"variants": [
{
"name": "discount_25",
"conversion_rate": 0.18,
"confidence": 0.95
},
{
"name": "points_500",
"conversion_rate": 0.14,
"confidence": 0.87
}
],
"recommendation": "scale_discount_variant"
}
}
Loyalty Program Intelligence
Smart loyalty program management with AI-driven rewards and tier optimization.
// Optimize loyalty rewards
const optimization = await client.loyalty.optimize({
program_id: 'prog_001',
objectives: ['increase_engagement', 'reduce_churn'],
constraints: {
max_reward_cost: 1000,
target_segments: ['premium', 'at_risk']
}
});
// Generate personalized rewards
const rewards = await client.loyalty.generateRewards({
customer_id: 'cust_99999',
occasion: 'birthday',
budget: 25
});
API Response
{
"optimized_structure": {
"tiers": [
{
"name": "Bronze",
"threshold": 0,
"multiplier": 1.0,
"perks": ["free_shipping"]
},
{
"name": "Silver",
"threshold": 1000,
"multiplier": 1.25,
"perks": ["priority_support", "early_access"]
}
],
"predicted_engagement_lift": "23%"
}
}
Ready to Start Building?
Don't wait for the interactive playground. Start building with LoyaltyDog AI today using our comprehensive documentation and free developer tier.
Get Notified When Playground Launches
Be the first to know when our interactive playground goes live with hands-on API testing tools.