Mock APIs with Map Local

Hands-on: import the Demo Shop and try every feature

A ready-made folder of mocks: login, products, product detail and checkout, with error states.

This demo is a small fake shop API on example.com, a domain reserved for documentation. It uses every Map Local feature: URL patterns, route parameters, response variants with all kinds of conditions, templates, delays and headers. Everything in it is dummy data.

Download aegisceptor-demo-shop.json

1. Import it

  1. Open Map Local and click Import.
  2. Choose aegisceptor-demo-shop.json. The preview lists 6 rules in the folder Demo Shop.
  3. Click Import.

Make sure a browser is captured (Capture Chrome traffic), or use the Terminal commands below.

2. Try it

Open the GET links in a captured browser. For POST requests, use the curl commands; they go through AegisCeptor on port 8080. -k skips the certificate check for these test calls only.

Login · body conditions and templates

Dummy account: demo@example.com / demo1234.

curl -k -x http://127.0.0.1:8080 -X POST https://example.com/api/login \
  -H 'Content-Type: application/json' \
  -d '{"email":"demo@example.com","password":"demo1234"}'

Returns 200 with a fresh demo-token-{{uuid}}, your email copied from the request with {{body 'email'}}, and the time from {{now}}. Change the password to anything else and you get the Wrong password response (401): its condition is Body · password · not equals · demo1234.

Profile · header that must exist

curl -k -x http://127.0.0.1:8080 https://example.com/api/me
curl -k -x http://127.0.0.1:8080 https://example.com/api/me -H 'Authorization: Bearer demo-token'

Without Authorization you get Logged out (401, condition Header · Authorization · does not exist). With it, the profile.

Product list · query param and a slow network

curl -k -x http://127.0.0.1:8080 https://example.com/api/products -H 'X-Demo-Scenario: slow'

Answers after 3 seconds: the Slow network response has its own delay.

Product detail · route parameter

Checkout · nested JSON field, "any" conditions and a delay

# Paid (201, about 0.8 s)
curl -k -x http://127.0.0.1:8080 -X POST https://example.com/api/checkout \
  -H 'Content-Type: application/json' -d '{"card":{"number":"4242424242424242"}}'

# Card declined (402): Body · card.number · equals · 4000000000000002
curl -k -x http://127.0.0.1:8080 -X POST https://example.com/api/checkout \
  -H 'Content-Type: application/json' -d '{"card":{"number":"4000000000000002"}}'

# Server error (500): header OR query, "Any condition matches"
curl -k -x http://127.0.0.1:8080 -X POST https://example.com/api/checkout -H 'X-Demo-Scenario: error' -d '{}'
curl -k -x http://127.0.0.1:8080 -X POST 'https://example.com/api/checkout?fail=1' -d '{}'

The card numbers are standard test numbers, not real cards.

Banners · wildcard and extra headers

example.com/api/banners/home matches example.com/api/banners/* and adds the headers X-Demo: true and Cache-Control: no-store. Open the request in AegisCeptor to see them.

3. Play with it

  • On Product list, click ⚑ Set as default on Empty page: now every page is empty until you switch back.
  • Switch the Demo Shop folder off: example.com/api/… goes to the real server again (and returns its normal 404 page).
  • Duplicate a rule, change it to your own API, and export the folder to share it with your team.

What is inside

RuleResponsesShows
POST example.com/api/loginBase 200 · Wrong password 401Body condition, {{uuid}}, {{body}}, {{now}}
GET example.com/api/meBase 200 · Logged out 401Header does not exist
GET example.com/api/productsBase 200 · Empty page · Slow networkQuery condition, per-response delay
GET example.com/api/products/:idBase 200 · Not found 404Route parameter, {{urlParam}}, {{randomInt}}, {{faker}}
POST example.com/api/checkoutBase 201 · Card declined 402 · Server error 500Nested body field, any conditions, delay
GET example.com/api/banners/*Base 200Wildcard, extra headers