Skip to main content
The Fake API is a simple static file server that provides mock backend data for testing KrakenD configuration. It serves JSON files from the data/ directory, simulating real backend APIs with various response structures.

Base URL

http://localhost:8000

How It Works

The Fake API is built using a simple BusyBox httpd server that serves static files:
fake_api:
  image: busybox:latest
  volumes:
    - ./data:/var/www/
  ports:
    - "8000:80"
  command: httpd -f -h /var/www/
Endpoints are automatically created based on the file structure in the data/ directory:
  • Files are accessible at their path relative to data/
  • File extensions are preserved (.json, .xml, .rss)
  • Directories create nested paths

Available Endpoints

The following endpoints are available based on the current file structure:

Root Level Endpoints

Articles

GET /articles.json
Returns JSON:API formatted article data with author relationships. Example Response:
{
  "data": [{
    "type": "articles",
    "id": "1",
    "attributes": {
      "title": "JSON API paints my bikeshed!",
      "body": "The shortest article. Ever.",
      "created": "2015-05-22T14:56:29.000Z",
      "updated": "2015-05-22T14:56:28.000Z"
    },
    "relationships": {
      "author": {
        "data": {"id": "42", "type": "people"}
      }
    }
  }],
  "included": [
    {
      "type": "people",
      "id": "42",
      "attributes": {
        "name": "John",
        "age": 80,
        "gender": "male"
      }
    }
  ]
}

Array Response

GET /array.json
Returns a JSON array (not an object). Useful for testing array response handling.

Campaign

GET /campaign.json
Returns campaign data.

Collection

GET /collection.json
Returns collection metadata. Example Response:
[
  "This",
  "JSON",
  "is",
  "not",
  "an",
  "object",
  "but",
  "an",
  "array"
]

Colors

GET /colors.json
Returns color data.

Token

GET /token.json
Returns authentication token data.

Broken JSON

GET /broken.json
Returns intentionally malformed JSON for error handling testing.

User Endpoints

Get User by ID

GET /user/1.json
Returns detailed user information including address and phone numbers. Example Response:
{
  "id_user": 1,
  "firstName": "John",
  "lastName": "Smith",
  "age": 25,
  "address": {
    "streetAddress": "21 2nd Street",
    "city": "New York",
    "state": "NY",
    "postalCode": "10021"
  },
  "phoneNumber": [
    {
      "type": "home",
      "number": "212 555-1234"
    },
    {
      "type": "fax",
      "number": "646 555-4567"
    }
  ]
}

Social Media Endpoints

Twitter Feed

GET /social/twitter.json
Returns mock Twitter API search results. Example Response:
{
  "results": [
    {
      "text": "@twitterapi  http://tinyurl.com/ctrefg",
      "to_user_id": 396524,
      "to_user": "TwitterAPI",
      "from_user": "jkoum",
      "metadata": {
        "result_type": "popular",
        "recent_retweets": 109
      },
      "id": 1478555574,
      "from_user_id": 1833773,
      "created_at": "Wed, 08 Apr 2009 19:22:10 +0000"
    }
  ],
  "since_id": 0,
  "max_id": 1480307926,
  "refresh_url": "?since_id=1480307926&q=%40twitterapi",
  "results_per_page": 15,
  "page": 1,
  "query": "%40twitterapi"
}

Facebook Feed

GET /social/fb.json
Returns mock Facebook API data.

Flickr Photos

GET /social/flickr.json
Returns mock Flickr photo data.

Google Maps

GET /social/maps.json
Returns mock Google Maps API data.

YouTube Videos

GET /social/youtube.json
Returns mock YouTube API video data.

Shop Endpoints

Products List

GET /shop/products.json
Returns a list of products.

Product by ID

GET /shop/products/1.json
Returns details for a specific product.

Campaigns List

GET /shop/campaigns.json
Returns a list of campaigns.

Campaign by ID

GET /shop/campaigns/1.json
Returns details for a specific campaign.

Destination Endpoints

Destination by ID

GET /destinations/1.json
Returns destination information.

Hotel Endpoints

Hotel by ID

GET /hotels/1.json
Returns hotel information.

JWK (JSON Web Key) Endpoints

Public Key

GET /jwk/public.json
Returns public JSON Web Key for JWT verification.

Private Key

GET /jwk/private.json
Returns private JSON Web Key.

Symmetric Key

GET /jwk/symmetric.json
Returns symmetric JSON Web Key.

Adding Custom Endpoints

To add your own mock endpoints:
  1. Create a JSON file in the data/ directory:
    echo '{"message": "Hello World"}' > data/hello.json
    
  2. Access it immediately at:
    http://localhost:8000/hello.json
    
  3. Create nested paths using directories:
    mkdir -p data/api/v1
    echo '{"status": "ok"}' > data/api/v1/health.json
    
    Access at:
    http://localhost:8000/api/v1/health.json
    

File Format Support

The Fake API can serve:
  • JSON files (.json) - Most common format
  • XML files (.xml) - For XML-based APIs
  • RSS feeds (.rss) - For feed aggregation testing

Directory Structure Example

data/
├── articles.json          # http://localhost:8000/articles.json
├── array.json             # http://localhost:8000/array.json
├── user/
│   └── 1.json             # http://localhost:8000/user/1.json
├── social/
│   ├── twitter.json       # http://localhost:8000/social/twitter.json
│   └── fb.json            # http://localhost:8000/social/fb.json
└── shop/
    ├── products.json      # http://localhost:8000/shop/products.json
    └── products/
        └── 1.json         # http://localhost:8000/shop/products/1.json

Testing with curl

Fetch any endpoint using curl:
# Get articles
curl http://localhost:8000/articles.json

# Get user data
curl http://localhost:8000/user/1.json

# Get social media feed
curl http://localhost:8000/social/twitter.json

# Get product details
curl http://localhost:8000/shop/products/1.json

Usage in KrakenD Configuration

Reference these endpoints in your KrakenD configuration as backend hosts:
{
  "endpoint": "/users/{id}",
  "backend": [
    {
      "url_pattern": "/user/{id}.json",
      "host": ["http://fake_api:80"]
    }
  ]
}
Note: Inside Docker Compose, use http://fake_api:80 as the host (service name), not localhost:8000.

Build docs developers (and LLMs) love