Invoking APIs from the Command Line using cURL

by Interzoid Team

Posted on August 20th, 2019

Use CURL to Invoke APIs Quickly and Easily to Understand Value and Build Applications

cUrl, which stands for "client URL", is a command-line utility for sending and receiving data. It works with a wide range of protocols including http, https, and ftp. This makes it an ideal tool for executing and testing APIs without having to write any code, enabling a potential API consumer to get comfortable with a given API and easily discover and understand its behavior and value without a significant time investment. And while its beauty is in its simplicity, it can also be used in advanced ways such as enabling proxy support, performing FTP uploads, HTTP post commands, multiple forms of user authentication, and a whole lot more.

The tool works from the Command Line in most flavors of Linux, the Command Prompt in Windows, the Terminal in MacOS X, and other implementations of a Unix shell command line such as Bash.

To ensure that you have it installed on your machine, go to the command line and enter the following:

$ curl --version

In the unlikely event you don't already have it installed, get it from here.

For detailed usage information, you can read the documentation by entering the following:

$ curl --man

or in Windows:

> curl --help

For now however, let's keep things simple and execute some APIs from the command line. In these examples we will be using various APIs from Interzoid. You will need an API key from Interzoid, which only requires your email address to register and obtain one. Use your own API key when you see YOURAPIKEY in the code.

Note in the examples below, we will be using single quotes around the URL in the cURL API calls. This is a requirement for APIs with multiple parameters. In the case of Windows, you must use double quotes around the URL.

In this example, we will be obtaining a real-time currency quote from Interzoid's Get Currency Rate API. Simply enter the following from the command-line:

$ curl ''

or in Windows (this is the only time we will show the Windows variant syntax):

> curl ""

And here is the JSON data retrieved and returned from the API:

{"Symbol":"EUR","Name":"Euro","Country":"European Union","Rate":"0.895","Code":"Success","Credits":"72250"}

In this example, we will perform a currency conversion using the Convert Currency API:

$ curl ''

JSON data in response:


Here is an example of the Get Weather by Zip Code API:

$ curl ''

And the response:


As you can see, cURL is an easy way to take any API for a test drive before putting it to use.

Free API Credits
Register for an Interzoid API account and receive free trial credits
Sample Code on Github
Sample Code for invoking APIs on Interzoid in multiple programming languages
Global Page Load API
Measure Web asset performance from multiple locations around the globe.
More Info...