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

Can someone help me on how I could copy instagram pictures to my django app using this library? #252

Open
wants to merge 73 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
73 commits
Select commit Hold shift + click to select a range
d4fe1f5
beat > the JSON object must be str, not 'bytes'
survtur Oct 20, 2015
57a09ad
encoding
survtur Oct 20, 2015
05f18c7
Making the word an alive hyperlink
KrishMunot Nov 14, 2015
8b02858
Update user_media_feed
kmlebedev Aug 27, 2016
17f11a0
specify urlencoded Content-Type (exchange_for_...)
Jan 30, 2017
0b67a18
Safely fetch comment data, by checking availability before calling
wkoot Feb 27, 2017
93ee521
pep8 tests
wkoot Feb 27, 2017
79badce
Merge branch 'master' into safe_comments_data
wkoot Feb 27, 2017
cfe9b14
Add test case for fixed logic
wkoot Feb 27, 2017
c5d03af
Merge pull request #1 from wkoot/safe_comments_data
wkoot Feb 27, 2017
f04d178
pep8 formatting
wkoot Feb 27, 2017
f2e1c31
Safely fetch entry data, by checking availability before calling
wkoot Feb 27, 2017
e40306c
Add test case for missing field videos
wkoot Feb 27, 2017
a6d83a8
Merge pull request #2 from wkoot/safe_object_from_dictionary
wkoot Feb 27, 2017
cb65d88
Merge pull request #3 from hosseinamin/patch-1
wkoot Feb 27, 2017
bbca28d
pep8 formatting
wkoot Feb 27, 2017
d61e687
Merge pull request #4 from kmlebedev/patch-1
wkoot Feb 27, 2017
08096be
Clean up and use six directly
wkoot Feb 27, 2017
daa9854
Fix travis build
wkoot Feb 27, 2017
4ea5b65
Merge pull request #5 from KrishMunot/patch-2
wkoot Feb 27, 2017
a63b886
Merge pull request #6 from survtur/sim
wkoot Feb 27, 2017
22f062f
Cherry pick 75c32cf1db32650a05236220758df369423e8c58
kavirajk Aug 17, 2015
5bd95e6
Cherry pick a28e4b7493f47913bf2b91876cd28b5c5ffa503f and also add in …
wkoot Feb 27, 2017
537735d
Incorrect place to add pytz requirement, needs setup.py
wkoot Feb 27, 2017
f33638e
Support python 2.6 for tests
wkoot Feb 27, 2017
a8704d3
Merge pull request #7 from wkoot/kavirajk-timezone-aware-datetime-object
wkoot Feb 27, 2017
248f55a
Cherry pick 93cd4fd4fbf0c3b3d1e050fbc950089aba1c23e3
Oct 5, 2015
34e3c3f
Merge pull request #9 from wkoot/ccstolley-timeout-parameter
wkoot Feb 27, 2017
ef43834
Raise SkipTest instead of del AuthTests and make test pass on case-se…
wkoot Feb 27, 2017
d3bc7d7
Cherry pick 2d5768b6f71f4312da0bf4084a6ca1fb7eba7525
wkoot Feb 27, 2017
b283cb9
Remove now obsolete else
wkoot Feb 27, 2017
6b07bdf
Skip AuthTests in a python 2.6 friendly way
wkoot Feb 27, 2017
97af5fb
All forms of skipping are not there, don't want to import unittest2..…
wkoot Feb 27, 2017
9702c7f
Revert previous attempt; try within the class
wkoot Feb 27, 2017
4207a55
Merge pull request #11 from wkoot/p26-skip-tests
wkoot Feb 27, 2017
dc5bc2e
Merge branch 'master' into stantonk-error-signing-posts
wkoot Feb 27, 2017
853f8d3
Merge pull request #10 from wkoot/stantonk-error-signing-posts
wkoot Feb 27, 2017
db766d6
Toss and ignore old folders
wkoot Feb 27, 2017
f025c75
Update pypi package info
wkoot Feb 27, 2017
4fd4334
Set version to 1.3.3
wkoot Feb 27, 2017
b45c293
Update link and image of travis build to new location
wkoot Feb 27, 2017
fa9c0cc
Add twine to push to pypi
wkoot Feb 27, 2017
18ce708
Define __all__ and add models for importing
wkoot Feb 28, 2017
1b0b2a7
Remove dupe tests
wkoot Feb 28, 2017
51cb414
pep8 formatting
wkoot Feb 28, 2017
1de32e0
Move api client helper methods outside class
wkoot Feb 28, 2017
ce57147
Clean up warnings
wkoot Feb 28, 2017
5f41b33
pep8
wkoot Feb 28, 2017
de7c136
Add most recent Python versions in Travis CI
SylvainDe Mar 8, 2017
91819f4
Add relevant test case
wkoot Sep 29, 2017
d49461f
Add support for id passing in Image and Video objects
wkoot Sep 29, 2017
c7e6f81
Merge pull request #13 from wkoot/cleanup_tests
wkoot Sep 29, 2017
5414ceb
Merge pull request #14 from wkoot/video_ids_recent_media
wkoot Sep 29, 2017
23ce491
Merge pull request #15 from SylvainDe/master
wkoot Sep 29, 2017
85277d6
Add OAuth2RequestTests with test_generate_sig
wkoot Sep 29, 2017
5447569
Make python3 compatible unicode call
wkoot Sep 29, 2017
a0e8fe4
Don't use {} string format shorthand
wkoot Sep 29, 2017
f09ac1b
Ensure that all other string munging instances in oauth2.py use .form…
wkoot Sep 29, 2017
c4ca57e
Merge pull request #16 from wkoot/python3-compatible-unicode-call
wkoot Sep 29, 2017
4e1e622
Set new release version 1.3.4
wkoot Sep 29, 2017
39276f8
Add coverage plugin
wkoot Oct 5, 2017
cb3e1fc
Remove sample_app.py and trim requirements
wkoot Oct 5, 2017
a81c895
Skip running python-codacy-coverage for python2.6
wkoot Oct 5, 2017
a0399b6
Add semicolon in travis.yml as the if statement seems to be concatena…
wkoot Oct 5, 2017
a8549a6
Add code coverage badge
wkoot Oct 5, 2017
14005ef
Merge pull request #17 from wkoot/coverage-integration
wkoot Oct 5, 2017
deb5882
Add coveralls to build
wkoot Oct 9, 2017
533e33c
Slap down coveragerc to direct coverage to instagram package only
wkoot Oct 9, 2017
c9f5243
Current test logic is not aimed at testing code branching; better dis…
wkoot Oct 9, 2017
a2238ba
Merge pull request #18 from wkoot/coverage-integration
wkoot Oct 9, 2017
80f62a8
Much awesome so badge
wkoot Oct 9, 2017
475f4b7
Remove old python versions from .travis.yml
wkoot Jan 11, 2019
d698bda
Merge pull request #20 from wkoot/remove-py26-py33
wkoot Jan 11, 2019
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
3 changes: 3 additions & 0 deletions .coveragerc
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
[run]
source = instagram
branch = False
6 changes: 5 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,8 @@
.DS_Store
*.swp
test_settings.py

