Skip to content

labteral/pygram

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

21 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Pygram Logo

Downloads PyPi License

Unofficial Python client for Instagram

Buy Me A Coffee

Installation

pip install pygram

Methods without mandatory login

Get user's profile

from pygram import PyGram
pygram = PyGram()

profile = pygram.get_profile('eminem')

Get user's ID

from pygram import PyGram
pygram = PyGram()

user_id = pygram.get_user_id('eminem')

Get user's posts

from pygram import PyGram
pygram = PyGram()

posts = pygram.get_posts('eminem', limit=10)
for post in posts:
    print(post)

Get post's comments

from pygram import PyGram
pygram = PyGram()

comments = pygram.get_comments(post, limit=10)
for comment in comments:
    print(comment)

Methods with mandatory login

Login

from pygram import PyGram

pygram = PyGram('user', 'password')

After the first login, a file with the name pygram-cache.json will be created in the current directory to avoid logging in again with every instantiation.

Get user's followers

from pygram import PyGram
pygram = PyGram('user', 'password')

users = pygram.get_followers('eminem', limit=10)
for user in users:
    print(user)

Get users followed by a user

from pygram import PyGram
pygram = PyGram('user', 'password')

users = pygram.get_followed('drdre', limit=10)
for user in users:
    print(user)

Like a post / comment

from pygram import PyGram
pygram = PyGram('user', 'password')

last_post = next(pygram.get_posts('eminem', limit=1))
pygram.like(last_post)

Unlike a post / comment

from pygram import PyGram
pygram = PyGram('user', 'password')

last_post = next(pygram.get_posts('eminem', limit=1))
pygram.unlike(last_post)

Comment a post / comment

from pygram import PyGram
pygram = PyGram('user', 'password')

pygram.comment(post, 'this is the comment')

Delete a comment

from pygram import PyGram
pygram = PyGram('user', 'password')

pygram.delete(comment)