• Stars
    star
    294
  • Rank 141,303 (Top 3 %)
  • Language
    Python
  • License
    MIT License
  • Created over 3 years ago
  • Updated over 1 year ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

RESTful API Wrapper for Instagram Private API

RESTful API Service

Allows you to use the Instagram Private API on any operating system from any programming language (C++, C#, F#, D, Golang, Erlang, Elixir, Nim, Haskell, Lisp, Closure, Julia, R, Java, Kotlin, Scala, OCaml, JavaScript, Crystal, Ruby, Rust, Swift, Objective-C, Visual Basic, .NET, Pascal, Perl, Lua, PHP and others) to automate the work of your accounts.

Support Chat in Telegram

Features

  1. Authorization: Login, support 2FA and manage settings
  2. Media: info, delete, edit, like, archive and much more else
  3. Video: download, upload to feed and story
  4. Photo: download, upload to feed and story
  5. IGTV: download, upload to feed and story
  6. Clip (Reels): download, upload to feed and story
  7. Album: download, upload to feed and story
  8. Story: info, delete, seen, download and much more else
  9. User: followers/following, info, follow/unfollow, remove_follower and much more else
  10. Insights: media, account

Installation

Install ImageMagick library:

sudo apt install imagemagick

...and comment the line with strict security policies of ImageMagick in /etc/ImageMagick-6/policy.xml:

<!--<policy domain="path" rights="none" pattern="@*"/>-->

Run docker container:

docker run subzeroid/instagrapi-rest

Or clone the repository:

git clone https://github.com/subzeroid/instagrapi-rest.git
cd instagrapi-rest

Build your image and run the container:

docker build -t instagrapi-rest .
docker run -p 8000:8000 instagrapi-rest

Or you can use docker-compose:

docker-compose up -d

Or manual installation and launch:

python3 -m venv .venv
. .venv/bin/activate
pip install -U wheel pip -Ur requirements.txt
uvicorn main:app --host 0.0.0.0 --port 8000 --reload

Usage

Open in browser http://localhost:8000/docs and follow the instructions

swagger

Get sessionid:

curl -X 'POST' \
  'http://localhost:8000/auth/login' \
  -H 'accept: application/json' \
  -H 'Content-Type: application/x-www-form-urlencoded' \
  -d 'username=<USERNAME>&password=<PASSWORD>&verification_code=<2FA CODE>'

Upload photo:

curl -X 'POST' \
  'http://localhost:8000/photo/upload_to_story' \
  -H 'accept: application/json' \
  -H 'Content-Type: multipart/form-data' \
  -F 'sessionid=<SESSIONID>' \
  -F '[email protected];type=image/jpeg'

Upload photo by URL:

curl -X 'POST' \
  'https://localhost:8000/photo/upload_to_story/by_url' \
  -H 'accept: application/json' \
  -H 'Content-Type: application/x-www-form-urlencoded' \
  -d 'sessionid=<SESSIONID>&url=https%3A%2F%2Fapi.telegram.org%2Ffile%2Ftest.jpg'

Upload video:

curl -X 'POST' \
  'http://localhost:8000/video/upload_to_story' \
  -H 'accept: application/json' \
  -H 'Content-Type: multipart/form-data' \
  -F 'sessionid=<SESSIONID>' \
  -F '[email protected];type=video/mp4'

Upload video by URL:

curl -X 'POST' \
  'https://localhost:8000/video/upload_to_story/by_url' \
  -H 'accept: application/json' \
  -H 'Content-Type: application/x-www-form-urlencoded' \
  -d 'sessionid=<SESSIONID>&url=https%3A%2F%2Fapi.telegram.org%2Ffile%2Ftest.MP4'

Generating client code

You can use this repo to generate client code for this rest api in any language you want to use.

Exapmle: openapi-generator-cli generate -g python -i https://localhost:8000]/openapi.json --skip-validate-spec Note skip-validate-spec is not necesserily required, when running it on my pc it couldn't validate the spec for some reason.

Testing

Tests can be run like this:

docker-compose run api pytest tests.py

One test:

docker-compose run api pytest tests.py::test_media_pk_from_code

or without docker-compose:

docker run --rm -v "$(pwd):/app" instagrapi-rest pytest tests.py

Development

For debugging:

docker-compose run --service-ports api

More Repositories

1

instagrapi

πŸ”₯ The fastest and powerful Python library for Instagram Private API 2023
Python
2,476
star
2

django-nginx-image

Resizing and cropping images via Nginx, as well as caching the result
Python
63
star
3

django-sql-stacktrace

Puts a python stacktrace in the SQL query as a comment (for debugging)
Python
31
star
4

marcus

Bilingual blog on Django
Python
28
star
5

django-multi-sessions

Multiple backends for your sessions!
Python
22
star
6

django-torrent-stream

Wraps the Torrent Stream http://torrentstream.org/
Python
17
star
7

zstdcat

Zstandard console reader
Python
9
star
8

django-social-auth-widget

Simple widget for django-social-auth
Python
9
star
9

django-sphinxsearch

A transparent layer for full-text search using Sphinx API and Django
Python
8
star
10

django-goto-url

Wraps external links in base64 and relocate on the special View, later redirect to source URL
Python
7
star
11

jquery-cleverfocus

Set the focus to the desired form element when text is entered without a focus
JavaScript
6
star
12

pre-code-review

Code Review (pep8, pyflakes) and Check Commit Message (check format of message) Git Hooks
Python
5
star
13

nagios-sentry

Plugin for Nagios, which check a count of messages in Sentry
Python
4
star
14

django-comments-plus

Extended django.contrib.comments, reviews, user registration via comment form, ajax submit and validation, subscription/unsubscribing (+web-interface)
Python
4
star
15

lettuce-py3

Python
3
star
16

smartencoding

Python smart encoding (smart_unicode and other functions)
Python
3
star
17

instagrapi-bot

Any useful improvements around instagrapi
Python
3
star
18

CryptoCurrency

Frontend for https://smappi.org/marketplace/adw0rd/cryptocurrency/
HTML
3
star
19

django-timeintervaller

A simple asynchronous task-scheduler for Django
Python
2
star
20

yandex-fotki

The plugin to display photos from photohosting "Yandeks.Fotki" to your blog on Wordpress
PHP
2
star
21

github-sync

Github Syncer. Checks and pulls all your GitHub repos
Python
2
star
22

salad-py3

Python
2
star
23

chatea

Simple Chat with Smappi Chatea API (https://smappi.org/api/adw0rd/chatea/)
HTML
1
star
24

solidity-create2-web3-example

An example for address prediction via create2
JavaScript
1
star