MegaReach API Documentation
← Back to Home | Getting Started
API Overview
The MegaReach API provides programmatic access to our platform's features, allowing developers to integrate social automation, rewards, and analytics into their applications.
🔐 Authentication
All API requests require authentication using an API key. Include your API key in the request header:
Authorization: Bearer YOUR_API_KEY
Get your API key from the Dashboard → API Keys
Base URL
https://api.megareach.xyz/v1
🔗 Core Endpoints
User Profile
GET /user/profile
Get user profile information
Generate AI Reply
POST /engagement/reply
Generate AI-powered reply for social media content
Token Balance
GET /rewards/balance
Get current $REACH token balance
Create Campaign
POST /campaign/create
Create a new marketing campaign
Analytics Overview
GET /analytics/overview
Get analytics overview and metrics
📝 Example: Generate AI Reply
Request
POST /v1/engagement/reply
Content-Type: application/json
Authorization: Bearer YOUR_API_KEY
{
"content": "Great product! How does it work?",
"context": "Product announcement tweet",
"tone": "friendly",
"platform": "twitter"
}
Response
{
"success": true,
"data": {
"reply": "Thank you for your interest! Our product uses advanced AI...",
"confidence": 0.92,
"tokens_earned": 5
}
}
📋 Request Parameters
Generate Reply Parameters
- content (string, required): The content to respond to
- context (string, optional): Additional context for better responses
- tone (string, optional): Response tone - friendly, professional, casual
- platform (string, required): Social platform - twitter, instagram, linkedin
⚡ Rate Limits
- Free Tier: 100 requests/hour
- Pro Tier: 1,000 requests/hour
- Enterprise: Custom limits
Rate limit headers are included in all responses:
X-RateLimit-Limit: 1000
X-RateLimit-Remaining: 999
X-RateLimit-Reset: 1640995200
❌ Error Handling
All errors return appropriate HTTP status codes and error messages:
{
"success": false,
"error": {
"code": "RATE_LIMIT_EXCEEDED",
"message": "Rate limit exceeded. Try again in 60 seconds.",
"details": {
"limit": 100,
"reset_at": "2024-01-01T12:00:00Z"
}
}
}
Common Error Codes
- 400 - Bad Request: Invalid parameters
- 401 - Unauthorized: Invalid API key
- 403 - Forbidden: Access denied
- 404 - Not Found: Resource doesn't exist
- 429 - Too Many Requests: Rate limit exceeded
- 500 - Internal Server Error
📦 SDKs & Libraries
JavaScript/Node.js
npm install @megareach/sdk
Python
pip install megareach
Go
go get github.com/megareach/go-sdk
PHP
composer require megareach/php-sdk
🔔 Webhooks
Configure webhooks to receive real-time events:
Available Events
- campaign.completed - Campaign has finished
- reward.distributed - Tokens have been distributed
- engagement.milestone - Engagement goal reached
- creator.request - New partnership request
- payment.received - Payment confirmed
Webhook Payload Example
{
"event": "campaign.completed",
"timestamp": "2024-01-01T12:00:00Z",
"data": {
"campaign_id": "camp_123456",
"status": "success",
"metrics": {
"engagements": 50000,
"reach": 1000000,
"conversions": 500
}
}
}
🔧 API Best Practices
- Cache responses when appropriate
- Implement exponential backoff for retries
- Use webhook events instead of polling
- Batch requests when possible
- Handle errors gracefully
- Keep API keys secure
📚 Additional Resources
🚀 Quick Start with Node.js
const MegaReach = require('@megareach/sdk');
const client = new MegaReach({
apiKey: 'YOUR_API_KEY'
});
// Generate AI reply
const reply = await client.engagement.generateReply({
content: 'Amazing product!',
platform: 'twitter',
tone: 'friendly'
});
console.log(reply.data.reply);
© 2024 MegaReach. All rights reserved.