{"id":13494954,"url":"https://github.com/facebookarchive/python-instagram","last_synced_at":"2025-09-28T20:31:54.910Z","repository":{"id":1368549,"uuid":"1318988","full_name":"facebookarchive/python-instagram","owner":"facebookarchive","description":"Python Client for Instagram API","archived":true,"fork":false,"pushed_at":"2020-10-01T16:22:11.000Z","size":342,"stargazers_count":3043,"open_issues_count":118,"forks_count":1098,"subscribers_count":262,"default_branch":"master","last_synced_at":"2025-09-24T20:34:01.713Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"http://instagram.com/developers/","language":"Python","has_issues":false,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"other","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/facebookarchive.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.md","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2011-02-02T02:45:23.000Z","updated_at":"2025-09-18T02:09:45.000Z","dependencies_parsed_at":"2022-07-14T18:00:32.683Z","dependency_job_id":null,"html_url":"https://github.com/facebookarchive/python-instagram","commit_stats":null,"previous_names":["instagram/python-instagram"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/facebookarchive/python-instagram","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/facebookarchive%2Fpython-instagram","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/facebookarchive%2Fpython-instagram/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/facebookarchive%2Fpython-instagram/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/facebookarchive%2Fpython-instagram/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/facebookarchive","download_url":"https://codeload.github.com/facebookarchive/python-instagram/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/facebookarchive%2Fpython-instagram/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":276881832,"owners_count":25721413,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-09-25T02:00:09.612Z","response_time":80,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-07-31T19:01:29.883Z","updated_at":"2025-09-28T20:31:54.528Z","avatar_url":"https://github.com/facebookarchive.png","language":"Python","readme":"- - -\n\n**_This project is not actively maintained. Proceed at your own risk!_**\n\n- - - \n\n[![Build Status](https://api.travis-ci.org/Instagram/python-instagram.svg)](https://travis-ci.org/Instagram/python-instagram)\n\npython-instagram\n======\nA Python 2/3 client for the Instagram REST and Search APIs\n\nInstallation\n-----\n```\npip install python-instagram\n```\nRequires\n-----\n  * httplib2\n  * simplejson\n  * six\n\n\nInstagram REST and Search APIs\n------------------------------\nOur [developer site](http://instagram.com/developer) documents all the Instagram REST and Search APIs.\n\n\nBlog\n----------------------------\nThe [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).\n\n\nCommunity\n----------------------\nThe [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.\n\n\nAuthentication\n-----\n\nInstagram API uses the OAuth2 protocol for authentication, but not all functionality requires authentication.\nSee the docs for more information: http://instagram.com/developer/authentication/\n\n### Obtaining an access token\n\nIf 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.\nIt 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.\n\n### Authenticating a user\n\nThe provided sample app shows a simple OAuth flow for authenticating a user and getting an access token for them.\n\n### Using an access token\n\nOnce you have an access token (whether via the script or from the user flow), you can  pass that token into the InstagramAPI constructor:\n\n``` python\nfrom instagram.client import InstagramAPI\n\naccess_token = \"YOUR_ACCESS_TOKEN\"\nclient_secret = \"YOUR_CLIENT_SECRET\"\napi = InstagramAPI(access_token=access_token, client_secret=client_secret)\nrecent_media, next_ = api.user_recent_media(user_id=\"userid\", count=10)\nfor media in recent_media:\n   print media.caption.text\n```\n       \n### Making unauthenticated requests\n\nFor methods that don't require authentication, you can just pass your client ID and optionally client secret into the InstagramAPI \nconstructor:\n\n``` python\napi = InstagramAPI(client_id='YOUR_CLIENT_ID', client_secret='YOUR_CLIENT_SECRET')\npopular_media = api.media_popular(count=20)\nfor media in popular_media:\n    print media.images['standard_resolution'].url\n```\n\nReal-time Subscriptions:\n-----\n\nSee the docs for more on real-time subscriptions: http://instagr.am/developer/realtime/\n\nYou can use the API to subscribe to users, tags, locations, or geographies:\n\n``` python\n# Subscribe to updates for all users authenticated to your app\napi.create_subscription(object='user', aspect='media', callback_url='http://mydomain.com/hook/instagram')\n\n# Subscribe to all media tagged with 'fox'\napi.create_subscription(object='tag', object_id='fox', aspect='media', callback_url='http://mydomain.com/hook/instagram')\n\n# Subscribe to all media in a given location\napi.create_subscription(object='location', object_id='1257285', aspect='media', callback_url='http://mydomain.com/hook/instagram')\n\n# Subscribe to all media in a geographic area\napi.create_subscription(object='geography', lat=35.657872, lng=139.70232, radius=1000, aspect='media', callback_url='http://mydomain.com/hook/instagram')\n```\n\nAlong with that, you would typically register subscription \"reactors\" for processing the different subscription types:\n\n``` python\n# React to user type updates\nreactor = subscriptions.SubscriptionsReactor()\nreactor.register_callback(subscriptions.SubscriptionType.USER, process_user_update)\n```\n    \nSee the provided sample app for an example of making a subscription, reacting to it, an processing the updates.\n\nYou can also use the API to list and delete subscriptions:\n\n``` python\napi.list_subscriptions()\napi.delete_subscriptions(id=342342)\n```\n   \n\nData Retrieval:\n-----\n\nSee the endpoints docs for more on these methods: http://instagr.am/developer/endpoints/\n\nThe methods with a * return two values, where the second is a pagination parameter. Here's an example of retrieving recent media:\n\n``` python\nrecent_media, next_ = api.user_recent_media()\nphotos = []\nfor media in recent_media:\n    photos.append('\u003cimg src=\"%s\"/\u003e' % media.images['thumbnail'].url)\n```            \n\nAnd an example of exhaustively pursuing a paginated endpoint:\n\n``` python\nfollows, next_ = api.user_follows()\nwhile next_:\n    more_follows, next_ = api.user_follows(with_next_url=next_)\n    follows.extend(more_follows)\n```\n\nUsers: http://instagr.am/developer/endpoints/users/\n    \n``` python\napi.user(user_id)\napi.user_media_feed()*\napi.user_liked_media()*\napi.user_recent_media(user_id, count, max_id)*\napi.user_search(q, count, lat, lng, min_timestamp, max_timestamp)\n```    \n   \nRelationships: http://instagr.am/developer/endpoints/relationships/\n\n``` python\napi.user_incoming_requests()\napi.user_follows(user_id)*\napi.user_followed_by(user_id)*\napi.follow_user(user_id)\napi.unfollow_user(user_id)\napi.block_user(user_id)\napi.unblock_user(user_id)\napi.approve_user_request(user_id)\napi.ignore_user_request(user_id)\napi.user_relationship(user_id)\n```\n\nMedia: http://instagr.am/developer/endpoints/media/\n\n``` python\napi.media(media_id)\napi.media_popular(count, max_id)\napi.media_search(q, count, lat, lng, min_timestamp, max_timestamp)\n```\n    \nComments: http://instagr.am/developer/endpoints/comments/\n\n``` python\napi.media_comments(media_id)\napi.create_media_comment(media_id, text)\napi.delete_comment(media_id, comment_id)\n```\n    \nLikes: http://instagr.am/developer/endpoints/likes/\n\n``` python\napi.media_likes(media_id)\napi.like_media(media_id)\napi.unlike_media(media_id)\n```\n    \nTags: http://instagr.am/developer/endpoints/tags/\n\n``` python\napi.tag(tag_name) \napi.tag_recent_media(count, max_tag_id, tag_name)*\napi.tag_search(q, count)*\n```\n \nLocations: http://instagr.am/developer/endpoints/locations/\n\n``` python\napi.location(location_id)\napi.location_recent_media(count, max_id, location_id)*\napi.location_search(q, count, lat, lng, foursquare_id, foursquare_v2_id)\n```\n    \nGeographies: http://instagr.am/developer/endpoints/geographies/\n\n``` python\napi.geography_recent_media(count, max_id, geography_id)*\n```\n\nError handling\n------\nImporting the bind module allows handling of specific error status codes. An example is provided below:\n``` python\nfrom instagram.bind import InstagramAPIError\n\ntry:\n   # your code goes here\nexcept InstagramAPIError as e:\n   if (e.status_code == 400):\n      print \"\\nUser is set to private.\"\n```\n\nTrouble Shooting\n------\n\nIf you get an error of a module not being defined during the Instagram import call, this might update a necessary package.\n```\nsudo pip install --upgrade six\n```\n\nSample app\n------\nThis repository includes a one-file sample app that uses the bottle framework and demonstrates\nauthentication, subscriptions, and update processing. To try it out:\n\n  * Download bottle if you don't already have it: pip install bottle\n  * Download bottle-session if you don't already have it: pip install bottle-session\n  * Download and run a redis instance on port 6379 if you don't already have it. Check http://redis.io for instructions.\n  * Set your redirect URI to 'http://localhost:8515/oauth_callback' in your dev profile\n  * Open up sample\\_app.py, update it with your client\\_id and secret, and set redirect URI to 'http://localhost:8515/oauth_callback'\n  * Run the file; it will host a local server on port 8515.\n  * Try visiting http://localhost:8515 in your browser\n\nContributing\n------------\nIn the spirit of [free software](http://www.fsf.org/licensing/essays/free-sw.html), **everyone** is encouraged to help improve this project.\n\nHere are some ways *you* can contribute:\n\n* by using alpha, beta, and prerelease versions\n* by reporting bugs\n* by suggesting new features\n* by writing or editing documentation\n* by writing specifications\n* by writing code (**no patch is too small**: fix typos, add comments, clean up inconsistent whitespace)\n* by refactoring code\n* by closing [issues](http://github.com/Instagram/python-instagram/issues)\n* by reviewing patches\n\n\nSubmitting an Issue\n-------------------\nWe use the [GitHub issue tracker](https://github.com/Instagram/python-instagram/issues) to track bugs and\nfeatures. Before submitting a bug report or feature request, check to make sure it hasn't already\nbeen submitted. You can indicate support for an existing issue by voting it up. When submitting a\nbug report, please include a [Gist](http://gist.github.com/) that includes a stack trace and any\ndetails that may be necessary to reproduce the bug, including your version number, and\noperating system. Ideally, a bug report should include a pull request with failing specs.\n\n\nSubmitting a Pull Request\n-------------------------\n1. Fork the project.\n2. Create a topic branch.\n3. Implement your feature or bug fix.\n4. Run \u003ctt\u003epython tests.py \u003c/tt\u003e.\n5. Add a test for your feature or bug fix.\n6. Run \u003ctt\u003epython tests.py \u003c/tt\u003e. If your changes are not 100% covered, go back to step 5.\n7. Commit and push your changes.\n8. Submit a pull request.\n9. If you haven't already, complete the Contributor License Agreement (\"CLA\").\n\nContributor License Agreement (\"CLA\")\n_____________________________________\nIn order to accept your pull request, we need you to submit a CLA. You only need\nto do this once to work on any of Instagram's or Facebook's open source projects.\n\nComplete your CLA here: [https://code.facebook.com/cla](https://code.facebook.com/cla)\n\n\nCopyright\n---------\nCopyright (c) 2014, Facebook, Inc. All rights reserved.\nBy contributing to python-instagram, you agree that your contributions will be licensed under its BSD license.\nSee [LICENSE](https://github.com/Instagram/python-instagram/blob/master/LICENSE.md) for details.\n","funding_links":[],"categories":["Python","\u003ca name=\"Python\"\u003e\u003c/a\u003ePython","APIs \u0026 SDKs"],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffacebookarchive%2Fpython-instagram","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ffacebookarchive%2Fpython-instagram","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffacebookarchive%2Fpython-instagram/lists"}