Hamster
hamsterlog
API Reference

API Reference

Complete technical reference for the Hamsterlog API, including endpoints, request/response formats, error codes, and rate limits.

Base URL

https://www.hamsterlog.dev

Authentication

All API requests require authentication using an API key. Include your API key in the request body:

{
  "apiKey": "your-api-key-here",
  "logs": [...]
}

API Key Management

  • API keys are unique to each source in your account.
  • Keys can be regenerated from the dashboard.
  • Keys should be kept secure and never exposed in client-side code.

Endpoints

POST /api/log

Send one or more log entries to Hamsterlog.

Request

Field Type Required Description
apiKey string Yes Your API key for authentication
logs array Yes Array of log objects (max 1000 logs per request)

Log Object

Field Type Required Description
message string Yes The log message (max 10,000 characters)
tags array No Array of tag strings (max 50 tags, 100 chars each)
timestamp integer No Unix timestamp in milliseconds

Example Request

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

{
  "apiKey": "your-api-key-here",
  "logs": [
    {
      "message": "User authentication successful",
      "tags": ["auth", "success", "user-123"],
      "timestamp": 1640995200000
    },
    {
      "message": "Database query executed in 45ms",
      "tags": ["database", "performance"],
      "timestamp": 1640995201000
    }
  ]
}

Response

Success (200 OK):

Error (4xx/5xx):

Error message

Error Codes

HTTP Status Error Code Description Resolution
400 invalid_json Request body is not valid JSON Check JSON syntax
400 missing_api_key API key not provided Include apiKey in request body
400 missing_logs Logs array not provided or empty Include logs array with at least one log
401 invalid_api_key API key is invalid or expired Check API key or regenerate from dashboard
429 rate_limit_exceeded Too many requests Implement exponential backoff

SDKs and Libraries

Official SDKs are available for popular languages:

For other languages, use the HTTP API directly.

Best Practices

Batching

  • Send multiple logs in a single request when possible
  • Aim for max 60 requests per minute

Error Handling

  • Always handle HTTP errors gracefully
  • Implement retry logic with exponential backoff
  • Log to local storage as backup when API is unavailable

Performance

  • Send logs asynchronously to avoid blocking your application
  • Consider using a background queue for high-volume logging

Security

  • Never expose API keys in client-side code
  • Sanitize sensitive data before logging

📖 More Information

For additional help, check our FAQ or Troubleshooting guide.