Examples Intro

Overview

The distro for the Standalone API Simulator™ contains few examples. Here is how to run them locally.

Prerequisites

Download the distro for your platform and unzip/untar the file to install API Simulator.

For simplicity, we will assume that the installation of API Simulator is under the root directory. Adjust the directory paths accordingly if the installation is in a different directory.

We recommend adding the API Simulator scripts to the command path. While you don’t have to do this, it will make running the examples a bit easier.

Linux:

export PATH=/apisimulator/apisimulator-http-1.3/bin:$PATH

Windows:

set PATH=\apisimulator\apisimulator-http-1.3\bin;%PATH%

Starting API Simulator

Start an API Simulator instance by executing the apisimulator script passing in the start argument, and fully qualified path to the simulation’s directory or path relative to the current directory:

apisimulator start examples/<simulation-name>

On Linux, the command starts API Simulator in the foreground (append & to the command to background the process). On Windows, the command starts API Simulator in a new Command Prompt window.

API Simulator listens for requests on its default port 6090. The API Simulator’s Admin Server, which allows for clean shutdown of the simulator, runs on its default port 6190.

Stopping API Simulator

To stop API Simulator when done running an example simulation, execute:

apisimulator stop examples/<simulation-name>

Running the Examples

One way to run the examples is via cURL - a well-known command line tool for "…​transferring data with URL syntax" over various protocols (see https://curl.haxx.se/). It is included in many Linux distributions. You can download the latest version here, including for Windows. Please see the cURL documentation for a description of the command line arguments.

Another way to run the examples is by using the simple API Client tool distributed with API Simulator. The README.txt file in the directory of each example contains more information.

Notice that double quotes surrounding API Simulator script arguments are required if directory paths or file names contain any spaces.

Double quotes inside curl command line arguments are escaped like this: \".


We would love to hear your feedback! Shoot us a quick email to [feedback at APISimulator.com] to let us know what you think.

Happy API Simulating!