[Python] Post a local video file as a REEL using Instagram API in Python

Discussão em 'Python' iniciado por Stack, Agosto 15, 2025.

  1. Stack

    Stack Membro Participativo

    I am able to post a video from a public URL as a REEL:

    import requests

    token = "..."
    api_version="v23.0"
    headers = {
    "Content-Type": "application/json",
    "Authorization": f"Bearer {token}"
    }


    # Get my user ID
    id_url = f"https://graph.instagram.com/{api_version}/me"
    id_response = requests.get(id_url, headers=headers)
    user_id = id_response.json()['id']

    # Upload a video on a public URL as a REEL
    url = f"https://graph.instagram.com/{api_version}/{user_id}/media"
    video_url = "https://download.samplelib.com/mp4/sample-5s.mp4"
    payload = {
    "video_url": video_path,
    "media_type": "REELS",
    }
    response = requests.post(
    url=url,
    headers=headers,
    data=payload
    )
    post_id = json.loads(out.content)['id']
    # wait until video has been uploaded ...
    publish_url = f"https://graph.instagram.com/{api_version}/{user_id}/media_publish"
    payload = {
    "creation_id": post_id
    }
    response = requests.post(publish_url, headers=headers, data=payload)
    reel_id = response.json()['id'])


    However, I cannot upload a local file. I've tried following the documentation but without any luck. I currenty have an App with Instagram Login.

    Continue reading...

Compartilhe esta Página