1
votes

I'm currently using the Instagram API to like photos and follow users. I'm passing in the access token to make the requests, but for some reason I keep getting client request limit reached. I'm not sure why since the requests are being sent with an access token saved when users authenticate with my app.

here's the gem I'm using to connect to the API in my Rails app: https://github.com/Instagram/instagram-ruby-gem

def self.follow_users(token, tags, user_id)
  tags.each do |hashtag|
    Instagram.tag_recent_media(hashtag.content).data.each do |data|
      Instagram.follow_user(data.user.id, :access_token => token)
    end
  end
end
1

1 Answers

0
votes

Are you passing the user's access token? Or are you passing your own (or your app's) access_token?

If you're passing your own, the reason you're seeing the rate limit error is because Instagram limits Follows to 60/h and Likes to 150/h. You can check the number remaining by inspecting the return HTTP header, and looking for x-ratelimit-remaining.

Sample response:

{
    "error_type": "APIError",
    "code": 400,
    "error_message": "Client request limit reached",
    "x-ratelimit-limit": "150",
    "x-ratelimit-remaining": "3"
}