logeyg
logeyg

Reputation: 559

Python Instagram API - get media by shortcode

I'm attempting to use this api call listed here (I want to get a media object from the instagram url shortcode):

https://instagram.com/developer/endpoints/media/?hl=en#get_media_by_shortcode

I've tried using calls like this (id is the shortcode)

media = instagram_api.media(shortcode=id)
# or
media = instagram_api.media.shortcode(id)

I keep getting errors that either say no parameter found for media id or function has no attribute 'shortcode'

Upvotes: 0

Views: 1754

Answers (1)

carpenter
carpenter

Reputation: 1210

The way to call it with the Python API as seen in this unit test is:

media = instagram_api.media_shortcode(id)

The second way won't work because media is a function and shortcode isn't a member of the media function. The first doesn't work because the media function has no parameter named shortcode. The correct function is media_shortcode(id).

Upvotes: 1

Related Questions