Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Instagram API /tags/{tag-name}/media/recent changed behaviour

I worked several times with this endpoint and it seems that since this week when I pass a max_id value an error is thrown, it says:

{
    "meta":  {
        "error_type": "APIInvalidParametersError",
        "code": 400,
        "error_message": "max_id must not be a media id."
    }
}

I have no idea where to find if api has changed behaviour or simply it's broken.
Guys, do you have any idea?

Another error that I've found is the order of returned Medias when I query this endpoint. Here's a sample data:

#sample error
[
    Media: 1220853576116214570_1383882821
    Media: 1220853572180739674_233961632
    Media: 1220853571106323542_44255974
    Media: 1220853327487332588_16383867
    Media: 1220853529276039536_37204591
    Media: 1220853517236612185_1342227858
    Media: 1220853478513480317_596571
    Media: 1220853329006327307_299159508
    Media: 1220853296836482014_1829274963
    Media: 1220853282356978078_1498664215
    Media: 1220853191933038656_528166155
    Media: 1220481246711237359_211289081  #MEDIA INCORRECT ORDER
    Media: 1220853144521663282_3026017167
    Media: 1220853127735637950_619046756
    Media: 1220853103550902683_2074401387
    Media: 1220853106444172011_3020165605
    Media: 1220449359646948005_208916789  #MEDIA INCORRECT ORDER
    Media: 1220853071011680880_596571
    Media: 1220852985861033044_446238634
    Media: 1220852995848611111_3098675456
    Media: 1220852944343050919_1126655937
    Media: 1220852926209616200_327453609
    Media: 1220852902671104371_351483533
    Media: 1220852898165133786_207127275
    Media: 1220852887618705294_1736270372
    Media: 1220852850174855566_1133338201
    Media: 1220852831895483805_30557620
    Media: 1220851564341433250_1460935835
    Media: 1220852721064734213_14247170
    Media: 1220852681564341476_1329013696
    Media: 1220852647186623946_2143587522
    Media: 1220852634988856098_6331807
    Media: 1220852621030972511_530287550
]

Edit: I've just checked that python instagram's client has been deprecated 9 days ago, and there's a lot of stackoverflow questions about api behaviour's from 23-march. A lot of coincidences

  • Instagram /v1/tags/{tag-name}/media/recent endpoint doesn't return min_tag_id in pagination block
  • Error 400: Bad request while fetching json data from instagram api via coldfusion
  • API Tags endpoint error - min_id is not a valid cursor for this tag


  • Edit 2: count parameter can't be greater than 33, omitted otherwise. In another words, max records per page number is 33

    Edit 3: Python client's broken since 1st of June due another undocumented behaviour change
      File "/usr/local/lib/python2.7/dist-packages/instagram/bind.py", line 194, in _call
        return method.execute()
      File "/usr/local/lib/python2.7/dist-packages/instagram/bind.py", line 186, in execute
        content, next = self._do_api_request(url, method, body, headers)
      File "/usr/local/lib/python2.7/dist-packages/instagram/bind.py", line 148, in _do_api_request
        obj = self.root_class.object_from_dictionary(entry)
      File "/usr/local/lib/python2.7/dist-packages/instagram/models.py", line 88, in object_from_dictionary
        for comment in entry['comments']['data']:
    KeyError: 'data'
    


    Edit 3 solved here

    like image 349
    xecgr Avatar asked Apr 01 '16 10:04

    xecgr


    1 Answers

    It seems that you're passing a media id as pagination. You can't do that anymore since Instagram changed the pagination values. It used to be a media id, but now is a string.

    When you do the request, you'll receive an json like this:

    {
        pagination: {
            next_max_tag_id: ...,
            deprecation_warning: "next_max_id and min_id are deprecated for this endpoint; use min_tag_id and max_tag_id instead",
            next_max_id: ...,
            next_min_id: ...,
            min_tag_id: ...
            ...
        },
        meta: {
            ...
        },
        data: {
            ...
        }
    }
    

    Just use the next_max_id value as max_tag_id in your request. That should works.

    like image 82
    Daniel Trolezi Avatar answered Oct 19 '22 01:10

    Daniel Trolezi