Introduction
The Ghost Planet API is a RESTful JSON API built with Go that provides access to paranormal investigation data, including locations, evidence, and investigations. The API uses standard HTTP methods and returns JSON responses with a consistent envelope format.Base URL
All API requests should be made to:The API runs on port 4000 by default in development mode. The base path
/v1 indicates API version 1.0.0.API Version
The current API version is 1.0.0. The version is included in the base path (/v1/) and can be verified via the healthcheck endpoint.
Source: backend/cmd/api/main.go:18
Server Configuration
The API server is configured with the following default settings:- Port: 4000 (configurable via
-portflag) - Environment: development (configurable via
-envflag) - Read Timeout: 10 seconds
- Write Timeout: 30 seconds
- Idle Timeout: 1 minute
- Database: PostgreSQL with connection pooling
- Max Open Connections: 25
- Max Idle Connections: 25
- Max Idle Time: 15 minutes
backend/cmd/api/main.go:40-74
Response Format
All API responses use a JSON envelope format for consistency and extensibility.Success Response Structure
Successful responses wrap data in a descriptive key:The envelope format uses an indented JSON structure with tabs for readability. All responses end with a newline character.
Response Headers
All JSON responses include:backend/cmd/api/helpers.go:27-46
Error Responses
Error responses follow a consistent format with anerror key:
HTTP Status Codes
The API uses standard HTTP status codes:| Status Code | Meaning | Description |
|---|---|---|
200 | OK | Request succeeded |
201 | Created | Resource created successfully |
400 | Bad Request | Invalid request format or parameters |
404 | Not Found | Resource not found |
405 | Method Not Allowed | HTTP method not supported for this endpoint |
422 | Unprocessable Entity | Validation failed |
500 | Internal Server Error | Server encountered an error |
Error Types
The API returns different error messages based on the error type:backend/cmd/api/errors.go:12-45
Request Limits
Request Body Size
The API enforces a maximum request body size:- Maximum Size: 1 MB (1,048,576 bytes)
backend/cmd/api/helpers.go:49
Request Body Validation
The API strictly validates JSON requests:- Request body must contain valid JSON
- Unknown fields are rejected
- Field types must match expected types
- Body must contain exactly one JSON value
- Empty bodies are rejected
backend/cmd/api/helpers.go:48-99
Health Check
Use the health check endpoint to verify API availability:backend/cmd/api/healthcheck.go:7-21
Content Type
All requests with a body must include the appropriate Content-Type header:The API only accepts JSON payloads. Other content types will be rejected.
Router
The API uses httprouter for fast HTTP routing with support for URL parameters and automatic OPTIONS responses. Source:backend/cmd/api/routes.go:9