Search⌘ K
AI Features

Connect to a Server

Explore how to establish a client-server connection using Python's requests library. Learn to send HTTP GET requests to REST API endpoints and handle responses without additional client configuration, focusing on simple and effective server communication.

We'll cover the following...

REST follows the client-server model. The server provides endpoints to connect to and serves data as per the request. The client connects to the endpoint and requests data. The request and response always follow the HTTP request-response model. For simplicity, in place of the API endpoint, the term “service” will be used.

The task of connecting to a server can be divided into two types:

  • Without configuration
  • With configuration

This distinction occurs due to a variety of reasons, including but not limited to, authentication mechanisms used by the server and the certificate type of the server. In this lesson, we’ll look at how to connect to a server without the client needing to configure itself. For completeness, the client will try to fetch data, i.e., issue a GET. We’ll be connecting to the air quality service provided by MET Norway. The URI is as follows:

...