Generated by DeepSeek V3.2| Requests (software) | |
|---|---|
| Name | Requests |
| Developer | Kenneth Reitz |
| Released | 14 February 2011 |
| Latest release version | 2.31.0 |
| Latest release date | 22 May 2023 |
| Programming language | Python |
| Operating system | Cross-platform |
| Genre | Library |
| License | Apache License 2.0 |
Requests (software) is a popular, elegant, and simple HTTP library for the Python programming language, created by developer Kenneth Reitz. It abstracts the complexities of making network requests behind a beautiful, simple API, allowing developers to send HTTP/1.1 requests with minimal code. The library is renowned for its human-friendly design, which has made it a de facto standard for web scraping, interacting with RESTful APIs, and consuming web services within the Python community.
The library provides a high-level interface to compose and send HTTP requests and handle responses, effectively replacing Python's built-in but more cumbersome urllib module. Its core philosophy, as stated in its documentation, is that "HTTP for Humans" should not require verbose code or deep knowledge of underlying protocols. This design principle has led to widespread adoption across numerous fields, including data science, DevOps automation, and backend development. The project is hosted on GitHub and is distributed via the Python Package Index (PyPI), making it easily installable through package managers like pip.
Key features include built-in support for handling query parameters, cookies, and sessions to persist certain parameters across multiple requests. It seamlessly manages HTTP authentication methods such as Basic Auth and Digest Auth, and allows for easy customization of request headers. The library also provides transparent content decoding, automatic handling of redirects, and robust support for uploading multipart file uploads. Furthermore, it offers connection keep-alive and HTTP/2 support through optional dependencies, along with synchronous and asynchronous request capabilities.
The project was initiated and first released by Kenneth Reitz in February 2011, quickly gaining traction for its superior developer experience compared to existing tools. Its development has been supported by a large community of contributors on GitHub, with major sponsorship from organizations like the Python Software Foundation. A significant milestone was the release of version 2.0 in 2014, which introduced a stable, refined API. The library's maintenance and future development are now overseen by a team of core maintainers, ensuring continued updates for security and compatibility with new versions of Python and evolving web standards.
A canonical example of its simplicity is retrieving the content of a webpage, which can be accomplished with just two lines of code, compared to more verbose patterns required by lower-level modules. It is extensively used for interacting with web services from companies like Google, Twitter, and GitHub through their public APIs. Common use cases in data analysis involve fetching JSON or XML data from a REST API endpoint for processing with libraries like pandas. The library's session object is particularly valuable for scripts that need to maintain login state or custom headers across multiple calls to the same web server.
Requests forms a foundational layer for many higher-level Python libraries and frameworks. It is the underlying HTTP client for popular tools like the PySpark connector, the Ansible module architecture, and the httpie command-line client. Within web frameworks, it is commonly used in Django and Flask applications for making outbound service calls to other microservices or external APIs. The library also integrates with testing frameworks such as pytest for mocking external HTTP dependencies and is a core component of the Requests-HTML library, which adds HTML parsing capabilities.
When using the library, developers are advised to leverage its support for TLS/SSL verification, which is enabled by default to prevent man-in-the-middle attacks. For handling sensitive credentials, integration with environment variable managers or secret management services from platforms like HashiCorp Vault or AWS Secrets Manager is recommended. Best practices include using connection timeouts to avoid hanging indefinitely on unresponsive servers and implementing retry logic with exponential backoff, often facilitated by the urllib3 library upon which Requests is built. Developers should also stay updated with releases from the Python Security Response Team (PSRT) regarding any vulnerabilities in dependent packages.
Category:Python libraries Category:Free software programmed in Python Category:HTTP clients