|
| 1 | +<!DOCTYPE html> |
| 2 | +<html xmlns="http://www.w3.org/1999/xhtml"> |
| 3 | + <head> |
| 4 | + <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/> |
| 5 | + |
| 6 | + <title>python-instagram-ext</title> |
| 7 | + |
| 8 | + <!--{* CSS *}--> |
| 9 | + <!--{* Bootstrap *}--> |
| 10 | + <link rel="stylesheet" href="//maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.css"/> |
| 11 | + </head> |
| 12 | + |
| 13 | + <body> |
| 14 | + <div id="wrapper" class="container"> |
| 15 | + <div id="header"> |
| 16 | + </div> |
| 17 | + |
| 18 | + <div id="container"> |
| 19 | + <div id="content"> |
| 20 | + <article class="markdown-body entry-content" itemprop="text"><hr> |
| 21 | + |
| 22 | + <p><strong><em>This project is personally forked and temporarily patched version of <a href="https://github.com/facebookarchive/python-instagram">python-instagram</a>. Proceed at your own risk!</em></strong></p> |
| 23 | + |
| 24 | + <hr> |
| 25 | + |
| 26 | + <p><a href="https://travis-ci.org/Instagram/python-instagram"><img src="https://camo.githubusercontent.com/c32f38ff68b980b6e5eca4103304184ed7d14994/68747470733a2f2f6170692e7472617669732d63692e6f72672f496e7374616772616d2f707974686f6e2d696e7374616772616d2e737667" alt="Build Status" data-canonical-src="https://api.travis-ci.org/Instagram/python-instagram.svg" style="max-width:100%;"></a></p> |
| 27 | + |
| 28 | + <h1><a id="user-content-python-instagram" class="anchor" href="#python-instagram" aria-hidden="true"><svg aria-hidden="true" class="octicon octicon-link" height="16" version="1.1" viewBox="0 0 16 16" width="16"><path d="M4 9h1v1h-1c-1.5 0-3-1.69-3-3.5s1.55-3.5 3-3.5h4c1.45 0 3 1.69 3 3.5 0 1.41-0.91 2.72-2 3.25v-1.16c0.58-0.45 1-1.27 1-2.09 0-1.28-1.02-2.5-2-2.5H4c-0.98 0-2 1.22-2 2.5s1 2.5 2 2.5z m9-3h-1v1h1c1 0 2 1.22 2 2.5s-1.02 2.5-2 2.5H9c-0.98 0-2-1.22-2-2.5 0-0.83 0.42-1.64 1-2.09v-1.16c-1.09 0.53-2 1.84-2 3.25 0 1.81 1.55 3.5 3 3.5h4c1.45 0 3-1.69 3-3.5s-1.5-3.5-3-3.5z"></path></svg></a>python-instagram</h1> |
| 29 | + |
| 30 | + <p>A Python 2/3 client for the Instagram REST and Search APIs</p> |
| 31 | + |
| 32 | + <h2><a id="user-content-installation" class="anchor" href="#installation" aria-hidden="true"><svg aria-hidden="true" class="octicon octicon-link" height="16" version="1.1" viewBox="0 0 16 16" width="16"><path d="M4 9h1v1h-1c-1.5 0-3-1.69-3-3.5s1.55-3.5 3-3.5h4c1.45 0 3 1.69 3 3.5 0 1.41-0.91 2.72-2 3.25v-1.16c0.58-0.45 1-1.27 1-2.09 0-1.28-1.02-2.5-2-2.5H4c-0.98 0-2 1.22-2 2.5s1 2.5 2 2.5z m9-3h-1v1h1c1 0 2 1.22 2 2.5s-1.02 2.5-2 2.5H9c-0.98 0-2-1.22-2-2.5 0-0.83 0.42-1.64 1-2.09v-1.16c-1.09 0.53-2 1.84-2 3.25 0 1.81 1.55 3.5 3 3.5h4c1.45 0 3-1.69 3-3.5s-1.5-3.5-3-3.5z"></path></svg></a>Installation</h2> |
| 33 | + |
| 34 | + <pre><code>pip install python-instagram |
| 35 | + </code></pre> |
| 36 | + |
| 37 | + <h2><a id="user-content-requires" class="anchor" href="#requires" aria-hidden="true"><svg aria-hidden="true" class="octicon octicon-link" height="16" version="1.1" viewBox="0 0 16 16" width="16"><path d="M4 9h1v1h-1c-1.5 0-3-1.69-3-3.5s1.55-3.5 3-3.5h4c1.45 0 3 1.69 3 3.5 0 1.41-0.91 2.72-2 3.25v-1.16c0.58-0.45 1-1.27 1-2.09 0-1.28-1.02-2.5-2-2.5H4c-0.98 0-2 1.22-2 2.5s1 2.5 2 2.5z m9-3h-1v1h1c1 0 2 1.22 2 2.5s-1.02 2.5-2 2.5H9c-0.98 0-2-1.22-2-2.5 0-0.83 0.42-1.64 1-2.09v-1.16c-1.09 0.53-2 1.84-2 3.25 0 1.81 1.55 3.5 3 3.5h4c1.45 0 3-1.69 3-3.5s-1.5-3.5-3-3.5z"></path></svg></a>Requires</h2> |
| 38 | + |
| 39 | + <ul> |
| 40 | + <li>httplib2</li> |
| 41 | + <li>simplejson</li> |
| 42 | + <li>six</li> |
| 43 | + </ul> |
| 44 | + |
| 45 | + <h2><a id="user-content-instagram-rest-and-search-apis" class="anchor" href="#instagram-rest-and-search-apis" aria-hidden="true"><svg aria-hidden="true" class="octicon octicon-link" height="16" version="1.1" viewBox="0 0 16 16" width="16"><path d="M4 9h1v1h-1c-1.5 0-3-1.69-3-3.5s1.55-3.5 3-3.5h4c1.45 0 3 1.69 3 3.5 0 1.41-0.91 2.72-2 3.25v-1.16c0.58-0.45 1-1.27 1-2.09 0-1.28-1.02-2.5-2-2.5H4c-0.98 0-2 1.22-2 2.5s1 2.5 2 2.5z m9-3h-1v1h1c1 0 2 1.22 2 2.5s-1.02 2.5-2 2.5H9c-0.98 0-2-1.22-2-2.5 0-0.83 0.42-1.64 1-2.09v-1.16c-1.09 0.53-2 1.84-2 3.25 0 1.81 1.55 3.5 3 3.5h4c1.45 0 3-1.69 3-3.5s-1.5-3.5-3-3.5z"></path></svg></a>Instagram REST and Search APIs</h2> |
| 46 | + |
| 47 | + <p>Our <a href="http://instagram.com/developer">developer site</a> documents all the Instagram REST and Search APIs.</p> |
| 48 | + |
| 49 | + <h2><a id="user-content-blog" class="anchor" href="#blog" aria-hidden="true"><svg aria-hidden="true" class="octicon octicon-link" height="16" version="1.1" viewBox="0 0 16 16" width="16"><path d="M4 9h1v1h-1c-1.5 0-3-1.69-3-3.5s1.55-3.5 3-3.5h4c1.45 0 3 1.69 3 3.5 0 1.41-0.91 2.72-2 3.25v-1.16c0.58-0.45 1-1.27 1-2.09 0-1.28-1.02-2.5-2-2.5H4c-0.98 0-2 1.22-2 2.5s1 2.5 2 2.5z m9-3h-1v1h1c1 0 2 1.22 2 2.5s-1.02 2.5-2 2.5H9c-0.98 0-2-1.22-2-2.5 0-0.83 0.42-1.64 1-2.09v-1.16c-1.09 0.53-2 1.84-2 3.25 0 1.81 1.55 3.5 3 3.5h4c1.45 0 3-1.69 3-3.5s-1.5-3.5-3-3.5z"></path></svg></a>Blog</h2> |
| 50 | + |
| 51 | + <p>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: <a href="http://developers.instagram.com">http://developers.instagram.com</a>.</p> |
| 52 | + |
| 53 | + <h2><a id="user-content-community" class="anchor" href="#community" aria-hidden="true"><svg aria-hidden="true" class="octicon octicon-link" height="16" version="1.1" viewBox="0 0 16 16" width="16"><path d="M4 9h1v1h-1c-1.5 0-3-1.69-3-3.5s1.55-3.5 3-3.5h4c1.45 0 3 1.69 3 3.5 0 1.41-0.91 2.72-2 3.25v-1.16c0.58-0.45 1-1.27 1-2.09 0-1.28-1.02-2.5-2-2.5H4c-0.98 0-2 1.22-2 2.5s1 2.5 2 2.5z m9-3h-1v1h1c1 0 2 1.22 2 2.5s-1.02 2.5-2 2.5H9c-0.98 0-2-1.22-2-2.5 0-0.83 0.42-1.64 1-2.09v-1.16c-1.09 0.53-2 1.84-2 3.25 0 1.81 1.55 3.5 3 3.5h4c1.45 0 3-1.69 3-3.5s-1.5-3.5-3-3.5z"></path></svg></a>Community</h2> |
| 54 | + |
| 55 | + <p>The <a href="http://stackoverflow.com/questions/tagged/instagram/">Stack Overflow community</a> 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.</p> |
| 56 | + |
| 57 | + <h2><a id="user-content-authentication" class="anchor" href="#authentication" aria-hidden="true"><svg aria-hidden="true" class="octicon octicon-link" height="16" version="1.1" viewBox="0 0 16 16" width="16"><path d="M4 9h1v1h-1c-1.5 0-3-1.69-3-3.5s1.55-3.5 3-3.5h4c1.45 0 3 1.69 3 3.5 0 1.41-0.91 2.72-2 3.25v-1.16c0.58-0.45 1-1.27 1-2.09 0-1.28-1.02-2.5-2-2.5H4c-0.98 0-2 1.22-2 2.5s1 2.5 2 2.5z m9-3h-1v1h1c1 0 2 1.22 2 2.5s-1.02 2.5-2 2.5H9c-0.98 0-2-1.22-2-2.5 0-0.83 0.42-1.64 1-2.09v-1.16c-1.09 0.53-2 1.84-2 3.25 0 1.81 1.55 3.5 3 3.5h4c1.45 0 3-1.69 3-3.5s-1.5-3.5-3-3.5z"></path></svg></a>Authentication</h2> |
| 58 | + |
| 59 | + <p>Instagram API uses the OAuth2 protocol for authentication, but not all functionality requires authentication. |
| 60 | + See the docs for more information: <a href="http://instagram.com/developer/authentication/">http://instagram.com/developer/authentication/</a></p> |
| 61 | + |
| 62 | + <h3><a id="user-content-obtaining-an-access-token" class="anchor" href="#obtaining-an-access-token" aria-hidden="true"><svg aria-hidden="true" class="octicon octicon-link" height="16" version="1.1" viewBox="0 0 16 16" width="16"><path d="M4 9h1v1h-1c-1.5 0-3-1.69-3-3.5s1.55-3.5 3-3.5h4c1.45 0 3 1.69 3 3.5 0 1.41-0.91 2.72-2 3.25v-1.16c0.58-0.45 1-1.27 1-2.09 0-1.28-1.02-2.5-2-2.5H4c-0.98 0-2 1.22-2 2.5s1 2.5 2 2.5z m9-3h-1v1h1c1 0 2 1.22 2 2.5s-1.02 2.5-2 2.5H9c-0.98 0-2-1.22-2-2.5 0-0.83 0.42-1.64 1-2.09v-1.16c-1.09 0.53-2 1.84-2 3.25 0 1.81 1.55 3.5 3 3.5h4c1.45 0 3-1.69 3-3.5s-1.5-3.5-3-3.5z"></path></svg></a>Obtaining an access token</h3> |
| 63 | + |
| 64 | + <p>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. |
| 65 | + 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.</p> |
| 66 | + |
| 67 | + <h3><a id="user-content-authenticating-a-user" class="anchor" href="#authenticating-a-user" aria-hidden="true"><svg aria-hidden="true" class="octicon octicon-link" height="16" version="1.1" viewBox="0 0 16 16" width="16"><path d="M4 9h1v1h-1c-1.5 0-3-1.69-3-3.5s1.55-3.5 3-3.5h4c1.45 0 3 1.69 3 3.5 0 1.41-0.91 2.72-2 3.25v-1.16c0.58-0.45 1-1.27 1-2.09 0-1.28-1.02-2.5-2-2.5H4c-0.98 0-2 1.22-2 2.5s1 2.5 2 2.5z m9-3h-1v1h1c1 0 2 1.22 2 2.5s-1.02 2.5-2 2.5H9c-0.98 0-2-1.22-2-2.5 0-0.83 0.42-1.64 1-2.09v-1.16c-1.09 0.53-2 1.84-2 3.25 0 1.81 1.55 3.5 3 3.5h4c1.45 0 3-1.69 3-3.5s-1.5-3.5-3-3.5z"></path></svg></a>Authenticating a user</h3> |
| 68 | + |
| 69 | + <p>The provided sample app shows a simple OAuth flow for authenticating a user and getting an access token for them.</p> |
| 70 | + |
| 71 | + <h3><a id="user-content-using-an-access-token" class="anchor" href="#using-an-access-token" aria-hidden="true"><svg aria-hidden="true" class="octicon octicon-link" height="16" version="1.1" viewBox="0 0 16 16" width="16"><path d="M4 9h1v1h-1c-1.5 0-3-1.69-3-3.5s1.55-3.5 3-3.5h4c1.45 0 3 1.69 3 3.5 0 1.41-0.91 2.72-2 3.25v-1.16c0.58-0.45 1-1.27 1-2.09 0-1.28-1.02-2.5-2-2.5H4c-0.98 0-2 1.22-2 2.5s1 2.5 2 2.5z m9-3h-1v1h1c1 0 2 1.22 2 2.5s-1.02 2.5-2 2.5H9c-0.98 0-2-1.22-2-2.5 0-0.83 0.42-1.64 1-2.09v-1.16c-1.09 0.53-2 1.84-2 3.25 0 1.81 1.55 3.5 3 3.5h4c1.45 0 3-1.69 3-3.5s-1.5-3.5-3-3.5z"></path></svg></a>Using an access token</h3> |
| 72 | + |
| 73 | + <p>Once you have an access token (whether via the script or from the user flow), you can pass that token into the InstagramAPI constructor:</p> |
| 74 | + |
| 75 | + <div class="highlight highlight-source-python"><pre><span class="pl-k">from</span> instagram.client <span class="pl-k">import</span> InstagramAPI |
| 76 | + |
| 77 | +access_token <span class="pl-k">=</span> <span class="pl-s"><span class="pl-pds">"</span>YOUR_ACCESS_TOKEN<span class="pl-pds">"</span></span> |
| 78 | +client_secret <span class="pl-k">=</span> <span class="pl-s"><span class="pl-pds">"</span>YOUR_CLIENT_SECRET<span class="pl-pds">"</span></span> |
| 79 | +api <span class="pl-k">=</span> InstagramAPI(<span class="pl-v">access_token</span><span class="pl-k">=</span>access_token, <span class="pl-v">client_secret</span><span class="pl-k">=</span>client_secret) |
| 80 | +recent_media, next_ <span class="pl-k">=</span> api.user_recent_media(<span class="pl-v">user_id</span><span class="pl-k">=</span><span class="pl-s"><span class="pl-pds">"</span>userid<span class="pl-pds">"</span></span>, <span class="pl-v">count</span><span class="pl-k">=</span><span class="pl-c1">10</span>) |
| 81 | + <span class="pl-k">for</span> media <span class="pl-k">in</span> recent_media: |
| 82 | + <span class="pl-c1">print</span> media.caption.text</pre></div> |
| 83 | + |
| 84 | + <h3><a id="user-content-making-unauthenticated-requests" class="anchor" href="#making-unauthenticated-requests" aria-hidden="true"><svg aria-hidden="true" class="octicon octicon-link" height="16" version="1.1" viewBox="0 0 16 16" width="16"><path d="M4 9h1v1h-1c-1.5 0-3-1.69-3-3.5s1.55-3.5 3-3.5h4c1.45 0 3 1.69 3 3.5 0 1.41-0.91 2.72-2 3.25v-1.16c0.58-0.45 1-1.27 1-2.09 0-1.28-1.02-2.5-2-2.5H4c-0.98 0-2 1.22-2 2.5s1 2.5 2 2.5z m9-3h-1v1h1c1 0 2 1.22 2 2.5s-1.02 2.5-2 2.5H9c-0.98 0-2-1.22-2-2.5 0-0.83 0.42-1.64 1-2.09v-1.16c-1.09 0.53-2 1.84-2 3.25 0 1.81 1.55 3.5 3 3.5h4c1.45 0 3-1.69 3-3.5s-1.5-3.5-3-3.5z"></path></svg></a>Making unauthenticated requests</h3> |
| 85 | + |
| 86 | + <p>For methods that don't require authentication, you can just pass your client ID and optionally client secret into the InstagramAPI |
| 87 | + constructor:</p> |
| 88 | + |
| 89 | + <div class="highlight highlight-source-python"><pre>api <span class="pl-k">=</span> InstagramAPI(<span class="pl-v">client_id</span><span class="pl-k">=</span><span class="pl-s"><span class="pl-pds">'</span>YOUR_CLIENT_ID<span class="pl-pds">'</span></span>, <span class="pl-v">client_secret</span><span class="pl-k">=</span><span class="pl-s"><span class="pl-pds">'</span>YOUR_CLIENT_SECRET<span class="pl-pds">'</span></span>) |
| 90 | +popular_media <span class="pl-k">=</span> api.media_popular(<span class="pl-v">count</span><span class="pl-k">=</span><span class="pl-c1">20</span>) |
| 91 | + <span class="pl-k">for</span> media <span class="pl-k">in</span> popular_media: |
| 92 | + <span class="pl-c1">print</span> media.images[<span class="pl-s"><span class="pl-pds">'</span>standard_resolution<span class="pl-pds">'</span></span>].url</pre></div> |
| 93 | + |
| 94 | + <h2><a id="user-content-real-time-subscriptions" class="anchor" href="#real-time-subscriptions" aria-hidden="true"><svg aria-hidden="true" class="octicon octicon-link" height="16" version="1.1" viewBox="0 0 16 16" width="16"><path d="M4 9h1v1h-1c-1.5 0-3-1.69-3-3.5s1.55-3.5 3-3.5h4c1.45 0 3 1.69 3 3.5 0 1.41-0.91 2.72-2 3.25v-1.16c0.58-0.45 1-1.27 1-2.09 0-1.28-1.02-2.5-2-2.5H4c-0.98 0-2 1.22-2 2.5s1 2.5 2 2.5z m9-3h-1v1h1c1 0 2 1.22 2 2.5s-1.02 2.5-2 2.5H9c-0.98 0-2-1.22-2-2.5 0-0.83 0.42-1.64 1-2.09v-1.16c-1.09 0.53-2 1.84-2 3.25 0 1.81 1.55 3.5 3 3.5h4c1.45 0 3-1.69 3-3.5s-1.5-3.5-3-3.5z"></path></svg></a>Real-time Subscriptions:</h2> |
| 95 | + |
| 96 | + <p>See the docs for more on real-time subscriptions: <a href="http://instagr.am/developer/realtime/">http://instagr.am/developer/realtime/</a></p> |
| 97 | + |
| 98 | + <p>You can use the API to subscribe to users, tags, locations, or geographies:</p> |
| 99 | + |
| 100 | + <div class="highlight highlight-source-python"><pre><span class="pl-c"># Subscribe to updates for all users authenticated to your app</span> |
| 101 | +api.create_subscription(<span class="pl-v">object</span><span class="pl-k">=</span><span class="pl-s"><span class="pl-pds">'</span>user<span class="pl-pds">'</span></span>, <span class="pl-v">aspect</span><span class="pl-k">=</span><span class="pl-s"><span class="pl-pds">'</span>media<span class="pl-pds">'</span></span>, <span class="pl-v">callback_url</span><span class="pl-k">=</span><span class="pl-s"><span class="pl-pds">'</span>http://mydomain.com/hook/instagram<span class="pl-pds">'</span></span>) |
| 102 | + |
| 103 | + <span class="pl-c"># Subscribe to all media tagged with 'fox'</span> |
| 104 | +api.create_subscription(<span class="pl-v">object</span><span class="pl-k">=</span><span class="pl-s"><span class="pl-pds">'</span>tag<span class="pl-pds">'</span></span>, <span class="pl-v">object_id</span><span class="pl-k">=</span><span class="pl-s"><span class="pl-pds">'</span>fox<span class="pl-pds">'</span></span>, <span class="pl-v">aspect</span><span class="pl-k">=</span><span class="pl-s"><span class="pl-pds">'</span>media<span class="pl-pds">'</span></span>, <span class="pl-v">callback_url</span><span class="pl-k">=</span><span class="pl-s"><span class="pl-pds">'</span>http://mydomain.com/hook/instagram<span class="pl-pds">'</span></span>) |
| 105 | + |
| 106 | + <span class="pl-c"># Subscribe to all media in a given location</span> |
| 107 | +api.create_subscription(<span class="pl-v">object</span><span class="pl-k">=</span><span class="pl-s"><span class="pl-pds">'</span>location<span class="pl-pds">'</span></span>, <span class="pl-v">object_id</span><span class="pl-k">=</span><span class="pl-s"><span class="pl-pds">'</span>1257285<span class="pl-pds">'</span></span>, <span class="pl-v">aspect</span><span class="pl-k">=</span><span class="pl-s"><span class="pl-pds">'</span>media<span class="pl-pds">'</span></span>, <span class="pl-v">callback_url</span><span class="pl-k">=</span><span class="pl-s"><span class="pl-pds">'</span>http://mydomain.com/hook/instagram<span clas |
| 108 | + </div> |
| 109 | + </div> |
| 110 | + |
| 111 | + <div id="footer"> |
| 112 | + </div> |
| 113 | + </div> |
| 114 | + |
| 115 | + |
| 116 | + <!--{* JavaScript *}--> |
| 117 | + <!--{* jQuery *}--> |
| 118 | + <script type="text/javascript" src="//ajax.googleapis.com/ajax/libs/jquery/2.2.2/jquery.js"></script> |
| 119 | + <!--{* Bootstrap *}--> |
| 120 | + <script type="text/javascript" src="//maxcdn.bootstrapcdn.com/bootstrap/3.3.6/js/bootstrap.js"></script> |
| 121 | + </body> |
| 122 | +</html> |
0 commit comments