Alivator
DocumentationMaking Your First Request

Making Your First Request

Language-specific examples to make your first API call.

Python

Python Example

import requests

# Set up your API key
API_KEY = "your_api_key_here"
BASE_URL = "https://api.alivator.com/v1"

# Create headers with authorization
headers = {
    "Authorization": f"Bearer {API_KEY}",
    "Content-Type": "application/json"
}

# Make the request
response = requests.get(f"{BASE_URL}/events", headers=headers)

# Parse the response
if response.status_code == 200:
    data = response.json()
    print(data)
else:
    print(f"Error: {response.status_code}")
    print(response.text)

JavaScript

JavaScript Example

const API_KEY = "your_api_key_here";
const BASE_URL = "https://api.alivator.com/v1";

// Make the request
fetch(`${BASE_URL}/events`, {
  method: "GET",
  headers: {
    "Authorization": `Bearer ${API_KEY}`,
    "Content-Type": "application/json"
  }
})
  .then(response => {
    if (!response.ok) {
      throw new Error(`HTTP error! status: ${response.status}`);
    }
    return response.json();
  })
  .then(data => {
    console.log("Events:", data);
  })
  .catch(error => {
    console.error("Error:", error);
  });

Node.js (with Axios)

Node.js Example

const axios = require("axios");

const API_KEY = "your_api_key_here";
const BASE_URL = "https://api.alivator.com/v1";

// Create axios instance with authorization
const client = axios.create({
  baseURL: BASE_URL,
  headers: {
    Authorization: `Bearer ${API_KEY}`,
    "Content-Type": "application/json"
  }
});

// Make the request
client.get("/events")
  .then(response => {
    console.log("Events:", response.data);
  })
  .catch(error => {
    console.error("Error:", error.response?.data || error.message);
  });

cURL

cURL Example

curl -X GET "https://api.alivator.com/v1/events" \
  -H "Authorization: Bearer your_api_key_here" \
  -H "Content-Type: application/json"

Example Response

Sample API Response

{
  "data": [
    {
      "id": "evt_1001",
      "category": "sports",
      "name": "Super Bowl LVII",
      "description": "Super Bowl LVII",
      "status": "active",
      "probability": 0.82,
      "confidence": 0.95,
      "resolved": false,
      "timestamp": "2026-01-15T14:30:00Z",
      "resolutionDate": "2026-02-09T00:00:00Z"
    },
    {
      "id": "evt_1002",
      "category": "weather",
      "name": "Heatwave in Europe",
      "description": "European temperatures exceed 40C",
      "status": "active",
      "probability": 0.68,
      "confidence": 0.88,
      "resolved": false,
      "timestamp": "2026-01-15T14:30:00Z",
      "resolutionDate": "2026-08-31T00:00:00Z"
    }
  ],
  "meta": {
    "total": 2,
    "limit": 20,
    "offset": 0,
    "timestamp": "2026-01-15T14:30:00Z",
    "requestId": "req_abc123def456"
  }
}

Check API Status

Check the status of the API without authentication:

Status Request

curl https://api.alivator.com/v1/status

Status Response

{
  "status": "operational",
  "version": "v1",
  "timestamp": "2026-01-15T14:30:00Z"
}

Error Handling

401 Unauthorized

{
  "error": "Unauthorized",
  "message": "Invalid or missing API key"
}

429 Too Many Requests

{
  "error": "Rate limit exceeded",
  "message": "You have exceeded your rate limit",
  "retryAfter": 60
}

500 Server Error

{
  "error": "Internal server error",
  "message": "An unexpected error occurred",
  "requestId": "req_abc123def456"
}

Next Steps