Frequently Asked Questions

This part of the documentation answers common questions about Requests.

Encoded Data?



Custom User-Agents?

Requests allows you to easily override User-Agent strings, along with any other HTTP Header. See documentation about headers.

Why not Httplib2?

Chris Adams gave an excellent summary on Hacker News:




Python 3 Support?

Yes! Requests officially supports Python 2.7 & 3.5+ and PyPy.

Python 2 Support?

Yes! We do not have immediate plans to sunset our support for Python 2.7. We understand that we have a large user base with varying needs, and intend to maintain Python 2.7 support within Requests until pip stops supporting Python 2.7 (there’s no estimated date on that yet).

That said, it is highly recommended users migrate to Python 3.6+ since Python 2.7 is no longer receiving bug fixes or security updates as of January 1, 2020.

What are “hostname doesn’t match” errors?

These errors occur when SSL certificate verification fails to match the certificate the server responds with to the hostname Requests thinks it’s contacting. If you’re certain the server’s SSL setup is correct (for example, because you can visit the site with your browser) and you’re using Python 2.7, a possible explanation is that you need Server-Name-Indication.

Server-Name-Indication, or SNI, is an official extension to SSL where the client tells the server what hostname it is contacting. This is important when servers are using Virtual Hosting. When such servers are hosting more than one SSL site they need to be able to return the appropriate certificate based on the hostname the client is connecting to.

Python3 and Python 2.7.9+ include native support for SNI in their SSL modules. For information on using SNI with Requests on Python < 2.7.9 refer to this Stack Overflow answer.