← Back to Home

API Documentation

Complete guide to using API Gateway Pro

Getting Started

API Gateway Pro provides a powerful edge-based API gateway that sits between your applications and backend services.

1. Get Your API Key

  1. Sign up at https://raysep.com/signup
  2. Choose your plan (Free, Basic, or Premium)
  3. Copy your API key from the dashboard

2. Make Your First Request

All requests go through the proxy endpoint:

curl https://raysep.com/api/proxy/YOUR_ENDPOINT \
  -H "Authorization: Bearer YOUR_API_KEY"

API Reference

Health Check

Check if the API Gateway is operational.

GET /api/health

Example:

curl https://raysep.com/api/health

Response:

{
  "status": "healthy",
  "timestamp": "2024-11-01T12:00:00Z",
  "version": "1.0.0",
  "region": "iad"
}

Pricing Information

Get current pricing plans.

GET /api/pricing

Example:

curl https://raysep.com/api/pricing

Proxy Requests

Route requests through the gateway to your backend APIs.

GET /api/proxy/{endpoint}
POST /api/proxy/{endpoint}
PUT /api/proxy/{endpoint}
DELETE /api/proxy/{endpoint}

Headers:

Example:

curl https://raysep.com/api/proxy/users/123 \
  -H "Authorization: Bearer abc123..." \
  -H "Content-Type: application/json"
Note: The gateway automatically adds headers like X-Forwarded-For, X-Request-ID, and tracks analytics for you.

Usage Statistics

Get your usage statistics and analytics.

GET /api/admin/stats

Headers:

Response:

{
  "user": {
    "id": "user_123",
    "tier": "premium"
  },
  "usage": {
    "today": {
      "requests": 1234,
      "cached": 456,
      "cost": 0.12
    },
    "thisMonth": {
      "requests": 45678,
      "cost": 4.56
    }
  },
  "performance": {
    "uptime": 99.98,
    "p50Latency": 142,
    "cacheHitRate": 37.2
  }
}

Authentication

All API requests require authentication using your API key in the Authorization header:

Authorization: Bearer YOUR_API_KEY

Alternatively, you can pass it as a query parameter:

?apiKey=YOUR_API_KEY
Security: Always use HTTPS and never expose your API key in client-side code. Store it securely in environment variables.

Rate Limiting

Rate limits are applied based on your plan:

Plan Requests/Month Rate Limit
Free 10,000 60/minute
Basic 100,000 100/minute
Premium 500,000 200/minute

When you exceed the rate limit, you'll receive a 429 response:

{
  "error": "Rate limit exceeded",
  "limit": 100,
  "remaining": 0,
  "resetAt": 1699000000
}

Caching

The gateway automatically caches GET requests based on the response's Cache-Control headers. Benefits:

Cache Control

Control caching behavior with headers:

# Disable caching for a request
curl ... -H "Cache-Control: no-cache"

# Request fresh data (bypass cache)
curl ... -H "Cache-Control: no-store"

Error Handling

The API uses standard HTTP status codes:

All errors return JSON:

{
  "error": "Error message here",
  "code": "ERROR_CODE",
  "details": "Additional information"
}

Best Practices

1. Use Caching Wisely

Set appropriate Cache-Control headers on your backend responses:

Cache-Control: public, max-age=300  # Cache for 5 minutes

2. Handle Rate Limits

Implement exponential backoff when you receive 429 responses:

function sleep(ms) {
  return new Promise(resolve => setTimeout(resolve, ms));
}

async function callAPI() {
  let retries = 0;
  while (retries < 5) {
    const response = await fetch(url, options);
    if (response.status === 429) {
      await sleep(Math.pow(2, retries) * 1000);
      retries++;
      continue;
    }
    return response;
  }
}

3. Monitor Your Usage

Regularly check your stats endpoint to avoid surprises:

# Get current usage
curl https://raysep.com/api/admin/stats \
  -H "Authorization: Bearer YOUR_API_KEY"

Support

Need help? We're here for you:

Pro Tip: Join our Discord community to get help from other developers and share your integrations!

Examples

Node.js

const axios = require('axios');

const client = axios.create({
  baseURL: 'https://raysep.com/api/proxy',
  headers: {
    'Authorization': `Bearer ${process.env.API_KEY}`
  }
});

// Make a request
const response = await client.get('/users/123');
console.log(response.data);

Python

import requests
import os

API_KEY = os.environ['API_KEY']
BASE_URL = 'https://raysep.com/api/proxy'

headers = {
    'Authorization': f'Bearer {API_KEY}'
}

response = requests.get(f'{BASE_URL}/users/123', headers=headers)
print(response.json())

JavaScript (Browser)

const API_KEY = 'your-api-key';
const BASE_URL = 'https://raysep.com/api/proxy';

async function getUser(id) {
  const response = await fetch(`${BASE_URL}/users/${id}`, {
    headers: {
      'Authorization': `Bearer ${API_KEY}`
    }
  });
  return response.json();
}

getUser(123).then(data => console.log(data));

← Back to Home