Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: ping/instagram_private_api
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: 1.5.3
Choose a base ref
...
head repository: ping/instagram_private_api
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: master
Choose a head ref
Loading
Showing with 1,182 additions and 226 deletions.
  1. +1 −0 .github/FUNDING.yml
  2. +9 −18 .github/ISSUE_TEMPLATE.md
  3. +57 −0 .github/ISSUE_TEMPLATE/bug-report.md
  4. +33 −0 .github/ISSUE_TEMPLATE/feature-request.md
  5. +55 −0 .github/ISSUE_TEMPLATE/question-others.md
  6. +1 −1 .travis.yml
  7. +42 −0 CHANGELOG.md
  8. +12 −10 README.md
  9. +10 −0 docs/api.rst
  10. +2 −2 docs/conf.py
  11. +17 −0 docs/faq.rst
  12. +3 −3 docs/usage.rst
  13. +9 −9 examples/pagination.py
  14. +3 −3 examples/savesettings_logincallback.py
  15. +1 −1 instagram_private_api/__init__.py
  16. +61 −26 instagram_private_api/client.py
  17. +2 −2 instagram_private_api/compatpatch.py
  18. +12 −10 instagram_private_api/constants.py
  19. +1 −0 instagram_private_api/endpoints/__init__.py
  20. +8 −1 instagram_private_api/endpoints/discover.py
  21. +21 −3 instagram_private_api/endpoints/feed.py
  22. +63 −0 instagram_private_api/endpoints/igtv.py
  23. +73 −0 instagram_private_api/endpoints/locations.py
  24. +12 −4 instagram_private_api/endpoints/media.py
  25. +10 −4 instagram_private_api/endpoints/misc.py
  26. +54 −0 instagram_private_api/endpoints/tags.py
  27. +1 −1 instagram_private_api/endpoints/upload.py
  28. +6 −14 instagram_private_api/endpoints/users.py
  29. +8 −4 instagram_private_api/errors.py
  30. +9 −4 instagram_private_api/http.py
  31. +3 −2 instagram_web_api/__init__.py
  32. +350 −71 instagram_web_api/client.py
  33. +1 −1 instagram_web_api/compatpatch.py
  34. +15 −0 instagram_web_api/errors.py
  35. +14 −3 instagram_web_api/http.py
  36. +11 −2 setup.py
  37. +1 −0 tests/private/__init__.py
  38. +4 −2 tests/private/client.py
  39. +3 −2 tests/private/compatpatch.py
  40. +2 −0 tests/private/discover.py
  41. +5 −1 tests/private/feed.py
  42. +35 −0 tests/private/igtv.py
  43. +10 −0 tests/private/locations.py
  44. +12 −11 tests/private/media.py
  45. +10 −0 tests/private/tags.py
  46. +4 −1 tests/private/upload.py
  47. +1 −2 tests/private/users.py
  48. +4 −2 tests/test_private_api.py
  49. +1 −1 tests/test_web_api.py
  50. +4 −1 tests/web/client.py
  51. +33 −2 tests/web/feed.py
  52. +26 −1 tests/web/media.py
  53. +24 −0 tests/web/unauthenticated.py
  54. +5 −1 tests/web/upload.py
  55. +8 −0 tests/web/user.py
1 change: 1 addition & 0 deletions .github/FUNDING.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
custom: ['https://buymeacoffee.com/ping/']
27 changes: 9 additions & 18 deletions .github/ISSUE_TEMPLATE.md
Original file line number Diff line number Diff line change
@@ -1,16 +1,17 @@
## Please follow the guide below

- Issues submitted without this template format will be **ignored**.
- You will be asked some questions and requested to provide some information, please read them **carefully** and answer completely.
- Please read the questions **carefully** and answer completely.
- Do not post screenshots of error messages or code.
- Put an `x` into all the boxes [ ] relevant to your issue (like so [x] no spaces).
- Put an `x` into all the boxes [ ] relevant to your issue (==> [x] *no* spaces).
- Use the *Preview* tab to see how your issue will actually look like.
- Issues about reverse engineering is out of scope and will be closed without response.
- Any mention of spam-like actions or spam-related tools/libs/etc is strictly **not allowed**.

