Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Newer
Older
100644 111 lines (70 sloc) 2.682 kb
2153b21 @kennethreitz less hostility
kennethreitz authored
1 Requests: HTTP for Humans
2 =========================
a6ffd97 @kennethreitz initial readme
kennethreitz authored
3
0b34812 @kennethreitz readme cleanup
kennethreitz authored
4 Requests is an ISC Licensed HTTP library, written in Python, for human
5 beings.
45c6897 @kennethreitz good readme update
kennethreitz authored
6
0b34812 @kennethreitz readme cleanup
kennethreitz authored
7 Most existing Python modules for sending HTTP requests are extremely
9471b0a @kennethreitz let's do this
kennethreitz authored
8 verbose and cumbersome. Python's builtin urllib2 module provides most of
0b34812 @kennethreitz readme cleanup
kennethreitz authored
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
9471b0a @kennethreitz let's do this
kennethreitz authored
13 Things shouldn't be this way. Not in Python.
0b34812 @kennethreitz readme cleanup
kennethreitz authored
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
9471b0a @kennethreitz let's do this
kennethreitz authored
30 response data in the same way. It's powered by urllib2, but it does
0b34812 @kennethreitz readme cleanup
kennethreitz authored
31 all the hard work and crazy hacks for you.
45c6897 @kennethreitz good readme update
kennethreitz authored
32
c840bc7 @kennethreitz readme update
kennethreitz authored
33
2cc8015 @kennethreitz Readme update.
kennethreitz authored
34 Features
35 --------
36
483d007 @kennethreitz readme update
kennethreitz authored
37 - Extremely simple HEAD, GET, POST, PUT, PATCH, DELETE Requests
927294f @kennethreitz big ol' doc update
kennethreitz authored
38 + Simple HTTP Header Request Attachment
39 + Simple Data/Params Request Attachment
43790c4 @kennethreitz updated multipart-upload documentation
kennethreitz authored
40 + Simple Multipart File Uploads
d511e6f @kennethreitz Version Bump v0.2.2
kennethreitz authored
41 + CookieJar Support
155863b @kennethreitz readme update
kennethreitz authored
42 + Redirection History
483d007 @kennethreitz readme update
kennethreitz authored
43 + Proxy Support
155863b @kennethreitz readme update
kennethreitz authored
44 + Redirection Recursion Urllib Fix
45 + Auto Decompression of GZipped Content
46 + Unicode URL Support
a9e18e9 Update the README
digitalxero authored
47
270898e @kennethreitz Readme Updates
kennethreitz authored
48 - Simple Authentication
927294f @kennethreitz big ol' doc update
kennethreitz authored
49 + Simple URL + HTTP Auth Registry
2cc8015 @kennethreitz Readme update.
kennethreitz authored
50
51
a6ffd97 @kennethreitz initial readme
kennethreitz authored
52 Usage
53 -----
54
2cc8015 @kennethreitz Readme update.
kennethreitz authored
55 It couldn't be simpler. ::
a6ffd97 @kennethreitz initial readme
kennethreitz authored
56
927294f @kennethreitz big ol' doc update
kennethreitz authored
57 >>> import requests
58 >>> r = requests.get('http://google.com')
2b54b01 @kennethreitz Documentation update
kennethreitz authored
59
60
61 HTTPS? Basic Authentication? ::
a9e18e9 Update the README
digitalxero authored
62
4cf4362 @kennethreitz typos
kennethreitz authored
63 >>> r = requests.get('https://httpbin.ep.io/basic-auth/user/pass')
927294f @kennethreitz big ol' doc update
kennethreitz authored
64 >>> r.status_code
65 401
2b54b01 @kennethreitz Documentation update
kennethreitz authored
66
a9e18e9 Update the README
digitalxero authored
67
2b54b01 @kennethreitz Documentation update
kennethreitz authored
68 Uh oh, we're not authorized! Let's add authentication. ::
a9e18e9 Update the README
digitalxero authored
69
18c42e8 @petermanser Fixing minor bug in code example - missing apostrophe
petermanser authored
70 >>> r = requests.get('https://httpbin.ep.io/basic-auth/user/pass', auth=('user', 'pass'))
a9e18e9 Update the README
digitalxero authored
71
1b88561 @kennethreitz Readme update
kennethreitz authored
72 >>> r.status_code
a9e18e9 Update the README
digitalxero authored
73 200
74
927294f @kennethreitz big ol' doc update
kennethreitz authored
75 >>> r.headers['content-type']
c9b0f8f @kennethreitz repr for datatypes
kennethreitz authored
76 'application/json'
a9e18e9 Update the README
digitalxero authored
77
927294f @kennethreitz big ol' doc update
kennethreitz authored
78 >>> r.content
483d007 @kennethreitz readme update
kennethreitz authored
79 '{"authenticated": true, "user": "user"}'
2b54b01 @kennethreitz Documentation update
kennethreitz authored
80
81
a6ffd97 @kennethreitz initial readme
kennethreitz authored
82 Installation
83 ------------
84
927294f @kennethreitz big ol' doc update
kennethreitz authored
85 To install requests, simply: ::
a6ffd97 @kennethreitz initial readme
kennethreitz authored
86
927294f @kennethreitz big ol' doc update
kennethreitz authored
87 $ pip install requests
a9e18e9 Update the README
digitalxero authored
88
a6ffd97 @kennethreitz initial readme
kennethreitz authored
89 Or, if you absolutely must: ::
90
927294f @kennethreitz big ol' doc update
kennethreitz authored
91 $ easy_install requests
a6ffd97 @kennethreitz initial readme
kennethreitz authored
92
93 But, you really shouldn't do that.
a9e18e9 Update the README
digitalxero authored
94
2b54b01 @kennethreitz Documentation update
kennethreitz authored
95
96
a6ffd97 @kennethreitz initial readme
kennethreitz authored
97 Contribute
98 ----------
99
100 If you'd like to contribute, simply fork `the repository`_, commit your changes to the **develop** branch (or branch off of it), and send a pull request. Make sure you add yourself to AUTHORS_.
101
102
2b54b01 @kennethreitz Documentation update
kennethreitz authored
103
a6ffd97 @kennethreitz initial readme
kennethreitz authored
104 Roadmap
105 -------
2b54b01 @kennethreitz Documentation update
kennethreitz authored
106
155863b @kennethreitz readme update
kennethreitz authored
107 - Sphinx Documentation
a6ffd97 @kennethreitz initial readme
kennethreitz authored
108
109 .. _`the repository`: http://github.com/kennethreitz/requests
110 .. _AUTHORS: http://github.com/kennethreitz/requests/blob/master/AUTHORS
Something went wrong with that request. Please try again.