How do I test APIs?

APIs can be tested in several ways and using different tools:

  • Insomnia - Powerful browser extension or mac app to test APIs.
  • SOAPUI - Open-source web service testing application.
  • Web Browser - Test APIs directly in a browser if authentication for the API is none or API key based.
  • cURL - Test APIs from your local computer using command line tools.

 

Insomnia

Easy to use, yet very powerful API testing tool.  More information and documentation can be found on the Insomnia website.

SOAPUI

SoapUI is an open-source web service testing application for service-oriented architectures and representational state transfers.  More information and documentation can be found on the SOAPUI website.

Web Browser

In the browser address bar, compose a query URL for the API to access.   The format of query URL is:

https:// hostname / api ? apikey=value

hostname - hostname listed for the API service

api - name of the API that is part of url provided in the API Documentation
? - only used in case of options (key=value pairs) separated with &
options (key=value pairs):
type=json - API data formats
key=0a1b3c4d5e6f7g8h9i0j1k2l3m412356 - API key provided after registering an application. 
 
Example constructed query:
https://gw.its.yale.edu/soa-gateway/buildings/feed?type=json&apikey=0a1b3c4d5e6f7g8h9i0j1k2l3m412345
*apikey in example is not a valid API key

cURL

If you are old-school like some of us terminal users, cURL is your friend. cURL is used in command line or scripts to transfer data. This tool will allow testing of APIs from your local computer. 
 
Apple Mac users, open Terminal window (Applications –> Utilities –> Terminal) and type in: curl
Windows users may need to download and install cURL.  Once installed open DOS Command Window and type in: curl
The following feedback should be returned: curl: try ‘curl –help’ or ‘curl –manual’ for more information
 
To use cURL please refer to the cURL manual for further details.
 
Example queries using cURL:
//get Building Room Data in XML
curl --include --request GET 'https://gw.its.yale.edu/soa-gateway/buildings/feed?method=getRoomData&apikey=0a1b3c4d5e6f7g8h9i0j1k2l3m412345'

//get Laundry Room Data in JSON
curl --include --request GET 'https://gw.its.yale.edu/soa-gateway/laundry/school?type=json&method=getRoomData&apikey=0a1b3c4d5e6f7g8h9i0j1k2l3m412345'
*apikey in example is not a valid API key