What is Insomnia REST?

Key takeaways:

  • Insomnia REST is a user-friendly interface that simplifies the design, testing, and debugging of APIs with an intuitive layout.

  • Insomnia REST allows customization of headers, parameters, and authentication methods for precise API interactions.

  • Provides detailed responses, including beautified JSON/XML, for easier analysis and debugging.

Insomnia is an open-source REST API client used for designing, testing and debugging APIs. It supports various protocols, including GraphQL, REST, WebSockets, server-sent events (SSE), gRPC, and any other HTTP-compatible protocol. Its user-friendly and easy-to-use interface and advanced functionality make it a go-to choice for developers and testers alike.

Why use Insomnia?

In addition to making working with APIs as simple as possible, Insomnia also allows developers full control over API requests, enabling them to customize headers, query parameters, request bodies, authentication methods, and more.

Insomnia provides a comprehensive and structured response to API requests, including status codes, headers, and response bodies. It also allows for beautifying JSON and XML responses, making it easier to analyze and debug API data. Additionally, support for environment variables and workspaces, as well as code generation in various programming languages to help developers integrate API calls into their applications quickly, is also a part of Insomnia’s arsenal.

Key features of Insomnia REST

The following are some of the key features of Insomnia REST:

  • API design: Creates and manages API specifications using OpenAPI and generates interactive documentation directly from the API definition for easy reference.

  • Request building and testing: Creates HTTP requests with various methods (GET, POST, PUT, DELETE, etc.) and sets headers, parameters, and bodies.

  • Environments and variables: Manages multiple environments with different base URLs, authentication credentials, and other variables.

  • Authentication and authorization: Supports various authentication mechanisms, including basic auth, Bearer tokens, API keys, and OAuth.

  • Code generation: Generates client-side code over twelve languages (e.g., JavaScript, Python, Ruby) from your API definition.

Installing Insomnia

Installing Insomnia is pretty straightforward. Just download the installer from the official website. For Windows and MacOS, Click on the installer and follow the on-screen instructions to install Insomnia. For Linux, use the package manager specific to your Linux distribution to install Insomnia using the installer.

Sending API requests

As stated before, Insomnia offers a user-friendly interface for sending API requests. The following demonstration provides a step-by-step guide to creating a GET request using Insomnia:

Dismiss the pop-up and click the “Don't share usage analytics” option
Dismiss the pop-up and click the “Don't share usage analytics” option
1 of 6

Please note that Insomnia’s UI might change in the future, and the given slides are only up-to-date with the UI available when this Answer was created.

In the following image, we send a GET request to http://localhost:3000/api that returns us the JSON data of various books:

Sending a GET request using Insomnia
Sending a GET request using Insomnia

We can also send the PUT requests to modify data using Insomnia. In the following demonstration, we change the request type to PUT, append /Chinua Achebe at the end of the URL to modify this entity, and add a JSON body with modified pages, title, and year fields to the request. As can be seen in the third slide, the data is modified:

Select “JSON” from the drop-down menu to send a JSON body with the PUT request
Select “JSON” from the drop-down menu to send a JSON body with the PUT request
1 of 3

Try it yourself

Below is an application for a books library with REST APIs implemented. Click the “Run” button to start the server and launch Insomnia. Try sending different API requests to test the implementation using Insomnia. The various endpoints for each request type are given below:

GET: http://localhost:3000/api (to get all the data)
GET: http://localhost:3000/api/{author} (to get the data of the specifed author only)
PUT: http://localhost:3000/api/{author} (to modify the data of the specifed author. dont forget to add a JSON body)
POST: http://localhost:3000/api (to add new data to the database. dont forget to add a JSON body)
DELETE: http://localhost:3000/api/{author} (to delete data of the specified author}
DELETE: http://localhost:3000/api (to delete all the data in the database}
URLs for various API requests
#!/usr/bin/env node

/**
 * Module dependencies.
 */

var app = require('../app');
var debug = require('debug')('books-project:server');
var http = require('http');

/**
 * Get port from environment and store in Express.
 */

var port = normalizePort(process.env.PORT || '3000');
app.set('port', port);

/**
 * Create HTTP server.
 */

var server = http.createServer(app);

/**
 * Listen on provided port, on all network interfaces.
 */

server.listen(port);
server.on('error', onError);
server.on('listening', onListening);

/**
 * Normalize a port into a number, string, or false.
 */

function normalizePort(val) {
  var port = parseInt(val, 10);

  if (isNaN(port)) {
    // named pipe
    return val;
  }

  if (port >= 0) {
    // port number
    return port;
  }

  return false;
}

/**
 * Event listener for HTTP server "error" event.
 */

function onError(error) {
  if (error.syscall !== 'listen') {
    throw error;
  }

  var bind = typeof port === 'string'
    ? 'Pipe ' + port
    : 'Port ' + port;

  // handle specific listen errors with friendly messages
  switch (error.code) {
    case 'EACCES':
      console.error(bind + ' requires elevated privileges');
      process.exit(1);
      break;
    case 'EADDRINUSE':
      console.error(bind + ' is already in use');
      process.exit(1);
      break;
    default:
      throw error;
  }
}

/**
 * Event listener for HTTP server "listening" event.
 */

function onListening() {
  var addr = server.address();
  var bind = typeof addr === 'string'
    ? 'pipe ' + addr
    : 'port ' + addr.port;
  debug('Listening on ' + bind);
}
Testing REST APIs using Insomnia

Conclusion

Insomnia REST is an invaluable tool for developers working with APIs. Its user-friendly interface, powerful features, and support for collaboration make it a standout choice for API testing and development. Whether we're working with REST or GraphQL, Insomnia streamlines the workflow, allowing developers to focus on building robust applications.

Frequently asked questions

Haven’t found what you were looking for? Contact Us


Is Insomnia free to use?

Yes, Insomnia is open-source and free to use, with optional premium features.


Can we customize request headers in Insomnia?

Yes, we can easily add and modify headers for the API requests.


Can we export and import Insomnia projects?

Yes, Insomnia allows us to export and import workspaces for easy sharing and backup.


Free Resources

Copyright ©2025 Educative, Inc. All rights reserved