API Documentation

Detailed reference for all endpoints, features, and usage of the Travel Assistant API.

Project Overview
  • Geolocation Search: Get latitude & longitude of a city using Open-Meteo's geocoding API.
  • Weather Forecast: 5-day daily max/min temperature forecasts from Open-Meteo.
  • Nearby Facilities: Points of interest from OpenStreetMap Nominatim API.
  • Security: Rate limiting and CORS for safe public use.
Folder Structure
.
├── views/              # EJS views for testing
├── public/             # Static files
├── DomesticTrip.json   # Sample preference file (domestic)
├── ForeignTrip.json    # Sample preference file (foreign)
├── index.js            # Main server file
        
Sample API Usage
GET /location-info?city=faridabad&state=ap
Example Response:
{
  "location": {
    "city": "Faridabad",
    "state": "Andhra Pradesh",
    "country": "India",
    "latitude": 28.41,
    "longitude": 77.31
  },
  "weather": {
    "temperature_2m_max": [...],
    "temperature_2m_min": [...]
  },
  "facilities": [ {...}, {...}, ... ]
}
        
Endpoints
Route Method Description Sample Usage
/location-info GET Returns geolocation, weather, and facilities for a city/state. /location-info?city=delhi&state=delhi
/preference GET Returns trip preferences (domestic/foreign) from sample JSON files. /preference/foreign-trips?query
/user GET, POST, PUT, DELETE User management endpoints. /user/profile
/api GET Returns a simple greeting JSON. /api
APIs Used
API Purpose Free Tier?
Open-Meteo Weather + Geocoding ✅ Yes
OpenStreetMap Nominatim Facility Search ✅ Yes

All APIs used are free, no keys required, and suitable for personal or academic use.

Dependencies
  • express
  • axios
  • cors
  • express-rate-limit
  • morgan
  • ejs
  • fs (Node.js built-in)
  • path (Node.js built-in)

User Authentication & Profile API

Method Endpoint Protected? Description Body/Headers
POST /user/register No Register a new user
{
  "username": "yourname",
  "email": "your@email.com",
  "password": "yourpassword"
}
              
POST /user/login No Login and receive JWT tokens
{
  "email": "your@email.com",
  "password": "yourpassword"
}
              
GET /user/profile Yes Get the authenticated user's profile Headers:
Authorization: Bearer <access_token>
              
POST /user/logout Yes Logout user (client should delete token) Headers:
Authorization: Bearer <access_token>
              
POST /user/refresh-token No Get a new access token using a refresh token
{
  "refreshToken": "<refresh_token>"
}
              

Note: All protected routes require a valid JWT access token in the Authorization header.

Note: Some endpoints may require authentication or specific query/body parameters. Please refer to the source code or contact the maintainer for advanced usage.