Member-only story
Explore REST APIs with cURL
Clueless about working with Web Services?

Nothing makes me feel more like fish out of water than working with web technologies. This this is an overview as much for your benefit as for my own about how to work with REST APIs primarily using the cURL Unix command. I will also look at how you can do this from some different programming languages.
Read more:
- Working with the HTTP Protocol and Forms in Julia — Setting up HTTP requests, mocking responses. How do you transfer image data? What about HTML forms? How do you process them in a request handler?
- A Guide to Different Web Technologies — How is WebSockets different from Unix sockets. AJAX vs WebSockets, jQuery, React etc how do they all related and overlap?
To avoid that you have to jump around all over the place, I will try to put all the key information right in this article.
What is a REST API?
It is not like a programming API when you are using C/C++, Python etc. Rather it is an API exposed as a set of URLs. That means you could actually interact with a REST API using nothing but your Web browser. REST is just a simple way of interacting with an application running on a server using Web technology such as the HTTP protocol.
You do this primarily by using one of two HTTP requests:
GET
This is what happens when you write a URL in your web browser. A GET request is sent to the web sever and some data is returned, usually a web page in HTML which your web browser shows.POST
Is used to send data. It also involves specifying a URL but this also involves supplying some data to send.
By request I mean that you send some data to a server over your TCP/IP connection with the intention on getting some specific data back.
You could e.g. visit my home page by writing the URL address http://blog.translusion.com
in your web browser, or you could use the Unix curl
command to download the HTML page:
$ curl http://blog.translusion.com
If you add the -i
switch as well you will also get the HTTP header which looks something like this: