MIT License

项目介绍

ping/instagram_private_api 是一个托管在 GitHub 上的开源项目,主要使用 Python 编写,采用 MIT License 许可证,目前获得 3.3k 个 Star、603 次 Fork。

仓库全名
ping/instagram_private_api
开源许可证
MIT License
Star 数
3.3k
Fork 数
603
未关闭 Issue
142

README 摘要

Instagram Private API A Python wrapper for the Instagram private API with no 3rd party dependencies. Supports both the app and web APIs. Overview I wrote this to access Instagram's API when they clamped down on developer access. Because this is meant to achieve parity with the official public API, methods not available in the public API will generally have lower priority. Problems? Please check the docs before…

完整内容见 GitHub 原始 README 或本页 。

常见问题

instagram_private_api 用什么语言开发?

主要使用 Python 编写,采用 MIT License 许可证,目前有 3.3k 个 Star。

instagram_private_api 可以免费商用吗?

仓库采用 MIT License 许可证,可免费使用与修改,商业使用请遵守许可证条款(例如保留版权声明与许可声明)。

如何获取 instagram_private_api 的源码?

可以直接克隆仓库:git clone https://github.com/ping/instagram_private_api.git,默认分支为 master;安装与运行步骤见仓库 README。

instagram_private_api 最近还在维护吗?

仓库最近一次更新为 2024年5月6日,当前有 142 个未关闭 Issue;Star 数为 3.3k,可作为社区活跃度的参考。

关于

GitHub 原始描述(英文)

A Python library to access Instagram's private API.

描述取自 GitHub 官方 API,保持仓库作者书写的原文。

简要分析

热度分
4643
价值分
2178
活跃状态
活跃

语言占比

Python

Release

README

Instagram Private API

A Python wrapper for the Instagram private API with no 3rd party dependencies. Supports both the app and web APIs.

Python 2.7, 3.5 Release Docs Build

Build

Overview

I wrote this to access Instagram’s API when they clamped down on developer access. Because this is meant to achieve parity with the official public API, methods not available in the public API will generally have lower priority.

Problems? Please check the docs before submitting an issue.

Features

An extension module is available to help with common tasks like pagination, posting photos or videos.

Documentation

Documentation is available at https://instagram-private-api.readthedocs.io/en/latest/

Install

Install with pip:

pip install git+https://[email protected]/ping/[email protected]

To update:

pip install git+https://[email protected]/ping/[email protected] --upgrade

To update with latest repo code:

pip install git+https://[email protected]/ping/instagram_private_api.git --upgrade --force-reinstall

Tested on Python 2.7 and 3.5.

Usage

The app API client emulates the official app and has a larger set of functions. The web API client has a smaller set but can be used without logging in.

Your choice will depend on your use case.

The examples/ and tests/ are a good source of detailed sample code on how to use the clients, including a simple way to save the auth cookie for reuse.

Option 1: Use the official app’s API


from instagram_private_api import Client, ClientCompatPatch

user_name = 'YOUR_LOGIN_USER_NAME'
password = 'YOUR_PASSWORD'

api = Client(user_name, password)
results = api.feed_timeline()
items = [item for item in results.get('feed_items', [])
         if item.get('media_or_ad')]
for item in items:
    # Manually patch the entity to match the public api as closely as possible, optional
    # To automatically patch entities, initialise the Client with auto_patch=True
    ClientCompatPatch.media(item['media_or_ad'])
    print(item['media_or_ad']['code'])

Option 2: Use the official website’s API


from instagram_web_api import Client, ClientCompatPatch, ClientError, ClientLoginError

# Without any authentication
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.

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.

Want to keep this project going? Please donate generously https://www.buymeacoffee.com/ping

Build

Support

Make sure to review the contributing documentation before submitting an issue report or pull request.

Disclaimer: This is not affliated, endorsed or certified by Instagram. This is an independent and unofficial API. Strictly not for spam. Use at your own risk.

评论

暂无评论