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

FieldTypeRequiredDescription
apiKeystringYesYour API key for authentication
logsarrayYesArray of log objects (max 1000 logs per request)

Log Object

FieldTypeRequiredDescription
messagestringYesThe log message (max 10,000 characters)
tagsarrayNoArray of tag strings (max 50 tags, 100 chars each)
timestampintegerNoUnix 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 StatusError CodeDescriptionResolution
400invalid_jsonRequest body is not valid JSONCheck JSON syntax
400missing_api_keyAPI key not providedInclude apiKey in request body
400missing_logsLogs array not provided or emptyInclude logs array with at least one log
401invalid_api_keyAPI key is invalid or expiredCheck API key or regenerate from dashboard
429rate_limit_exceededToo many requestsImplement 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.