Skip to content
This repository has been archived by the owner on Jan 13, 2022. It is now read-only.

Python3 #264

Open
wants to merge 135 commits into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
135 commits
Select commit Hold shift + click to select a range
68fa152
Init Image using object_from_dictionary for
shayne Feb 24, 2011
2ea1ed4
adding realtime support
Feb 17, 2011
83b9d15
updating accepted parameters for subscriptions
Feb 24, 2011
2d41991
Bumping version number
Feb 24, 2011
1da5ad4
Added method exchange_user_id_for_access_token
shayne Feb 28, 2011
5329ddf
Adding user_liked_media endpoint
Jun 2, 2011
73bcdf1
handle non-ID'd locations
Jun 2, 2011
2ce61e5
Fixing user follows / followed-by endpoints
Jun 20, 2011
0745e51
Specified basic scope explicitly when authenticating because API give…
sandinmyjoints Sep 5, 2011
caa3bba
Updated README.md to say media_popular and standard_resolution.
sandinmyjoints Sep 5, 2011
53daf35
Updated sample_app docs to specify that oauth_callback must be part o…
sandinmyjoints Sep 5, 2011
63d826d
added Caption field to Media model objects
prehensile Oct 16, 2011
c3e48c3
Merge pull request #7 from sandinmyjoints/master
Feb 15, 2012
8f24b8b
Merge pull request #9 from prehensile/master
Feb 15, 2012
55c0950
return raw json responses instead of media objects
Feb 16, 2012
faaad4c
return_json instead of media obeject
Feb 16, 2012
9e63cf5
return_json api_responses, not media objects
Feb 16, 2012
fef1e63
Disable SSL validation.
akumria Feb 16, 2012
c80ef51
Not all Locations have latitude / longitude.
akumria Feb 16, 2012
bd9fd8a
As well as returning the access_token, return who it is associated to
akumria Feb 20, 2012
4867b59
Relationship changes are a POSTed.
akumria Feb 20, 2012
8861a94
Merge pull request #15 from akumria/fixup-oauth-return-user
Feb 24, 2012
b5675a1
Merge pull request #14 from akumria/fixup-relationships
Feb 24, 2012
00e1fef
Merge pull request #13 from akumria/fixup-media-popular
Feb 24, 2012
ba703ed
Merge pull request #11 from shreyansb/master
Feb 24, 2012
94c3230
Minor spacing fix
Feb 24, 2012
c95107c
Updating model to reflect new Relationship
etchalon Nov 22, 2011
9be6079
Merge pull request #12 from akumria/fixup-https
Feb 24, 2012
7cb5ca1
Updated the Location model to pass point in the kwargs as opposed the…
Jul 2, 2011
958f632
Added new json fixuture
mgunneras Feb 26, 2011
d0bdf26
Added list of Users to Media.likes if available
mgunneras Feb 26, 2011
e076fb4
Added caption class
mgunneras Feb 26, 2011
086d32d
Fixed bug where str representation of Comment returned None
mgunneras Feb 26, 2011
c84d764
Added Caption to Media model
mgunneras Feb 26, 2011
4832523
Added method to fetch Media based on geography_id
mgunneras Feb 26, 2011
a1e8c03
Whitespace cleanup tabs are now spaces.
mgunneras Feb 26, 2011
ed43974
Fix bug where Point didn't get added to Location
mgunneras Feb 28, 2011
13c9df3
Added filter property to Media model
mgunneras Feb 28, 2011
557678c
Fixed bug in geographies url endpoint
mgunneras Feb 28, 2011
ed0bccf
Added fixture for geography query
mgunneras Feb 28, 2011
38b0e21
fixed models
mgunneras Apr 10, 2011
7931110
Bugfix. check key not attribute of dict
mgunneras Apr 11, 2011
9e62146
Handle if filter is missing
Feb 24, 2012
2f8beda
Making the mock http class compatible with the kwarg passed in
Feb 24, 2012
8e8ccbf
Version bump and README update
Feb 24, 2012
142c64e
Updating readme with pip instructions
Feb 24, 2012
38eb254
Default args should not be mutable
michaelhelmick Feb 24, 2012
9559336
Merge pull request #16 from michaelhelmick/master
Feb 24, 2012
d37641d
Fix #15
michaelhelmick Feb 24, 2012
c3fd4f5
Fix #15
michaelhelmick Feb 24, 2012
d8a1d48
Add an 'empty' type explicitly
Feb 25, 2012
bcb0f71
Version bump
Feb 25, 2012
cb70746
Adding tags; fixes #6
Feb 25, 2012
67a60c6
Another version bump
Feb 25, 2012
9132cef
Readme updates
Feb 25, 2012
6b43209
Make it easier to identify various models with a __unicode__ method.
akumria Feb 28, 2012
17cb064
Switch __str__ to __unicode__
akumria Feb 28, 2012
6c2d83b
Prefix this with what kind of object it is.
akumria Feb 28, 2012
c4a4415
Remove duplicated settings of the caption.
akumria Feb 28, 2012
e079e1a
There are no users of the Caption model, remove it.
akumria Feb 28, 2012
727939e
Explicitly construct the appropriate object.
akumria Feb 28, 2012
9b8d2af
Convert the Tags dictionary into Tags objects too.
akumria Feb 28, 2012
2c5f308
Merge pull request #21 from akumria/fixup-add-tags-to-media
Feb 28, 2012
6349372
Merge pull request #20 from akumria/fixup-models
Feb 28, 2012
ba62e57
Merge pull request #22 from akumria/fixup-remove-caption
Feb 28, 2012
51c2064
Merge branch 'master' of git://github.com/Instagram/python-instagram
michaelhelmick Feb 29, 2012
0deeabb
Datetime to Timestamp helper
michaelhelmick Feb 29, 2012
911e4c9
PEP8 Cleanup
michaelhelmick Feb 29, 2012
2a73f90
Merge pull request #24 from michaelhelmick/pep8_cleanup
Mar 2, 2012
4cead55
Merge pull request #23 from michaelhelmick/datetime_to_timestamp
Mar 2, 2012
25780e1
Updating fixture; temp removing test that doesn't match what we do in…
Mar 2, 2012
7b7e3f4
version bump
Mar 2, 2012
7ce1f49
Changed message to error_message, as that's what the API returns to m…
pamelafox Apr 9, 2012
53e1a7f
Adding more information to the README. The API is written in a way su…
pamelafox Apr 11, 2012
212ea92
Merge pull request #26 from pamelafox/patch-2
May 27, 2012
6906a95
Merge pull request #25 from pamelafox/patch-1
May 27, 2012
0d1726a
Added user_relationship method, more verbose simplejson import, excep…
michaelhelmick May 28, 2012
884aa80
0.8.0, Bumping the minor because we *added a method*
michaelhelmick May 28, 2012
0e48d18
Add user_relationship to README
michaelhelmick May 29, 2012
417f5b2
Merge remote-tracking branch 'michaelhelmick/relationship_status'
May 29, 2012
95dc1c5
Central json import logic
May 29, 2012
0028906
Fixed bug in sample_app.py. The access_token needs to be unpacked fro…
tonyxiao Jul 8, 2012
b8e88f1
Handle OAuthRateLimitException from Nginx
benneic Jul 31, 2012
07c4d56
Handling any non meta response
benneic Jul 31, 2012
f81532a
Fix comparison type bug
benneic Jul 31, 2012
aefb118
Add pagination_format parameter to api methods.
Aug 7, 2012
71e7c05
Added line break
techguydave Nov 14, 2012
f2f6313
Update location_search method to accept new foursquare_v2_id parameter
dvonlehman May 16, 2013
e95c7bd
Fixed example code in README.md
kenkam Jun 2, 2013
d65f26c
use json_import instead of simplejson
isnowfy Jul 22, 2013
29290ba
add with_next_url implement to easy paginator
isnowfy Aug 18, 2013
2f4247b
Import simplejson with json_import
holagvk Sep 14, 2013
74ef87f
Update README.md
dangayle Sep 17, 2013
9d5b63d
Merge pull request #52 from dangayle/master
albertotretti Dec 17, 2013
ea0646c
Merge pull request #40 from synth3tk/patch-1
albertotretti Dec 17, 2013
45b3094
Merge pull request #47 from kenkam/master
albertotretti Dec 17, 2013
5bfd9d6
Merge pull request #31 from tonyxiao/patch-1
albertotretti Dec 17, 2013
b6f0fed
Merge pull request #51 from gvkalra/patch-1
albertotretti Dec 17, 2013
a1563a1
Add syntax highlighting for Python examples
Jan 21, 2014
6bc555b
Set version to our own.
Feb 3, 2014
445f6ed
Media now supports video, has a 'type' field and additional url acces…
phniix Apr 1, 2014
3fe546d
README update with CLA and new License and version 1 bump
heatonjb Apr 7, 2014
4d1e2c6
Merge branch 'master' of github.com:isnowfy/python-instagram into isn…
heatonjb Apr 22, 2014
d5eae33
Merge pull request #61 from philsturgeon/patch-1
heatonjb Apr 23, 2014
eb0cd3b
Merge branch 'video_support' of github.com:jjshabs/python-instagram i…
heatonjb Apr 23, 2014
28d89f6
added x-ratelimt support to client obj
heatonjb Apr 24, 2014
5414f8d
Merge branch 'master' of github.com:Instagram/python-instagram
heatonjb Apr 24, 2014
32704a3
sample app update
heatonjb Apr 24, 2014
5d8cd6a
Merge branch 'master' of github.com:dvonlehman/python-instagram into …
heatonjb Apr 24, 2014
c8f47b9
Merge branch 'master' of github.com:beichhor/python-instagram into be…
heatonjb Apr 24, 2014
07b4032
Adding an optional status_code to InstagramClientError
johnboiles May 2, 2014
c7656b7
updated sample to use new media methods
heatonjb May 9, 2014
5e8a0e2
Merge branch 'master' of github.com:johnboiles/python-instagram into …
heatonjb May 9, 2014
d51700b
Merge branch 'johnboiles-master' propagates API response codes
heatonjb May 9, 2014
9b0f9f1
Update README.md Sample app section
j-e-d May 12, 2014
8c2f06b
Update README.md Sample app to include Redis
j-e-d May 12, 2014
136be37
Merge pull request #69 from j-e-d/patch-1
heatonjb May 15, 2014
51a8ed4
Merge branch 'pagination-format' of github.com:henninge/python-instag…
heatonjb May 15, 2014
efe46fc
Merge branch 'henninge-pagination-format'
heatonjb May 15, 2014
b5e136b
Merge branch 'master' of github.com:Instagram/python-instagram
heatonjb May 15, 2014
3adbb5d
add support for new http status code for ratelimit exceeded
heatonjb May 22, 2014
d58f452
Adding the Travis configuration file.
yssk22 Jun 2, 2014
16d1bc5
Support the signed header.
yssk22 Jun 3, 2014
a43b176
Merge branch 'travis-ci' of github.com:yssk22/python-instagram into y…
heatonjb Jun 3, 2014
caca3d1
Merge branch 'yssk22-travis-ci'
heatonjb Jun 3, 2014
de5ec37
changed to support secured requests
heatonjb Jun 3, 2014
d090bfd
Merge branch 'yssk22-signed-post'
heatonjb Jun 3, 2014
2d480bf
updated sample app to add like and unlike
heatonjb Jun 3, 2014
dd796e7
version increment
heatonjb Jun 3, 2014
bf877e8
supporting /media/shortcode url
Jun 3, 2014
de29177
Merge branch 'lcarvalho-master'
heatonjb Jun 9, 2014
1b9f7a4
added media shortcode support
heatonjb Jun 9, 2014
ada0358
add python 3 support
gcd0318 Jun 12, 2014
dab0861
rm build files, README modified for python 3
gcd0318 Jun 12, 2014
1662a3f
Merge pull request #80 from gcd0318/master
heatonjb Jun 11, 2014
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
language: python
python:
- "2.6"
- "2.7"
install:
- "pip install ."
script: "python tests.py"

