Cosmic Watch is a backend service for monitoring Near-Earth Objects (NEOs), managing user authentication, and maintaining asteroid watchlists. All endpoints return JSON unless otherwise stated.
Authentication is handled using JWT tokens. Protected routes require:
Authorization: Bearer <token>
Returns basic server status.
"Hello World!"Create a new user account.
POST /auth/register
application/json
{
"name": "John Doe",
"email": "john@example.com",
"password": "password123"
}{
"message": "User registered successfully"
}400 Bad Request — Missing required field
{
"message": "Invalid input data"
}Authenticate user and return JWT token.
POST /auth/login
{
"email": "john@example.com",
"password": "password123"
}{
"token": "jwt_token_here"
}401 Unauthorized
{
"message": "Invalid credentials"
}All routes in this section require authentication.
Retrieve list of Near-Earth Objects.
GET /feed
Authorization: Bearer <token>
[
{
"id": "123",
"name": "Asteroid XYZ",
"magnitude": 22.1,
"isHazardous": false
}
]Retrieve details of a specific Near-Earth Object.
GET /feed/:id
| Parameter | Type | Description |
|---|---|---|
| id | string | NEO unique identifier |
{
"id": "123",
"name": "Asteroid XYZ",
"magnitude": 22.1,
"isHazardous": false,
"approachDate": "2026-02-08"
}404 Not Found
{
"message": "NEO not found"
}All routes require authentication.
Add a Near-Earth Object to user's watchlist.
POST /alerts/watch
{
"neoId": "123"
}{
"message": "Asteroid added to watchlist"
}Remove a Near-Earth Object from user's watchlist.
POST /alerts/unwatch/:neoId
| Parameter | Type | Description |
|---|---|---|
| neoId | string | NEO unique identifier |
{
"message": "Asteroid removed from watchlist"
}404 Not Found
{
"message": "Asteroid not found in watchlist"
}All error responses follow this structure:
{
"message": "Error description"
}