Merge branch 'develop' of https://github.com/gazpachoking/requests into develop
[platform/upstream/python-requests.git] / README.rst
1 Requests: HTTP for Humans
2 =========================
3
4 Requests is an ISC Licensed HTTP library, written in Python, for human
5 beings.
6
7 Most existing Python modules for sending HTTP requests are extremely
8 verbose and cumbersome. Python's builtin urllib2 module provides most of
9 the HTTP capabilities you should need, but the api is thoroughly broken.
10 It requires an enormous amount of work (even method overrides) to
11 perform the simplest of tasks.
12
13 Things shouldn't be this way. Not in Python.
14
15 ::
16
17     >>> r = requests.get('https://api.github.com', auth=('user', 'pass'))
18     >>> r.status_code
19     204
20     >>> r.headers['content-type']
21     'application/json'
22     >>> r.content
23     ...
24
25 See `the same code, without Requests <https://gist.github.com/973705>`_.
26
27 Requests allow you to send  **HEAD**, **GET**, **POST**, **PUT**,
28 **PATCH**, and **DELETE** HTTP requests. You can add headers, form data,
29 multipart files, and parameters with simple Python dictionaries, and access the
30 response data in the same way. It's powered by httplib, but it does
31 all the hard work and crazy hacks for you.
32
33
34 Features
35 --------
36
37 - Browser standard SSL verification.
38 - Extremely simple HEAD, GET, POST, PUT, PATCH, DELETE Requests.
39 - Gevent support for Asyncronous Requests.
40 - Sessions with cookie persistence.
41 - Basic, Digest, and Custom Authentication support.
42 - Automatic form-encoding of dictionaries
43 - A simple dictionary interface for request/response cookies.
44 - Multipart file uploads.
45 - Automatc decoding of Unicode, gzip, and deflate responses.
46 - Full support for unicode URLs and domain names.
47
48
49 Usage
50 -----
51
52 It couldn't be simpler::
53
54     >>> import requests
55     >>> r = requests.get('http://google.com')
56
57
58 HTTPS? Basic Authentication? ::
59
60     >>> r = requests.get('https://httpbin.ep.io/basic-auth/user/pass')
61     >>> r.status_code
62     401
63
64
65 Uh oh, we're not authorized! Let's add authentication. ::
66
67     >>> r = requests.get('https://httpbin.ep.io/basic-auth/user/pass', auth=('user', 'pass'))
68
69     >>> r.status_code
70     200
71
72     >>> r.headers['content-type']
73     'application/json'
74
75     >>> r.content
76     '{"authenticated": true, "user": "user"}'
77
78
79 Installation
80 ------------
81
82 To install requests, simply: ::
83
84     $ pip install requests
85
86 Or, if you absolutely must: ::
87
88     $ easy_install requests
89
90 But, you really shouldn't do that.
91
92
93
94 Contribute
95 ----------
96
97 #. Check for open issues or open a fresh issue to start a discussion around a feature idea or a bug. There is a Contributor Friendly tag for issues that should be ideal for people who are not very familiar with the codebase yet.
98 #. Fork `the repository`_ on Github to start making your changes to the **develop** branch (or branch off of it).
99 #. Write a test which shows that the bug was fixed or that the feature works as expected.
100 #. Send a pull request and bug the maintainer until it gets merged and published. :) Make sure to add yourself to AUTHORS_.
101
102 .. _`the repository`: http://github.com/kennethreitz/requests
103 .. _AUTHORS: http://github.com/kennethreitz/requests/blob/master/AUTHORS