cURL is a command line tool that can be used, among other things, to make HTTP requests. Its basic syntax is:

$ curl http://url/api/resource

When we execute this command, we get the raw response to the http request in the command line.

If you want a better and deeper insight on this cURL command, I recommend you take a look at its man page. Here, I’m just going to talk about the options that I use to test APIs and find most useful.

The first option I’d like to talk about is -I. It reduces the response to headers.

$ curl -I
HTTP/1.1 200 OK
Content-Type: text/html; charset=utf-8
Status: 200 OK

Another important option is -H. It allows us to add request headers, like Content-Type, accept headers, api-key and so on. Here you have an example of a cURL request to a server, where we want to get a json response from the version 3 of the API using a client key:

$ curl http://server/api/clients
-H "Content-Type: application/json"
-H "Accept: application/; version=3"
-H "Api-Client-Key: 999AAAWWW"

Once we have set the right headers, it’s quite straight forward to execute actions over REST resources. In the next lines, I’ll omit the headers in order to improve readability.


curl http://host/users/user_id


curl http://host/users POST -d 'params[name]=James'


curl http://host/users/uiser_id PUT -d 'params[name]=James'


curl DELETE http://host/users/uiser_id

To finish this post, I’d like to leave a link to a tool that I really like: the Chrome plugin Postman - REST client. It’s perfect for those who are not command line friends and/or are looking for a nice interface to make requests to their APIs.