{"id":19063252,"url":"https://github.com/delner/butterfli-instagram","last_synced_at":"2025-10-09T04:37:23.245Z","repository":{"id":36478092,"uuid":"40783649","full_name":"delner/butterfli-instagram","owner":"delner","description":"Adds Instagram data and configuration to Butterfli.","archived":false,"fork":false,"pushed_at":"2016-05-21T18:38:43.000Z","size":47,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-06-05T14:41:12.544Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Ruby","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/delner.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.txt","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2015-08-15T20:36:08.000Z","updated_at":"2016-05-21T18:38:44.000Z","dependencies_parsed_at":"2022-09-09T10:10:57.006Z","dependency_job_id":null,"html_url":"https://github.com/delner/butterfli-instagram","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/delner/butterfli-instagram","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/delner%2Fbutterfli-instagram","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/delner%2Fbutterfli-instagram/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/delner%2Fbutterfli-instagram/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/delner%2Fbutterfli-instagram/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/delner","download_url":"https://codeload.github.com/delner/butterfli-instagram/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/delner%2Fbutterfli-instagram/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":279000705,"owners_count":26082921,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-10-09T02:00:07.460Z","response_time":59,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-11-09T00:29:24.269Z","updated_at":"2025-10-09T04:37:23.230Z","avatar_url":"https://github.com/delner.png","language":"Ruby","funding_links":[],"categories":[],"sub_categories":[],"readme":"![Butterfli](http://cdn.delner.com/www/images/projects/butterfli/logo_small.svg)\nInstagram\n==========\n\n[![Build Status](https://travis-ci.org/delner/butterfli-instagram.svg?branch=master)](https://travis-ci.org/delner/butterfli-instagram) ![Gem Version](https://img.shields.io/gem/v/butterfli-instagram.svg?maxAge=2592000)\n###### *For Ruby 1.9.3, 2.0.0, 2.1.0*\n\n### Introduction\n\n`butterfli-instagram` is a gem that extends the [Butterfli](https://github.com/delner/butterfli) framework for use with Instagram. It adds data libraries and configuration that enables Butterfli to handle Instagram data.\n\nTo gain access to Instagram's subscription APIs, check out [`butterfli-instagram-rails`](https://github.com/delner/butterfli-instagram-rails), which implements the Instagram API via Rails engine, and enables a Rails application to receive real-time Instagram data.\n\nThis gem is a part of the *Butterfli* suite:\n\n**Core gems**:\n - [`butterfli`](https://github.com/delner/butterfli): Core gem for Butterfli suite.\n - [`butterfli-rails`](https://github.com/delner/butterfli-rails): Core gem for Rails-engine based API interactions.\n\n**Extension gems**:\n - [`butterfli-instagram`](https://github.com/delner/butterfli-instagram): Adds Instagram data to the Butterfli suite.\n - [`butterfli-instagram-rails`](https://github.com/delner/butterfli-instagram-rails): Adds Rails API endpoints for realtime-subscriptions.\n\n### Installation\n\nInstall the gem via `gem install butterfli-instagram`\n\nThen configure Butterfli with your Instagram settings. (In Rails applications, you can put this in an initializer.)\n\n```ruby\nButterfli.configure do |config|\n  config.provider :instagram do |provider|\n    provider.client_id = \"Your client ID\"\n    provider.client_secret = \"Your client secret\"\n  end\nend\n```\n\n### Usage\n\n##### Retrieving stories using jobs\n\nTo retrieve data from the Instagram API, create a job, and set it to work:\n\n```ruby\njob = Butterfli::Instagram::Jobs::GeographyRecentMedia.new(obj_id: id)\nstories = job.work\nstories # =\u003e [#\u003cButterfli::Data::Story\u003e, ...]\n```\n\nAvailable jobs are:\n\n - `Butterfli::Instagram::Jobs::GeographyRecentMedia`\n - `Butterfli::Instagram::Jobs::LocationRecentMedia`\n - `Butterfli::Instagram::Jobs::TagRecentMedia`\n\nYou can also execute these jobs asynchronously, if you have configured a Butterfli processor. (See [`butterfli`](https://github.com/delner/butterfli) documentation for more details.)\n\n```ruby\nButterfli.processor.enqueue(job)\n```\n\n##### Retrieving stories manually\n\nYou can also read data directly via Instagram API client and convert them to stories manually.\n\nTo access the Instagram API client:\n```ruby\nclient = Butterfli.configuration.providers(:instagram).client\n# =\u003e #\u003cInstagram::Client\u003e\n```\n\nTo convert an Instagram `MediaObject` to a `Butterfli::Data::Story`:\n```ruby\nmedia_object = client.geography_recent_media(12345678).first\n# =\u003e {  \"tags\":[\"brunch\",\"waffletime\"],\n#       \"created_time\":\"1435437184\",\n#       \"link\":\"https:\\/\\/instagram.com\\/p\\/ABCDEFGH\\/\",\n#       \"images\": { ... }}\nstory = Butterfli::Instagram::Data::MediaObject.new(media_object).transform\n# =\u003e #\u003cButterfli::Data::Story\u003e\n```\n\n##### Throttling API requests\n\nThe Instagram API has a default limit of 5000 requests / hour (sliding window.) You can define a *policy* to throttle jobs so they don't exceed this threshold.\n\nTo do so, add the following to the Butterfli configuration:\n\n```ruby\nButterfli.configure do |config|\n  config.provider :instagram do |provider|\n    provider.policy :jobs do |jobs|\n      # Throttles TagRecentMedia jobs. (Can also be :geography or :location)\n      jobs.throttle :tag do |t|\n        # Only match against jobs who have these arguments\n        # :obj_id is the Instagram ID of the object you're querying against\n        t.matching obj_id: 'nofilter'\n        t.limit 400\n        t.per_seconds 3600\n      end\n    end\n  end\nend\n```\n\nThen you can check a job against the policy to see whether it's permitted:\n\n```ruby\n# For an example job...\njob = Butterfli::Instagram::Jobs::TagRecentMedia.new(obj_id: 'nofilter')\n# Check if it's permitted under the policy\n# It reads the Butterfli.cache for a 'last time queued' to see if it should run\nif Butterfli::Instagram::Regulation.policies(:jobs).permits?(job) \n  job.work\n  # Be sure to update that 'last time queued' if you do work, though.\n  # Otherwise it will ignore rate limitations\n  Butterfli::Instagram::Data::Cache.for.subscription(:tag, id).field(:last_time_queued).write(Time.now)\nend\n```\n\n### Changelog\n\n#### Version 0.0.1\n\n - Initial version of butterfli-instagram (extraction from `butterfli` prototype)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdelner%2Fbutterfli-instagram","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdelner%2Fbutterfli-instagram","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdelner%2Fbutterfli-instagram/lists"}