Skip to content

User Guide

Peter Thomas edited this page Nov 27, 2023 · 54 revisions
 

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

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 here: v0.1.0-SNAPSHOT.

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. Windows users can directly click on start.bat. Windows may show a warning message, but accept the error and proceed. Mac users can open a terminal in the karate-xplorer folder and run ./start.

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

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. Windows users can open a cmd window, change directory to karate-xplorer and do this to use port 9000: start 9000.

Mac users can do this: ./start 9000.

Click on Load / Save on the top menu-bar to experience built-in samples that show you the power of Karate Xplorer.

Simple Requests

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

image

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 configUrl is a "special" 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.

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.

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

Coming Soon

Clone this wiki locally