The Apimimic CLI utility provides a way to intercept HTTP requests, return mocked responses, and proxy unmocked requests running on your local machine.
This is especially useful if you are running an api server on your local machine. Use the CLI to avoid the complexity of setting up CORS, as all requests go through the local proxy.
This CLI utility connects to online Apimimic service and mocks or proxies endpoints accordingly to how they are specified in the Apimimic dashboard.
Important: For the CLI utility to work in proxy mode, make sure to enable Proxy Mode in the Dashboard. The Base URL can be left empty or filled - it doesn't affect functionality as long as CLI utility is run with --server parameter set.
Apimimic CLI utility can be used in serveral different ways. Fastest way would be to use pre-compiled binaries.
1. Get the latest pre-compiled binary for your platform from the Github
2. Run the file with the following command:
apimimic run --project YOUR_PROJECT_KEY --server http://localhost:8000
The cli server will run on port 8080. If Proxy Setting is enabled in the Dashboard, target server for proxied requests is going to be http://localhost:8000
1. Clone the repository from Github:
git clone https://github.com/rarar89/apimimic-cli.git cd apimimic-cli
2. Install Rust and Cargo:
For Unix-like OS (Linux, macOS):
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh
For Windows:
Download and run rustup-init.exe from rustup.rs
After installation, restart your terminal and verify Rust is installed:
rustc --version cargo --version
3. Build the project using Cargo:
cargo build --release
4. The compiled binary will be available in the target/release
directory. Run binary with a following command:
apimimic run --project YOUR_PROJECT_KEY --server http://localhost:8000
If you already have Rust and Cargo installed, you can install Apimimic CLI directly using Cargo:
cargo install apimimic
After installation, you can run the CLI with:
apimimic run --project YOUR_PROJECT_KEY --server http://localhost:8000
Note: Make sure you have Rust and Cargo installed first. If you don't, follow the installation instructions in method B above.
Project key is a unique identifier for your project. It is used to authenticate your requests to the Apimimic service. It can be found in the Apimimic dashboard when opening the project.
Set your project key once and reuse it for all future sessions:
apimimic set-project YOUR_PROJECT_KEY
Run command can have following parameters:
Parameter | Description | Default | Required |
---|---|---|---|
--project | Apimimic project Key | * | |
--listen | Local address to listen on | 127.0.0.1:8080 | |
--server | Target server URL for proxying | ||
--remote | Remote API Mimic URL | https://cli.apimimic.com | |
--remote-ping | Remote ping URL for health checks | https://cli-checkin.apimimic.com |
* Project key is not required if the project key is saved beforehand with set-project command.
Run command usage example:
apimimic run --project YOUR_PROJECT_KEY --listen 127.0.0.1:8080 --server http://localhost:8000