Skip to content
πŸ“· Instagrammer lets you fetch Instagram user info and posts
Ruby Shell
Branch: master
Clone or download
dependabot-preview and richardvenneman Update rake requirement from ~> 12.3 to ~> 13.0 (#6)
Updates the requirements on [rake]( to permit the latest version.
- [Release notes](
- [Changelog](
- [Commits](ruby/rake@v12.3.0...v13.0.0)

Signed-off-by: dependabot-preview[bot] <>
Latest commit de56811 Oct 12, 2019


Instagrammer lets you fetch Instagram user info and posts. This is done by crawling the Instagram web interface, powered by Capybara and a headless Chrome Selenium driver. Automated integration tests are run daily to keep up with possible changes. Read more about the motivation to build this gem.

Build Status Gem Version Maintainability Test Coverage


Add this line to your application's Gemfile:

gem 'instagrammer'

And then execute:

$ bundle

Or install it yourself as:

$ gem install instagrammer

If you're running on Heroku, make sure to use the heroku-buildpack-google-chrome buildpack.



Create a new user with"username") or simply"username").

Accessing certain properties on an account that is private will result in a PrivateAccount exception. In some cases Instagram doesn't expose any meta data through. In these cases a UserInvalid exception will be raised when accessing certain properties.

Therefor you can check if the account is scrapable with the #public? instance method.


The meta counts data is available for both public as well as private accounts:

user ="richardvenneman")
user.follower_count # => "204"
user.following_count # => "141"
user.post_count # => "91"


Bio info is currently available for public accounts only:

user ="richardvenneman") # => "Richard Venneman"
user.username # => "@richardvenneman"
user.avatar # => "" # => "πŸ‘¨πŸ»β€πŸ’» Partner at GoNomadic B.V.\nTraveling and building πŸ™ @cityspotters"
user.url # => ""


Get the posts for a specific user by using the #get_posts(_limit_) user method.

user ="richardvenneman")
user.get_posts(3) # => [#<Instagrammer::Post:70223732051200..>, #<Instagrammer::Post:70223732051200..>, #<Instagrammer::Post:70223732051200..>]

See below for the available post methods


Create a new post with"shortcode").

post ="Bg3VjfwDRDw") # => true
post.caption # => "πŸŒ‹ Mount Agung as seen from πŸŒ‹ Mount Batur just after sunrise πŸŒ…"
post.upload_date # => #<DateTime: 2018-03-28T11:07:26+00:00 ((2458206j,40046s,0n),+0s,2299161j)
post.comment_count # => 3
post.like_count # => 52
post.image_url # => ""
post.image_urls # => [{:url=>"", :width=>640}, {:url=>",", :width=>750}, {:url=>",", :width=>1080}]

Additionally video posts are somewhat supported as well. Image URLs and like counts are not available for videos.

post ="Byx0Nd3A3qr") # => true
post.watch_count # => 8035142


The problem with scrapers is that they always brake. Instagram/Facebook seems to put in a lot of effort to battle scrapers. This gem tries to approach that challenge a bit different than other Ruby Instagram scrapers. With decent test coverage the integration should be tested continuously and good code quality should allow for quick and easy updates may any changes in the Instagram web interface happen.

The main focus is currently retrieving user posts with some metadata while maintaining a stable implementation. Therefor I try to avoid naive page selectors and rely on meta data where possible.


Bug reports and pull requests are welcome on GitHub at

You can’t perform that action at this time.