Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Instagram API media/search/ endpoint return results outside the time range

Tags:

instagram

I'm currently using Instagram API media/search endpoint using this following sample configuration:

curl -XGET 'https://api.instagram.com/v1/media/search?
lat=1.3058866783157643&lng=103.88191223144531&distance=5000&
min_timestamp=1394615197&max_timestamp=1394615227&
access_token=xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx'

The highlights of this command are:

  1. min_timestamp = 1394615197
  2. max_timestamp = 1394615227

The results that I obtained has these following created_time field: (I don't put the raw result because it will consume lots of space. I use jq (http://stedolan.github.io/jq/) to extract the created_time field).

  1. "1394615279" *outside timestamp parameters
  2. "1394615277" *
  3. "1394615270" *
  4. "1394615268" *
  5. "1394615251" *
  6. "1394615248" *
  7. "1394615246" *
  8. "1394615243" *
  9. "1394615241" *
  10. "1394615239" *
  11. "1394615232" *
  12. "1394615217"
  13. "1394615214"
  14. "1394615204" *
  15. "1394615204" *
  16. "1394615187" *
  17. "1394615180" *
  18. "1394615180" *
  19. "1394615179" *
  20. "1394615178" *

As you can see there are results (I put an asterisk behind) that created outside the timestamp parameters that I use. So, is this the expected behavior of the media search API? Or is it because something wrong with my timestamp parameter (range too close maybe, note that the difference between max and min timestamp is only 30 seconds).

like image 501
arinto Avatar asked Nov 01 '22 03:11

arinto


1 Answers

I believe that Instagram rounds time constraints to the nearest minute. Rounding down for min and up for max. So the time ranges in your query spans two minutes. So, your query window is actually 120 seconds. You'll have to filter out the extras yourself.

Keep in mind that the media search is going to return a maximum of 20 results. So you may want to split that query up in to two separate queries for each of the 60 second windows it spans. I don't think media search results use pagination to display additional results. So you don't really know how much data you're losing.

like image 90
David LaPorte Avatar answered Nov 08 '22 05:11

David LaPorte