REST Book is a Visual Studio Code extension that allows you to perform REST calls in a Notebook interface.
- Create and run REST Calls within cells.
- Organize multiple REST Calls within one file.
- Intermingle markdown for documenting your calls.
- View rich HTML and image responses directly inside the Notebook.
- Optionally use the Interactive Window interface.
- Basic Authentication.
- Use data from one call in the next.
- Save API keys and other sensitive information outside of the Notebook to use securely in calls.
Must be using the latest version of Visual Studio Code Insiders edition.
- Create a new file to store your REST Calls with a
You can also use the command:
REST Book: Create a new blank REST Notebook.
- Add a code cell by hovering over the middle of the Notebook and clicking the
- Add your intended URL as the first line of the cell. By default without specifying a method, it will be a GET call.
To use the Interactive Window interface:
- Run the command:
REST Book: Create an Interactive Window
- Enter your line(s) into the input field at the bottom of the window.
- Click the adjacent button to run them.
Changing output view to rich rendered HTML or rich JSON view
To toggle between the different views for the results of calls you can change mimetype like so:
is equivalent to:
In subsequent lines immediately following the first line add any parameters or queries starting with
& like this:
In the lines following without an empty line will be considered as the Request Headers:
The last lines after a new line separator is the body of the call. Like the following:
text: "Foo is the most bar of the Foos"
Or you can load the body from another file like so:
You can also assign the responses from calls to a variable and use the data from that response in future calls. To do this you would just declare a variable with
let and the name of your variable and then a
= like so:
let foo = GET google.com
And then in future cells you can reference
foo in your calls with a
$ sign. Here's a short example:
Using API keys and other secrets
If you'd like to use secret information in your calls like API keys but you don't want to use and save the raw text of these keys in the REST Notebooks, you can use secrets to save and access API keys.
To save secrets, look for the command
REST Book: Secrets in the command palette with Cmd+Shift+P (MacOS) or Ctrl+Shift+P (Windows). Add a new secret and a name for that secret.
Then when use your secrets in your calls using the
$SECRETS variable. In this example I'm saving a secret with the name
mySecret and then accessing this secret to send to my Express server with
$SECRETS.mySecret. You can see my server received my secret value of "hooray" correctly but the secret text is not visible anywhere in the Notebook.
And you can see that the actual secret is not saved in the results of the call. Every place that used a secret will be replaced by
[Secret <secret name>]; this is for all parameters, headers, and bodies sent. Here you can see that my secret text "hooray" was replaced by
[Secret mySecret] in the view of the request I sent.
To test these interactions, you can play around with this simple server: SandboxServer
Unable to save responses. This should be fixed soon in the next few versions of VS Code Insiders.
Any Other issues
Please submit your issue on the tanhakabir/rest-book repository with exact reproduction steps.