Skip to content

User Guide

Peter Thomas edited this page Mar 11, 2024 · 54 revisions

Karate Xplorer GIF

Karate Xplorer makes calling HTTP APIs easy and fun - and you can chain multiple calls to tell a story. Watch Video

One of the highlights is how you can view JSON as an easy-to-read grid. Karate Xplorer is a great way to show-off what your APIs can do to business users. You can also view payloads as raw-text, with syntax-coloring.

Both Request and Response are shown side by side for convenience. You can add user-friendly labels to each API call for even better readability. Scripting support allows you to scale from simple hard-coded requests to dynamic URLs, headers and payloads and un-limited "chained" calls.

The application runs locally - which means that all your data is secure, you can test APIs that run on localhost or within your network, and you won't be blocked by CORS restrictions.

Here is a summary of features:

  • Call HTTP APIs without writing code
  • View responses in user-friendly tabular form
  • Quickly edit and re-try calls
  • Save calls to share or re-play later
  • Dynamically chain multiple calls
  • Switch between environments
  • Validate expected API behavior
  • Document API workflows
  • Save all data locally
  • Easily install and run locally
  • Call APIs on local-host or within your firewall

Note

For a detailed feature list and roadmap,
refer to this page: Features

Installing

Download the ZIP file corresponding to your OS from the latest from the Releases Page.

Right now versions for Mac (darwin) and Windows (win32-x64) are available. If you need a version not yet supported, please contact us.

Extract the ZIP into a directory of your choice. Then, depending on whether you are on Windows or Mac, follow the instructions below.

By default the web-app starts on port 8090. You can go to this URL to start using Karate Xplorer: http://localhost:8090.

Windows

  • Directly click and open start.bat
  • Windows may show a warning message, but accept the error and proceed.

If the application does not start because port 8090 is in use, you can change the port by passing a number as a command-line argument. For example:

  • Open a cmd window
  • change directory to karate-xplorer
  • enter this command to use port 9000: start 9000

Mac

  • Open a terminal in the karate-xplorer folder and run ./start
  • If you get a warning, re-try after running this (one-time only): xattr -dr com.apple.quarantine jre/bin/java

If the application does not start because port 8090 is in use, you can change the port by passing a number as a command-line argument. For example:

  • ./start 9000

Demo Samples

Click on Open on the top menu-bar to choose from a set of built-in samples that show you the power of Karate Xplorer.

Simple Requests

Click on Run (to run all requests) or the ▶️ button to step through the calls one at a time. You can set the URL, Path and HTTP Method. The body can be edited as plain-text, and there is syntax support for JSON.

image
 

If you want the URL to be set "globally" you can do this via a global Config Variable.

Chaining

Chaining can be done by directly referring to specific parts of the previous response. This can be done using expressions in this form: ${response.body.someName}.

For example, here we use a value from the previous response as a path parameter. The placeholder-substitution system uses the "dollar" and "curly braces" convention, for example: ${foo}

image

Placeholders

Placeholder substitution is supported for all the following:

URL | Path | Body | Headers | Params

Examples of how you can dynamically set headers are shown below:

image
 

Header manipulation is essential for getting past many authorization schemes.

Here below are examples of how to shape query parameters:

image

Advanced Scripting

You can "save" data that persists for the whole sequence. This is commonly needed to perform CRUD via REST-ful HTTP calls.

For example you can use the After section to evaluate expressions. These are small snippets of simple JavaScript. Here we save id and booking for future reference. Note that the booking comes from the request ! This avoids the need for extensive cut-and-paste and can save you a lot of time.

image

JSON Manipulation

Here we are updating JSON by evaluating an expression. We change one value within the booking payload in the Before section.

image

JSON Re-Use

Karate Xplorer has a short-cut to insert a variable into a payload or anywhere expressions are supported.

  • If an expression is enclosed in round-brackets, it will be converted to JSON at run-time.
  • The expression has to begin and end with round-brackets

This is most commonly used to set the Request:Body.

See how easy it is to re-use a variable that happens to be JSON. Look at the Body below set to (booking).

image

Embedded Expressions

You can dynamically change JSON payloads using Karate-style JSON templating via variable substitution - for e.g. { foo: '#(bar)' }.

Here is an example of changing the totalPrice using the bookingPrice variable:

image

Global Variables

You can add multiple variables that will be initialized at the start of a run. The _url is a "special" config variable that will be used as a "default" if no URL is provided for an individual call. You can mix and match for convenience. For example you can change the URL for one single request, experiment with it and then change it back (or have it empty).

image
 

Note how we also set the data-type of bookingPrice to a number by using round-brackets. You do the same for boolean values.

And in the case where you want to set a value to null, use: (null).

JS Functions

Coming Soon

Environment Switching

You can manage all environments in one view.

image
 

Switching then becomes a matter of using the drop-down in the top menu-bar.

image

Saving Files

The "Save" menu gives you the option to save the sequence currently being edited to your local-drive.

Karate Xplorer sequence files have to have the .kxp extension.

image

Import

Click the [...] button on a step to bring up the "Import" option.

image
 

Then paste your API data into the text-field and click Submit.

image

Export

You can also convert Postman, OpenAPI, Swagger, cURL and HAR formats and export them to Karate scripts in one step. Click Open and then the Import button. You can paste API data into the left text-area and click Import to see the Karate equivalent.

 

You also have the option to open the API data in Xplorer itself and make requests.