Developing a REST API Server

Overview

Web services that use the representational state transfer (REST) format provide a flexible and agnostic way of exchanging data between computers and different programming languages. Many applications and services on the internet use this clear and concise format to expose their data to other applications. Using Go to interact with REST APIs opens the door to a large number of services that provide many resources for our command-line tools. It allows us to create flexible tools that were previously challenging to develop by integrating information from multiple sources.

In this chapter, we’ll apply the concepts to design a command-line tool that connects to a REST API using Go’s net/http package. We’ll explore more advanced concepts such as the http.Client and http.Request types to fine-tune specific connection parameters like headers and timeouts, and we’ll use the encoding/json package to parse JSON response data.

Get hands-on with 1400+ tech skills courses.