30 changes: 30 additions & 0 deletions LICENSE.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
BSD License

For python-instagram software

Copyright (c) 2014, Facebook, Inc. All rights reserved.

Redistribution and use in source and binary forms, with or without modification,
are permitted provided that the following conditions are met:

* Redistributions of source code must retain the above copyright notice, this
list of conditions and the following disclaimer.

* Redistributions in binary form must reproduce the above copyright notice,
this list of conditions and the following disclaimer in the documentation
and/or other materials provided with the distribution.

* Neither the name Facebook nor the names of its contributors may be used to
endorse or promote products derived from this software without specific
prior written permission.

THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR
ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
255 changes: 237 additions & 18 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,41 +4,260 @@ A Python client for the Instagram REST and Search APIs

Installation
-----
pip install instagram
pip install python-instagram

Requires
-----
* httplib2
* simplejson

Follow @instagramapi on Twitter

Instagram REST and Search APIs
------------------------------
Our [developer site](http://instagram.com/developer) documents all the Instagram REST and Search APIs.


Blog
----------------------------
You can [follow @instagramapi on Twitter](http://twitter.com/#!/instagramapi) for announcements,
updates, and news about the Instagram gem.
The [Developer Blog] features news and important announcements about the Instagram Platform. You will also find tutorials and best practices to help you build great platform integrations. Make sure to subscribe to the RSS feed not to miss out on new posts: [http://developers.instagram.com](http://developers.instagram.com).


Obtaining an access token
Community
----------------------
The [Stack Overflow community](http://stackoverflow.com/questions/tagged/instagram/) is a great place to ask API related questions or if you need help with your code. Make sure to tag your questions with the Instagram tag to get fast answers from other fellow developers and members of the Instagram team.


Authentication
-----
You can use the provided get_access_token.py script to obtain an access token for yourself.
It will prompt you for your app's Client ID, Client Secret, and Redirect URI,
and walk you through instructions for getting your own access token for your app.

Usage
Instagram API uses the OAuth2 protocol for authentication, but not all functionality requires authentication.
See the docs for more information: http://instagram.com/developer/authentication/

### Obtaining an access token

If you're using a method that requires authentication and need an access token, you can use the provided get_access_token.py script to obtain an access token for yourself.
It will prompt you for your app's Client ID, Client Secret, and Redirect URI, and walk you through instructions for getting your own access token for your app.

### Authenticating a user

The provided sample app shows a simple OAuth flow for authenticating a user and getting an access token for them.

### Using an access token

Once you have an access token (whether via the script or from the user flow), you can pass that token into the InstagramAPI constructor:

``` python
from instagram.client import InstagramAPI

access_token = "YOUR_ACCESS_TOKEN"
api = InstagramAPI(access_token=access_token)
recent_media, next = api.user_recent_media(user_id="userid", count=10)
for media in recent_media:
print media.caption.text
```

### Making unauthenticated requests

For methods that don't require authentication, you can just pass your client ID and optionally client secret into the InstagramAPI
constructor:

``` python
api = InstagramAPI(client_id='YOUR_CLIENT_ID', client_secret='YOUR_CLIENT_SECRET')
popular_media = api.media_popular(count=20)
for media in popular_media:
print(media.images['standard_resolution'].url)
```

Real-time Subscriptions:
-----

See the docs for more on real-time subscriptions: http://instagr.am/developer/realtime/

You can use the API to subscribe to users, tags, locations, or geographies:

``` python
# Subscribe to updates for all users authenticated to your app
api.create_subscription(object='user', aspect='media', callback_url='http://mydomain.com/hook/instagram')

# Subscribe to all media tagged with 'fox'
api.create_subscription(object='tag', object_id='fox', aspect='media', callback_url='http://mydomain.com/hook/instagram')

# Subscribe to all media in a given location
api.create_subscription(object='location', object_id='1257285', aspect='media', callback_url='http://mydomain.com/hook/instagram')

# Subscribe to all media in a geographic area
api.create_subscription(object='geography', lat=35.657872, lng=139.70232, radius=1000, aspect='media', callback_url='http://mydomain.com/hook/instagram')
```

Along with that, you would typically register subscription "reactors" for processing the different subscription types:

``` python
# React to user type updates
reactor = subscriptions.SubscriptionsReactor()
reactor.register_callback(subscriptions.SubscriptionType.USER, process_user_update)
```

See the provided sample app for an example of making a subscription, reacting to it, an processing the updates.

You can also use the API to list and delete subscriptions:

``` python
api.list_subscriptions()
api.delete_subscriptions(id=342342)
```


Data Retrieval:
-----
from instagram.client import InstagramAPI

access_token = "..."
api = InstagramAPI(access_token=access_token)
popular_media = api.popular_media(count=20)
for media in popular_media:
print media.images['high_resolution'].url
See the endpoints docs for more on these methods: http://instagr.am/developer/endpoints/

The methods with a * return two values, where the second is a pagination parameter. Here's an example of retrieving recent media:

``` python
recent_media, next = api.user_recent_media()
photos = []
for media in recent_media:
photos.append('<img src="%s"/>' % media.images['thumbnail'].url)
```

Users: http://instagr.am/developer/endpoints/users/

``` python
api.user(user_id)
api.user_media_feed()*
api.user_liked_media()*
api.user_recent_media(user_id, count, max_id)*
api.user_search(q, count, lat, lng, min_timestamp, max_timestamp)
```

Relationships: http://instagr.am/developer/endpoints/relationships/

``` python
api.user_incoming_requests()
api.user_follows(user_id)*
api.user_followed_by(user_id)*
api.follow_user(user_id)
api.unfollow_user(user_id)
api.block_user(user_id)
api.unblock_user(user_id)
api.approve_user_request(user_id)
api.ignore_user_request(user_id)
api.user_relationship(user_id)
```

Media: http://instagr.am/developer/endpoints/media/

``` python
api.media(media_id)
api.media_popular(count, max_id)
api.media_search(q, count, lat, lng, min_timestamp, max_timestamp)
```

Comments: http://instagr.am/developer/endpoints/comments/

``` python
api.media_comments(media_id)
api.create_media_comment(media_id, text)
api.delete_comment(media_id, comment_id)
```

Likes: http://instagr.am/developer/endpoints/likes/

``` python
api.media_likes(media_id)
api.like_media(media_id)
api.unlike_media(media_id)
```

Tags: http://instagr.am/developer/endpoints/tags/

``` python
api.tag(tag_name)
api.tag_recent_media(count, max_id, tag_name)*
api.tag_search(q, count)*
```

Locations: http://instagr.am/developer/endpoints/locations/

``` python
api.location(location_id)
api.location_recent_media(count, max_id, location_id)*
api.location_search(q, count, lat, lng, foursquare_id, foursquare_v2_id)
```

Geographies: http://instagr.am/developer/endpoints/geographies/

``` python
api.geography_recent_media(count, max_id, geography_id)*
```

Sample app
------
We also provide a one-file sample app using bottle (you'll have to 'pip install bottle' first). To try it out:
This repository includes a one-file sample app that uses the bottle framework and demonstrates
authentication, subscriptions, and update processing. To try it out:

* Set your redirect URI to 'http://localhost:8515' in your dev profile
* Open up sample\_app.py, update it with your client\_id and secret
* Download bottle if you don't already have it: pip install bottle
* Download bottle-session if you don't already have it: pip install bottle-session
* Download and run a redis instance on port 6379 if you don't already have it. Check http://redis.io for instructions.
* Set your redirect URI to 'http://localhost:8515/oauth_callback' in your dev profile
* Open up sample\_app.py, update it with your client\_id and secret, and set redirect URI to 'http://localhost:8515/oauth_callback'
* Run the file; it will host a local server on port 8515.
* Try visiting http://localhost:8515 in your browser

Contributing
------------
In the spirit of [free software](http://www.fsf.org/licensing/essays/free-sw.html), **everyone** is encouraged to help improve this project.

Here are some ways *you* can contribute:

* by using alpha, beta, and prerelease versions
* by reporting bugs
* by suggesting new features
* by writing or editing documentation
* by writing specifications
* by writing code (**no patch is too small**: fix typos, add comments, clean up inconsistent whitespace)
* by refactoring code
* by closing [issues](http://github.com/Instagram/python-instagram/issues)
* by reviewing patches


Submitting an Issue
-------------------
We use the [GitHub issue tracker](https://github.com/Instagram/python-instagram/issues) to track bugs and
features. Before submitting a bug report or feature request, check to make sure it hasn't already
been submitted. You can indicate support for an existing issue by voting it up. When submitting a
bug report, please include a [Gist](http://gist.github.com/) that includes a stack trace and any
details that may be necessary to reproduce the bug, including your version number, and
operating system. Ideally, a bug report should include a pull request with failing specs.

Instagram has a [bounty program](https://www.facebook.com/whitehat/) for the safe
disclosure of security bugs. In those cases, please go through the process
outlined on that page and do not file a public issue.


Submitting a Pull Request
-------------------------
1. Fork the project.
2. Create a topic branch.
3. Implement your feature or bug fix.
4. Run <tt>python tests.py </tt>.
5. Add a test for your feature or bug fix.
6. Run <tt>python tests.py </tt>. If your changes are not 100% covered, go back to step 5.
7. Commit and push your changes.
8. Submit a pull request.
9. If you haven't already, complete the Contributor License Agreement ("CLA").

Contributor License Agreement ("CLA")
_____________________________________
In order to accept your pull request, we need you to submit a CLA. You only need
to do this once to work on any of Instagram's or Facebook's open source projects.

Complete your CLA here: [https://code.facebook.com/cla](https://code.facebook.com/cla)


Copyright
---------
Copyright (c) 2014, Facebook, Inc. All rights reserved.
By contributing to python-instagram, you agree that your contributions will be licensed under its BSD license.
See [LICENSE](https://github.com/Instagram/python-instagram/blob/master/LICENSE.md) for details.
Loading