---

### Before submitting an issue, make sure you have:
- [ ] Updated to the lastest version v1.5.3
- [ ] Updated to the lastest version v1.6.0
- [ ] Read the [README](https://github.com/ping/instagram_private_api/blob/master/README.md) and [docs](https://instagram-private-api.readthedocs.io/en/latest/)
- [ ] [Searched](https://github.com/ping/instagram_private_api/search?type=Issues) the bugtracker for similar issues including **closed** ones
- [ ] Reviewed the sample code in [tests](https://github.com/ping/instagram_private_api/tree/master/tests) and [examples](https://github.com/ping/instagram_private_api/tree/master/examples)
@@ -19,19 +20,15 @@
- [ ] app (``instagram_private_api/``)
- [ ] web (``instagram_web_api/``)

### Purpose of your issue?
- [ ] Bug report (encountered problems/errors)
- [ ] Feature request (request for a new functionality)
- [ ] Question
- [ ] Other

---

### The following sections requests more details for particular types of issues, you can remove any section (the contents between the triple ---) not applicable to your issue.
### Describe your issue

---
Please make sure the description is worded well enough to be understood with as much context and examples as possible.

### For a *bug report*, you **must** include the Python version used, *code* that will reproduce the error, and the *error log/traceback*.
If describing a problem or a bug, code to replicate the issue *must* be provided below.

---

Paste the output of ``python -V`` here:

@@ -52,9 +49,3 @@ Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ZeroDivisionError: integer division or modulo by zero
```

---

### Describe your issue

Explanation of your issue goes here. Please make sure the description is worded well enough to be understood with as much context and examples as possible.
57 changes: 57 additions & 0 deletions .github/ISSUE_TEMPLATE/bug-report.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
---
name: Bug Report
about: Report an error or problem

---

## Please follow the guide below

- Issues submitted without this template format will be **ignored**.
- Please read the questions **carefully** and answer completely.
- Do not post screenshots of error messages or code.
- Put an `x` into all the boxes [ ] relevant to your issue (==> [x] *NO* spaces).
- Use the *Preview* tab to see how your issue will actually look like.
- Issues about reverse engineering is out of scope and will be closed without response.
- Any mention of spam-like actions or spam-related tools/libs/etc is strictly **not allowed**.

---

### Before submitting an issue, make sure you have:
- [ ] Updated to the lastest version v1.6.0
- [ ] Read the [README](https://github.com/ping/instagram_private_api/blob/master/README.md) and [docs](https://instagram-private-api.readthedocs.io/en/latest/)
- [ ] [Searched](https://github.com/ping/instagram_private_api/search?type=Issues) the bugtracker for similar issues including **closed** ones
- [ ] Reviewed the sample code in [tests](https://github.com/ping/instagram_private_api/tree/master/tests) and [examples](https://github.com/ping/instagram_private_api/tree/master/examples)

### Which client are you using?
- [ ] app (``instagram_private_api/``)
- [ ] web (``instagram_web_api/``)

---

### Describe the Bug/Error:

Please make sure the description is worded well enough to be understood with as much context and examples as possible.

Code to replicate the error must be provided below.

---

Paste the output of ``python -V`` here:

Code:

```python
# Example code that will produce the error reported
from instagram_web_api import Client

web_api = Client()
user_feed_info = web_api.user_feed('1234567890', count=10)
```

Error/Debug Log:

```python
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ZeroDivisionError: integer division or modulo by zero
```
33 changes: 33 additions & 0 deletions .github/ISSUE_TEMPLATE/feature-request.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
---
name: Feature Request
about: Request for new functionality

---

## Please follow the guide below

- Issues submitted without this template format will be **ignored**.
- Read the questions **carefully** and answer completely.
- Do not post screenshots of error messages or code.
- Put an `x` into all the boxes [ ] relevant to your issue (==> [x] *no* spaces).
- Use the *Preview* tab to see how your issue will actually look like.
- Issues about reverse engineering is out of scope and will be closed without response.
- Any mention of spam-like actions or spam-related tools/libs/etc is strictly **not allowed**.

---

### Before submitting an issue, make sure you have:
- [ ] Updated to the lastest version v1.6.0
- [ ] Read the [README](https://github.com/ping/instagram_private_api/blob/master/README.md) and [docs](https://instagram-private-api.readthedocs.io/en/latest/)
- [ ] [Searched](https://github.com/ping/instagram_private_api/search?type=Issues) the bugtracker for similar issues including **closed** ones
- [ ] Reviewed the sample code in [tests](https://github.com/ping/instagram_private_api/tree/master/tests) and [examples](https://github.com/ping/instagram_private_api/tree/master/examples)

### Which client are you using?
- [ ] app (``instagram_private_api/``)
- [ ] web (``instagram_web_api/``)

---

### Describe your Feature Request:

Please make sure the description is worded well enough to be understood with as much context and examples as possible.
55 changes: 55 additions & 0 deletions .github/ISSUE_TEMPLATE/question-others.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
---
name: Question/Others
about: Not an error or feature request

---

## Please follow the guide below

- Issues submitted without this template format will be **ignored**.
- Rlease read them **carefully** and answer completely.
- Do not post screenshots of error messages or code.
- Put an `x` into all the boxes [ ] relevant to your issue (==> [x] *no* spaces).
- Use the *Preview* tab to see how your issue will actually look like.
- Issues about reverse engineering is out of scope and will be closed without response.
- Any mention of spam-like actions or spam-related tools/libs/etc is strictly **not allowed**.

---

### Before submitting an issue, make sure you have:
- [ ] Updated to the lastest version v1.6.0
- [ ] Read the [README](https://github.com/ping/instagram_private_api/blob/master/README.md) and [docs](https://instagram-private-api.readthedocs.io/en/latest/)
- [ ] [Searched](https://github.com/ping/instagram_private_api/search?type=Issues) the bugtracker for similar issues including **closed** ones
- [ ] Reviewed the sample code in [tests](https://github.com/ping/instagram_private_api/tree/master/tests) and [examples](https://github.com/ping/instagram_private_api/tree/master/examples)

### Which client are you using?
- [ ] app (``instagram_private_api/``)
- [ ] web (``instagram_web_api/``)

---

### Describe your Question/Issue:

Please make sure the description is worded well enough to be understood with as much context and examples as possible.

---

Paste the output of ``python -V`` here:

Code:

```python
# Example code that will produce the error reported
from instagram_web_api import Client

web_api = Client()
user_feed_info = web_api.user_feed('1234567890', count=10)
```

Error/Debug Log:

```python
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ZeroDivisionError: integer division or modulo by zero
```
2 changes: 1 addition & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
@@ -5,7 +5,7 @@ python:
- "3.5"

install:
- pip install flake8 pylint
- pip install flake8 'pylint<2.0'

script:
- flake8 --max-line-length=120 --exclude=./setup.py,./instagram_private_api/compat.py,./instagram_web_api/compat.py,./instagram_private_api/endpoints/__init__.py
42 changes: 42 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,47 @@
# Change Log

## 1.6.0
- Web API:
* Add ``highlight_reels()`` and ``highlight_reel_media()``
* Add ``tagged_user_feed()``
* Add ``tag_story_feed()`` and ``location_story_feed()``
* Update query hashes
* Fix for case sensitivity for tag feed
* Add ``delete_media()``
* Add ``proxy_handler`` kwarg to support custom proxy handler such as socks
- App API:
* :fire: __BREAKING CHANGE__: Change in user agent format for the app version
* :fire: __BREAKING CHANGE__: Change in argument list for ``search_users()``
* Add IGTV endpoints
* Update ``media_n_comments()``, ``search_users()``, ``news()``
* ``feed_location()`` deprecated
* Add ``kwargs`` to ``news()`` for paging support
* Add ``tag_section()`` and ``location_section()`` endpoints
* Add ``proxy_handler`` kwarg to support custom proxy handler such as socks

## 1.5.7
- Web API:
* Improve cookie expiry detection
- App API:
* Make change to cookiejar (in 1.5.6) backward compatible

## 1.5.6
- Web API:
* Add ``media_likers()``
* Fix ``user_info2()``
* Fix csrf token extraction
- App API:
* Fix client authentication expiry
* Improve get cookie value

## 1.5.5
- Web API:
* Fix for changes in the ``X-Instagram-GIS`` signed header requirement

## 1.5.4
- Web API:
* Fix for changes in the ``X-Instagram-GIS`` signed header requirement

## 1.5.3
- Web API:
* ``client.settings`` now includes ``user_agent`` which you should persist since ``rhx_gis`` is dependent on both the ``csrftoken`` (in cookie) and the client's ``user_agent``
22 changes: 12 additions & 10 deletions README.md
Original file line number Diff line number Diff line change
@@ -5,7 +5,7 @@ A Python wrapper for the Instagram private API with no 3rd party dependencies. S
![Python 2.7, 3.5](https://img.shields.io/badge/Python-2.7%2C%203.5-3776ab.svg?maxAge=2592000)
[![Release](https://img.shields.io/github/release/ping/instagram_private_api.svg?colorB=ff7043)](https://github.com/ping/instagram_private_api/releases)
[![Docs](https://img.shields.io/badge/docs-readthedocs.io-ff4980.svg?maxAge=2592000)](https://instagram-private-api.readthedocs.io/en/latest/)
[![Build](https://img.shields.io/travis/ping/instagram_private_api.svg)](https://travis-ci.org/ping/instagram_private_api)
[![Build](https://img.shields.io/travis/com/ping/instagram_private_api.svg)](https://travis-ci.com/ping/instagram_private_api)

[![Build](https://www.buymeacoffee.com/assets/img/custom_images/yellow_img.png)](https://www.buymeacoffee.com/ping)

@@ -19,8 +19,8 @@ Problems? Please check the [docs](https://instagram-private-api.readthedocs.io/e

- Supports many functions that are only available through the official app, such as:
* Multiple feeds, such as [user feed](https://instagram-private-api.readthedocs.io/en/latest/api.html#instagram_private_api.Client.user_feed), [location feed](https://instagram-private-api.readthedocs.io/en/latest/api.html#instagram_private_api.Client.feed_location), [tag feed](https://instagram-private-api.readthedocs.io/en/latest/api.html#instagram_private_api.Client.feed_tag), [popular feed](https://instagram-private-api.readthedocs.io/en/latest/api.html#instagram_private_api.Client.feed_popular)
* Post a [photo](https://instagram-private-api.readthedocs.io/en/latest/api.html#instagram_private_api.Client.friendships_destroy) or [video](https://instagram-private-api.readthedocs.io/en/latest/api.html#instagram_private_api.Client.post_video) to your feed or stories
* [Like](https://instagram-private-api.readthedocs.io/en/latest/api.html#instagram_private_api.Client.comment_like)/[unlike](https://instagram-private-api.readthedocs.io/en/latest/api.html#instagram_private_api.Client.comment_unlike) posts
* Post a [photo](https://instagram-private-api.readthedocs.io/en/latest/api.html#instagram_private_api.Client.post_photo) or [video](https://instagram-private-api.readthedocs.io/en/latest/api.html#instagram_private_api.Client.post_video) to your feed or stories
* [Like](https://instagram-private-api.readthedocs.io/en/latest/api.html#instagram_private_api.Client.post_like)/[unlike](https://instagram-private-api.readthedocs.io/en/latest/api.html#instagram_private_api.Client.delete_like) posts
* Get [post comments](https://instagram-private-api.readthedocs.io/en/latest/api.html#instagram_private_api.Client.media_comments)
* [Post](https://instagram-private-api.readthedocs.io/en/latest/api.html#instagram_private_api.Client.post_comment)/[delete](https://instagram-private-api.readthedocs.io/en/latest/api.html#instagram_web_api.Client.delete_comment) comments
* [Like](https://instagram-private-api.readthedocs.io/en/latest/api.html#instagram_private_api.Client.comment_like)/[unlike](https://instagram-private-api.readthedocs.io/en/latest/api.html#instagram_private_api.Client.comment_unlike) comments
@@ -44,11 +44,11 @@ Documentation is available at https://instagram-private-api.readthedocs.io/en/la

Install with pip:

``pip install git+https://git@github.com/ping/instagram_private_api.git@1.5.3``
``pip install git+https://git@github.com/ping/instagram_private_api.git@1.6.0``

To update:

``pip install git+https://git@github.com/ping/instagram_private_api.git@1.5.3 --upgrade``
``pip install git+https://git@github.com/ping/instagram_private_api.git@1.6.0 --upgrade``

To update with latest repo code:

@@ -57,6 +57,7 @@ To update with latest repo code:
Tested on Python 2.7 and 3.5.

## Usage

The [app API client](instagram_private_api/) emulates the official app and has a larger set of functions. The [web API client](instagram_web_api/) has a smaller set but can be used without logging in.

Your choice will depend on your use case.
@@ -83,7 +84,6 @@ for item in items:
print(item['media_or_ad']['code'])
```


### Option 2: Use the [official website's API](instagram_web_api/)

```python
@@ -95,21 +95,22 @@ web_api = Client(auto_patch=True, drop_incompat_keys=False)
user_feed_info = web_api.user_feed('329452045', count=10)
for post in user_feed_info:
print('%s from %s' % (post['link'], post['user']['username']))

# Some endpoints, e.g. user_following are available only after authentication
authed_web_api = Client(
auto_patch=True, authenticate=True,
username='YOUR_USERNAME', password='YOUR_PASSWORD')

following = authed_web_api.user_following('123456')
for user in following:
print(user['username'])

# Note: You can and should cache the cookie even for non-authenticated sessions.
# This saves the overhead of a single http request when the Client is initialised.
# This saves the overhead of a single http request when the Client is initialised.
```

### Avoiding Re-login

You are advised to persist/cache the auth cookie details to avoid logging in every time you make an api call. Excessive logins is a surefire way to get your account flagged for removal. It's also advisable to cache the client details such as user agent, etc together with the auth details.

The saved auth cookie can be reused for up to **90 days**.
@@ -121,6 +122,7 @@ Want to keep this project going? Please donate generously [https://www.buymeacof
[![Build](https://www.buymeacoffee.com/assets/img/custom_images/yellow_img.png)](https://www.buymeacoffee.com/ping)

## Support

Make sure to review the [contributing documentation](CONTRIBUTING.md) before submitting an issue report or pull request.

## Legal
10 changes: 10 additions & 0 deletions docs/api.rst
Original file line number Diff line number Diff line change
@@ -14,6 +14,12 @@ The api currently has two main interfaces:
- :class:`instagram_private_api.ClientLoginError`
- :class:`instagram_private_api.ClientLoginRequiredError`
- :class:`instagram_private_api.ClientCookieExpiredError`
- :class:`instagram_private_api.ClientThrottledError`
- :class:`instagram_private_api.ClientReqHeadersTooLargeError`
- :class:`instagram_private_api.ClientConnectionError`
- :class:`instagram_private_api.ClientCheckpointRequiredError`
- :class:`instagram_private_api.ClientChallengeRequiredError`
- :class:`instagram_private_api.ClientSentryBlockError`
- :class:`instagram_private_api.MediaRatios`
- :class:`instagram_private_api.MediaTypes`

@@ -22,6 +28,10 @@ The api currently has two main interfaces:
- :class:`instagram_web_api.ClientCompatPatch`
- :class:`instagram_web_api.ClientError`
- :class:`instagram_web_api.ClientCookieExpiredError`
- :class:`instagram_web_api.ClientConnectionError`
- :class:`instagram_web_api.ClientBadRequestError`
- :class:`instagram_web_api.ClientForbiddenError`
- :class:`instagram_web_api.ClientThrottledError`


App API
4 changes: 2 additions & 2 deletions docs/conf.py
Original file line number Diff line number Diff line change
@@ -59,9 +59,9 @@
# built documents.
#
# The short X.Y version.
version = u'1.5.3'
version = u'1.6.0'
# The full version, including alpha/beta/rc tags.
release = u'1.5.3'
release = u'1.6.0'

# The language for content autogenerated by Sphinx. Refer to documentation
# for a list of supported languages.
Loading