Yes, Insomnia is open-source and free to use, with optional premium features.
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.
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.
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 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.
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:
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:
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:
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}
#!/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); }
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.
Haven’t found what you were looking for? Contact Us
Free Resources