Requests

The requests module is the de facto standard for sending HTTP requests in Python.

It abstracts the complexities of making requests behind a beautiful, simple API so that you can focus on interacting with services and consuming data in your application.

The HTTP request returns a Response Object with all the response data (content, encoding, status, etc).

Installation

Let’s begin by installing the requests module. To do so, run the following command in the terminal:

pip install requests

Once requests is installed, you can use it in your program. Importing requests looks like this:

import requests

Requests

requests.delete()
Makes a delete request to a web server; it returns a response object.
requests.get()
Makes a get request to a web server; it returns a response object.
requests.head()
Makes a head request to a web server; it returns a response object.
requests.post()
Makes a post request to a web server; it returns a response object.
requests.put()
Makes a put request to a web server; it returns a response object.
requests.request()
Makes seven main kinds of request to a web server: get, options, head, post, put, patch, and delete; it can also handle custom HTTP verbs if needed, and returns a response object.
Edit this page on GitHub

Contributors

Interested in helping build Docs? Read the Contribution Guide or share your feedback.

Learn Python on Codecademy

Edit this page on GitHub

Contributors