dist
build
*.egg-info
.coverage
coverage.xml
18 changes: 14 additions & 4 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,10 +1,20 @@
language: python
python:
- "2.6"
- "2.7"
- "3.3"
- "3.4"
- "3.5"
- "3.6"
- "3.6-dev"
- "3.7-dev"
- "nightly"
install:
- "pip install ."
script: "python tests.py"

- "pip install -r build_requirements.txt"
script:
- "coverage run tests.py"
- "coverage xml -o coverage.xml"
after_success:
- "coveralls"
- "if [[ $TRAVIS_PYTHON_VERSION != 2.6 ]]; then
python-codacy-coverage -r coverage.xml;
fi"
109 changes: 66 additions & 43 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,41 +4,51 @@

- - -

[![Build Status](https://api.travis-ci.org/Instagram/python-instagram.svg)](https://travis-ci.org/Instagram/python-instagram)
[![Build Status](https://api.travis-ci.org/wkoot/python-instagram.svg)](https://travis-ci.org/wkoot/python-instagram)
[![Coveralls Coverage](https://coveralls.io/repos/github/wkoot/python-instagram/badge.svg)](https://coveralls.io/github/wkoot/python-instagram)
[![Codacy Badge](https://api.codacy.com/project/badge/Grade/6dd0431b8752421d95521ea59fc6ecc1)](https://www.codacy.com/app/wkoot/python-instagram)
[![Code Climate](https://img.shields.io/codeclimate/github/wkoot/python-instagram.svg)](https://codeclimate.com/github/wkoot/python-instagram)


python-instagram
======
================
A Python 2/3 client for the Instagram REST and Search APIs


Installation
-----
------------
```
pip install python-instagram
pip install instagram
```
Requires
-----


Requirements
------------
* httplib2
* simplejson
* six
* pytz


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


Blog
----------------------------
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).
Instagram for developers blog
-----------------------------
The [Instagram for developers blog](http://developers.instagram.com/) features news and important announcements about the Instagram Platform.
You will also find tutorials and best practices to help you build great platform integrations.


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.
Stack Overflow community
------------------------
The Stack Overflow [instagram tag](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
-----
--------------

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/
Expand Down Expand Up @@ -66,7 +76,7 @@ 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
Expand All @@ -79,8 +89,9 @@ for media in popular_media:
print media.images['standard_resolution'].url
```

Real-time Subscriptions:
-----

Real-time Subscriptions
-----------------------

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

Expand All @@ -107,7 +118,7 @@ Along with that, you would typically register subscription "reactors" for proces
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:
Expand All @@ -116,10 +127,10 @@ You can also use the API to list and delete subscriptions:
api.list_subscriptions()
api.delete_subscriptions(id=342342)
```


Data Retrieval:
-----

Data Retrieval
--------------

See the endpoints docs for more on these methods: http://instagr.am/developer/endpoints/

Expand All @@ -142,15 +153,15 @@ while next_:
```

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
Expand All @@ -173,47 +184,49 @@ 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_tag_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)*
```


Error handling
------
--------------

Importing the bind module allows handling of specific error status codes. An example is provided below:
``` python
from instagram.bind import InstagramAPIError
Expand All @@ -225,26 +238,35 @@ except InstagramAPIError as e:
print "\nUser is set to private."
```


Setting Timeouts
----------------

By default there is no timeout for requests to the Instagram API. You can specify a timeout in one of two ways:
``` python
from instagram.client import InstagramAPI

# set a 30-second timeout for this particular InstagramAPI instance
api = InstagramAPI(access_token=access_token, client_secret=client_secret, timeout=30)
```
or
``` python
import socket

# Set the global default timeout, which applies to all sockets in your
# program where a timeout is not otherwise specified.
socket.setdefaulttimeout(30)
```


Trouble Shooting
------
----------------

If you get an error of a module not being defined during the Instagram import call, this might update a necessary package.
```
sudo pip install --upgrade six
```

Sample app
------
This repository includes a one-file sample app that uses the bottle framework and demonstrates
authentication, subscriptions, and update processing. To try it out:

* 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
------------
Expand Down Expand Up @@ -289,8 +311,9 @@ Submitting a Pull Request
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.

Expand Down
4 changes: 4 additions & 0 deletions build_requirements.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
twine==1.8.1
coverage==4.4.1
coveralls==1.2.0
codacy-coverage==1.3.3
Binary file removed dist/python-instagram-1.0.0.tar.gz
Binary file not shown.
Binary file removed dist/python-instagram-1.0.1.tar.gz
Binary file not shown.
Binary file removed dist/python-instagram-1.1.0.tar.gz
Binary file not shown.
Binary file removed dist/python-instagram-1.1.1.tar.gz
Binary file not shown.
Binary file removed dist/python-instagram-1.1.2.tar.gz
Binary file not shown.
Loading