Skip to content

Intro

Sometimes, or actually quite often, the frontend or other service isn't yet ready or in a state where we could "trial" our API with the proper client. For this reason we have to seek for alternative solutions. Few of the solutions could be used are.

Postman

Postman is a great tool when trying to dissect RESTful API’s made by others or test ones you have made yourself. It offers a sleek user interface with which to make HTML request, without the hassle of writing a bunch of code just to test an API’s functionality.

Although Postman is not just a REST Client, it contains a full-featured testing sandbox that lets you write and execute Javascript based tests for your API.

Postman comes with a nifty CLI tool — Newman. Newman is the Postman’s Collection Runner engine that sends API requests, receives the response and then runs your tests against the response. Newman lets developments easily integrate Postman into continuous integration systems like Jenkins. Some of the important features of Postman & Newman include:

  • Ability to test any API and see the response instantly.
  • Ability to create test suites or collections using a collection of API endpoints.
  • Ability to collaborate with team members on these collections.
  • Ability to easily export/import collections as JSON files.

Read more: Testing API’s using Postman


cURL

cURL, which stands for client URL and can be written as curl, is a command line tool for file transfer with a URL syntax. It supports a number of protocols including HTTP, HTTPS, FTP, and many more. HTTP/HTTPS makes it a great candidate for interacting with APIs!

Curl can be used on just about any platform on any hardware that exists today. This means, regardless of what you are running and where, the most basic curl commands should just work. None of the usual “it doesn’t work on my machine”.

You use curl in a terminal or command prompt.

curl -d '{ "email": "testing@gmail.com", "password":"testing123" }' \
-X POST \
-H "Content-Type: application/json" \
https://en3u0tzev07c6.x.pipedream.net/v1/users

Why would I use cURL and not Postman?

No one is telling you what you can and cannot use, but as referenced above, curl is fairly standard in its functionality and available across tons of platforms. There is no UI to get lost in for basic commands with authentication and you can see exactly what’s going on. But if you find a UI more comforting and familiar, by all means go for it.

To be honest, you don’t even have to use curl. It’s just there as an option. Just like the snippets in Go, Python, Java, etc.


fetch

Fetch is a method that can be found in most modern browsers.

fetch() allows you to make network requests similar to XMLHttpRequest (XHR). The main difference is that the Fetch API uses Promises, which enables a simpler and cleaner API, avoiding callback hell and having to remember the complex API of XMLHttpRequest.

The Fetch API has been available in the Service Worker global scope since Chrome 40, but it'll be enabled in the window scope in Chrome 42.

const headers = new Headers()
headers.append("Content-Type", "application/json")

const body = { "email": "testing@gmail.com", "password":"testing123" }

const options = {
  method: "POST",
  headers,
  mode: "cors",
  body: JSON.stringify(body),
}

fetch("en3u0tzev07c6.x.pipedream.net/v1/users", options)

Read more: javascript.info: Fetch