API Overview
Integrate and extend Refgrow programmatically
Introduction
Refgrow provides a RESTful API that allows you to integrate affiliate tracking and management functionality directly into your applications. The API enables you to track conversions, manage affiliates, retrieve statistics, and automate workflows.
The API is organized around REST principles. All requests should be made over HTTPS, and most API actions return JSON-encoded responses. Error responses include descriptive messages to help identify issues.
Base URL
The base URL for all API requests is:
https://refgrow.com/api
Authentication
Authentication to the API is performed via API keys. Each request must include your API key in the Authorization header.
const headers = {
'Authorization': 'Bearer YOUR_API_KEY',
'Content-Type': 'application/json'
};
For more details on obtaining and using API keys, see the Authentication documentation.
Available Endpoints
Refgrow API provides several endpoint categories:
Program Management
Endpoint | Method | Description |
---|---|---|
/api/program/:id/settings |
GET | Retrieve program settings |
/api/programs/:id/stats |
GET | Retrieve program statistics |
Affiliate Management
Endpoint | Method | Description |
---|---|---|
/api/auth |
POST | Authenticate affiliate |
/api/affiliates |
GET | List affiliates |
/api/affiliate/:id |
GET | Get affiliate details |
Tracking
Endpoint | Method | Description |
---|---|---|
/api/track |
POST | Track referral clicks |
/api/conversion |
POST | Track conversions |
Statistics
Endpoint | Method | Description |
---|---|---|
/api/programs/:id/referrals |
GET | Get referral statistics |
/api/programs/:id/daily-stats |
GET | Get daily statistics |
Rate Limits
To ensure service stability, API requests are subject to rate limiting. Current limits are:
- 100 requests per minute per IP address
- 1000 requests per hour per API key
When a rate limit is exceeded, the API will return a 429 Too Many Requests response with a Retry-After header indicating when you can resume making requests.
Error Handling
The API uses conventional HTTP response codes to indicate success or failure of requests:
- 2xx - Success
- 4xx - Client errors (invalid parameters, authentication issues)
- 5xx - Server errors
Error responses include a JSON object with error details:
{
"error": {
"code": "invalid_parameters",
"message": "Missing required parameter: program_id",
"status": 400
}
}
Example Requests
Below is an example of how to make a request to track a conversion:
// Example Node.js code for tracking a conversion
const axios = require('axios');
async function trackConversion() {
try {
const response = await axios.post('https://refgrow.com/api/conversion', {
program_id: '123',
customer_email: 'customer@example.com',
amount: 49.99,
referral_code: 'REF123'
}, {
headers: {
'Authorization': 'Bearer YOUR_API_KEY',
'Content-Type': 'application/json'
}
});
console.log('Conversion tracked:', response.data);
} catch (error) {
console.error('Error tracking conversion:', error.response ? error.response.data : error.message);
}
}
Next Steps
To learn more about specific API endpoints and functionality, explore these resources:
- Authentication Guide - Detailed information on API authentication
- API Endpoints - Complete reference for all available endpoints
- Webhooks - Set up real-time notifications for events in your affiliate program