# Use curl to interacting with an API by Seth Kenlon Curl is commonly referred to as a non-interactive web browser for the Linux terminal. Its developers, however, describe it more accurately as a tool to transfer data to or from a server, with access to a huge variety of protocols, including HTTP, FTP, SFTP, SCP, IMAP and POP3, LDAP, SMB, SMTP, and many more. It's a useful tool to the average sys admin, whether you use it for a quick way to download a file you need from the Internet, or to script automated updates. Curl is also an important tool for testing remote APIs, so if a service you rely on or provide is unresponsive, you can use the ``curl`` command to test it. ## API The term [API](https://opensource.com/resources/what-api) is short for *Application Programming Interface*, meaning that an API is anything that takes specific actions or responds to queries for information provided by end users. It's a powerful means of abstraction, and can be the difference between giving someone, for example, access to your database server and just letting people request information from your database through a highly structured URL. An API also enables people to use features of a service without requiring them to learn complex commands nor exposing sensitive data. And more importantly, an API allows computers to talk to computers in a structured and programmed way, so that instead of you spending *your* time scraping the web for data, you can script it. ## Installing curl It's quite likely that you already have Curl installed. If you don't have it installed, it's probably in your software repository. On Fedora, CentOS, or RHEL: ``` $ sudo dnf install curl ``` ## Curl basics You can download a file with Curl by providing a link to a specific URL. Whatever exists at the URL you provide is, by default, downloaded and printed in your terminal. HTML is relatively verbose, so that's often a lot of text. You can pipe the output to ``less`` or ``tail`` or any other command you find useful. ``` $ curl "http://example.com" | tail -n 4
This domain is for use in illustrative examples in documents. You may use this domain in literature without prior coordination or asking for permission.