Hamster
hamsterlog
HTTP API

๐Ÿ”— Hamsterlog HTTP API

The Hamsterlog HTTP API allows you to send logs from any programming language or platform. This guide shows you how to integrate directly with the API using simple HTTP requests.

API Endpoint

All logs are sent to a single endpoint:

POST https://www.hamsterlog.dev/api/log
Content-Type: application/json

Request Format

Send a JSON payload with your API key and an array of log entries:

{
  "apiKey": "your-api-key-here",
  "logs": [
    {
      "message": "User logged in successfully",
      "tags": ["auth", "success"],
      "timestamp": 1640995200000
    },
    {
      "message": "API request processed",
      "tags": ["api", "request"],
      "timestamp": 1640995201000
    }
  ]
}

Request Fields

  • apiKey (required): Your unique API key from the Hamsterlog dashboard
  • logs (required): Array of log objects to send

Log Object Fields

  • message (required): The log message string
  • tags (optional): Array of strings for categorizing the log
  • timestamp (required): Unix timestamp in milliseconds

Batching Logs

For better performance, batch multiple logs in a single request:

{
  "apiKey": "your-api-key-here",
  "logs": [
    {
      "message": "User session started",
      "tags": ["auth", "session"],
      "timestamp": 1640995200000
    },
    {
      "message": "Profile page loaded",
      "tags": ["ui", "profile"],
      "timestamp": 1640995201000
    },
    {
      "message": "Settings updated",
      "tags": ["user", "settings"],
      "timestamp": 1640995202000
    }
  ]
}

Response Codes

Status Code Meaning Description
200 Success Logs received and processed
400 Bad Request Invalid JSON or missing required fields
401 Unauthorized Invalid or missing API key
429 Rate Limit Too many requests, slow down
500 Server Error Internal server error, try again later

Security Considerations

API Key Protection

  • Never expose API keys in client-side code
  • Use environment variables for API key storage

Testing the API

Test your integration with a simple cURL command:

# Test with a simple log
curl -X POST https://www.hamsterlog.dev/api/log \
  -H "Content-Type: application/json" \
  -d '{
    "apiKey": "your-api-key-here",
    "logs": [
      {
        "message": "API test log",
        "tags": ["test"],
        "timestamp": '$(date +%s000)'
      }
    ]
  }'

# Expected response: HTTP 200 OK

๐Ÿงช Testing Tools

Use tools like HTTPie, Postman, or Insomnia to test API requests interactively.

๐Ÿ”ง Need Help?

Check our Troubleshooting guide or the FAQ. Or just email us. We're friendly hamsters who actually respond!