OpenAPI Implementation

OpenAPI gateway for Cercalia Core REST services with OpenAPI 3.0 specs, Swagger UI, and production-ready REST endpoints.

What is this? The OpenAPI Implementation is a type-safe REST wrapper around the Core REST API. It provides cleaner endpoints, automatic validation, interactive documentation, and production-ready features like health checks and retry logic.

OpenAPI Swagger

Explore the Hosted Swagger UI

Prefer to explore the API without running it locally? Use our hosted OpenAPI + Swagger interface to browse endpoints, view schemas, and test requests instantly.

Open Swagger Documentation →

Overview

While the Core REST API gives you direct access to Cercalia’s geospatial engine, the OpenAPI Implementation adds a modern abstraction layer on top of it. Think of it as a “developer-friendly gateway” that:

Transforms Legacy to Modern REST

Converts Cercalia's query-string API into clean, RESTful endpoints following best practices.

OpenAPI 3.0 Specification

Full OpenAPI spec enables code generation for any language and interactive Swagger UI documentation.

Request Validation

Automatic validation of all parameters with clear error messages before reaching the backend.

Production-Ready

Health checks, structured logging, retry logic, and Docker support out of the box.


When to Use This vs Core REST API

Use CaseRecommendation
Building a new application from scratchOpenAPI Implementation - Better DX, type safety, modern patterns
Migrating an existing Cercalia integrationCore REST API - Direct compatibility with existing code
Generating client SDKs for unsupported languagesOpenAPI Implementation - Use the OpenAPI spec with code generators
Direct HTTP integration without middlewareCore REST API - Fewer moving parts, direct access
Need Swagger UI for team onboardingOpenAPI Implementation - Interactive docs included
Maximum control over request/response handlingCore REST API - No abstraction layer

Available Services

The OpenAPI Implementation wraps 11 Core REST API services with enhanced endpoints:

ServiceEndpointCore API Equivalent
GeocodingGET /v1/geocodingGeocoding
Reverse GeocodingGET /v1/reverse-geocodingReverse Geocoding
SuggestGET /v1/suggestSuggest
RoutingGET /v1/routingRouting
IsochroneGET /v1/isochroneIsochrones
POIGET /v1/poiPoints of Interest
ProximityGET /v1/proximityProximity
Static MapsGET /v1/staticmapsStatic Maps
GeomentGET /v1/geomentGeometry Download
Snap-to-RoadGET /v1/snaptoroadSnap to Road
GeofencingGET /v1/geofencingGeofencing

Quick Start

Prerequisites

Installation

# Clone the repository
git clone https://github.com/nexusgeographics/cercalia-openapi.git
cd cercalia-openapi

# Install dependencies
npm install

# Copy environment configuration
cp .env.example .env

# Edit .env and add your Cercalia API key
# CERCALIA_API_KEY=your_api_key_here

Running the Application

# Development mode (with hot-reload)
npm run start:dev

# Production mode
npm run build
npm run start:prod

# With Docker
docker-compose up

Access Points

ResourceURL
Swagger UIhttp://localhost:3000/api
Health Checkhttp://localhost:3000/health
API Base URLhttp://localhost:3000/v1

Authentication

All API endpoints require the X-API-Key header:

curl -X GET "http://localhost:3000/v1/geocoding?query=Barcelona" \
  -H "X-API-Key: your_api_key"

Example Requests

Geocode an Address

curl -X GET "http://localhost:3000/v1/geocoding?query=Passeig%20de%20Gracia%2092%2C%20Barcelona" \
  -H "X-API-Key: your_api_key"

Calculate a Route

curl -X GET "http://localhost:3000/v1/routing?origin=41.3851,2.1734&destination=41.4036,2.1744" \
  -H "X-API-Key: your_api_key"

Search for Nearby POIs

curl -X GET "http://localhost:3000/v1/proximity/nearest?lat=41.3851&lng=2.1734&categories=gas_station" \
  -H "X-API-Key: your_api_key"

Configuration

Environment Variables

VariableDescriptionDefault
PORTServer port3000
CERCALIA_API_KEYYour Cercalia API keyRequired
CERCALIA_BASE_URLCercalia API base URLhttps://lb.cercalia.com/services/v2/json
CERCALIA_SUGGEST_URLCercalia Suggest service URLhttps://lb.cercalia.com/suggest/SuggestServlet
LOG_FORMATLog format (json or text)text
DEBUGEnable debug loggingfalse
NODE_ENVEnvironment (development, production)development

Example .env File

# Required
CERCALIA_API_KEY=your_api_key_here

# Optional
CERCALIA_BASE_URL=https://lb.cercalia.com/services/v2/json
CERCALIA_SUGGEST_URL=https://lb.cercalia.com/suggest/SuggestServlet
PORT=3000
LOG_FORMAT=json
DEBUG=false

Docker Deployment

Build and Run

# Build the image
docker build -t cercalia-openapi .

# Run with environment file
docker run -p 3000:3000 --env-file .env cercalia-openapi

Docker Compose

# Production mode
docker-compose up -d

# Development mode (with hot-reload)
docker-compose --profile dev up

# View logs
docker-compose logs -f

Health Checks

The container includes Kubernetes-ready health checks:

EndpointPurpose
GET /v1/health/liveLiveness probe - Process is running
GET /v1/health/readyReadiness probe - Service is ready (includes backend check)
GET /v1/healthBasic health status

Error Handling

All errors follow a consistent JSON format:

{
  "statusCode": 400,
  "message": "Invalid coordinates",
  "error": "Bad Request",
  "timestamp": "2026-01-15T10:30:00.000Z",
  "path": "/v1/geocoding",
  "requestId": "abc123-def456"
}

Common Error Codes

StatusDescription
400Bad Request - Invalid parameters
401Unauthorized - Invalid or missing API key
403Forbidden - API key not authorized for this service
404Not Found - No results found
500Internal Server Error
503Service Unavailable - Backend unavailable

Development

Available Scripts

ScriptDescription
npm run start:devStart in development mode with hot-reload
npm run start:prodStart in production mode
npm run buildBuild the application
npm run testRun unit tests
npm run test:e2eRun end-to-end tests
npm run test:covRun tests with coverage
npm run lintLint and fix code
npm run formatFormat code with Prettier
npm run swagger:generateGenerate Swagger HTML documentation
npm run docker:buildBuild Docker image
npm run type-checkTypeScript type checking

Generating API Documentation

# Generate static Swagger HTML
npm run swagger:generate

This creates:

  • docs/swagger/openapi.json - OpenAPI specification
  • docs/swagger/index.html - Standalone Swagger UI

Resources

Source Code
View on GitHub
Core REST API
View Documentation
Support
Contact Us

Copyright (c) 2025 Nexus Geographics - MIT License

Last modified January 22, 2026: feat: SEO improvements (be5cf91)