Use steem python to post a image

Words
100
Reading
1 min
Listen
Play
8y

The most important step to use a python API to post a image is to upload a image to a server and return the image URL.

Imgur API provide such a function:

To use the API, an account has to be registered first. After registration you will get client ID, which will need to be used in the following code.

To install the python API

pip install pyimgur

To upload a image:

import pyimgur
def upload_image():
    CLIENT_ID = "ID"
    PATH = 'Image path'
    im = pyimgur.Imgur(CLIENT_ID)
    uploaded_image = im.upload_image(PATH, title="image_title")
    print(uploaded_image.title)
    print(uploaded_image.link)
    print(uploaded_image.size)
    print(uploaded_image.type)
    return uploaded_image.link
Use steem python to post a image | Ecency