【问题标题】:How to get the location geotag from an Instagram post using the API如何使用 API 从 Instagram 帖子中获取位置地理标签
【发布时间】:2026-01-26 02:00:02
【问题描述】:

我正在尝试使用 Basic Display Instagram API 从已发布的 Instagram 帖子中获取位置地理标签?

我找不到任何可以让我获取位置的端点。是我遗漏了什么还是我们无法做到的?

【问题讨论】:

  • 我觉得这很奇怪,因为它是发布时如此常用的属性。

标签: python instagram-api


【解决方案1】:

此时出现location-id只能在通过API创建媒体时设置,而在检索媒体时不可用。

对 API 的 POST 调用 https://developers.facebook.com/docs/instagram-api/reference/ig-user/media#create-photo-container

进行 GET 调用时可用的字段 https://developers.facebook.com/docs/instagram-api/reference/ig-media#fields

【讨论】:

  • 好吧,我也得出了同样的结论。只是想确保我没有遗漏任何东西。
  • 是否有解决方法?
【解决方案2】:

这可以通过打开帖子,右键单击帖子顶部,勾选属性,然后位置来完成。您将获得一张带有十进制度的位置坐标的地图,您可以使用它在 Google 地图或其他地图服务上查明该地点。 API 也会计算这一点,但 API 仅供开发人员使用,因此普通 Instagram 用户无法访问它,除非您正在构建与之相关的应用。

【讨论】:

  • OP 询问如何通过 API 而非 UI 来执行此操作。
【解决方案3】:

您可以使用我使用的 data365.co Instagram API 获取它。

如果您有帖子 ID 或短代码,您可以构建一个任务以通过 POST 请求下载它: https://api.data365.co/v1.1/instagram/post/CYjV-nusXA8/update?access_token=TOKEN

此 GET 请求会返回有关发布的信息: https://api.data365.co/v1.1/instagram/post/CYjV-nusXA8?access_token=TOKEN

您会收到这样的字段列表,包括 location_id:

{
    "data": {
    

"attached_media_content": null,
    "attached_media_display_url": "https://instagram.fclj4-1.fna.fbcdn.net/v/t51.2885-15/e35/s1080x1080/271671353_2486006594877541_7824177366520402526_n.jpg?_nc_ht=instagram.fclj4-1.fna.fbcdn.net&_nc_cat=101&_nc_ohc=6N-Dwpx8IvEAX9Zjcvp&edm=AABBvjUBAAAA&ccb=7-4&oh=00_AT88wqJiMtaSe4Ma8xtcixRCdaIozxnXKK_6k1W-84k3ZQ&oe=61E6FF84&_nc_sid=83d603",
    "attached_media_tagged_users": [
        "dilettazamba.iti",
        "laura_medeghini"
    ],
    "attached_video_url": null,
    "comments_count": 8,
    "created_time": "2022-01-10T14:04:24",
    "id": "2748136859869737020",
    "is_comments_disabled": false,
    "is_video": false,
    "likes_count": 257,
    "location_id": "447269731",
    "owner_id": "182171607",
    "related_posts": null,
    "shortcode": "CYjV-nusXA8",
    "sponsors": [
        "dilettazamba.iti",
        "laura_medeghini"
    ],
    "text": "Pretending it was not all about grappa ?#italiansdoitbetter??",
    "text_lang": "en",
    "text_tagged_users": null,
    "text_tags": [
        "italiansdoitbetter"
    ],
    "timestamp": 1641823464,
    "video_plays_count": null,
    "video_views_count": null
    },
    "error": null,
    "status": "ok"
}

如果您需要获取更多的位置数据,可以创建一个任务来下载位置信息。

创建任务示例,POST 请求:

https://api.data365.co/v1.1/instagram/location/447269731/update?access_token=TOKEN

获取数据示例,GET请求:

https://api.data365.co/v1.1/instagram/location/447269731?access_token=TOKEN

来自 GET 请求的位置数据示例:

{
    "data": {
        "address": null,
        "city": null,
        "country_code": "IT",
        "description": null,
        "external_url": "http://www.regione.lombardia.it/",
        "has_public_page": false,
        "id": "447269731",
        "is_exact_city_match": null,
        "is_exact_country_match": null,
        "is_exact_region_match": true,
        "latitude": 45.65,
        "longitude": 9.95,
        "name": "Lombardy",
        "phone": null,
        "posts_count": 752322,
        "primary_alias_on_fb": "234765516537015",
        "region": "Lombardia",
        "slug": "lombardy",
        "thumb_url": "https://instagram.fhel6-1.fna.fbcdn.net/v/t51.2885-15/e35/s150x150/133538449_422161569029342_6176236793032572073_n.jpg?_nc_ht=instagram.fhel6-1.fna.fbcdn.net&_nc_cat=102&_nc_ohc=TKr1bwmeTxsAX8c_2AW&tp=1&oh=6d7d9df9654741083884c5880496fc5a&oe=60269982",
        "zip_code": null
    },
    "error": null,
    "status": "ok"
}

您可以在https://data365.co/instagram 上查看有关我们的 API 功能及其提供的数据的更多信息。

【讨论】: