Published Sep 14, 2022Updated Apr 2, 2023
Contribute to Docs
requests module is the de facto standard for sending HTTP requests in Python.
It abstracts the complexities of making requests behind an API so that code can focus on interacting with services and consuming data in the application.
The HTTP request returns a Response Object with all the response data (content, encoding, status, etc).
requests module is done by running the following pip command in the terminal:
pip install requests
Or for Python 3:
pip3 install requests
requests is installed, it can be used in a program and imported like this:
- Sends a DELETE request to a web server and returns a response object.
- Sends a GET request to a web server and it returns a response object.
- Sends a HEAD request to a web server and it returns a response object.
- Sends a POST request to a web server and returns a response object.
- Sends a PUT request to a web server and returns a response object.
- Sends 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.
Looking to contribute?
- Learn more about how to get involved.
- Edit this page on GitHub to fix an error or make an improvement.
- Submit feedback to let us know how we can improve Docs.
Learn Python on Codecademy
Computer ScienceLooking for an introduction to the theory behind programming? Master Python while learning data structures, algorithms, and more!
Includes 6 Courses
With Professional Certification