Upload Multiple Images ====================== This tutorial explains how to upload more than one image within a single request. .. include:: includes/requirements.rst Procedure --------- .. include:: includes/initialize-variables.rst 2. Read image files to upload ***************************** This code snippet reads the image files and prepares them to be in the type that is expected for the requests library. .. code:: python image_filenames = [ 'image1.png', 'image2.png', 'image3.png', ] image_files = [] for image_filename in image_filenames: image_files.append( ('file', (image_filename, open('/tmp/{}'.format(image_filename), 'rb'), 'image/png')) ) 3. Perform upload request ************************* Finally, perform an upload request and print its ID and URL. .. code:: python response = requests.post( 'https://{}/api/1.3/images'.format(API_DOMAIN), params={'api_key': API_KEY}, files=image_files ) response.raise_for_status() image_api_response = response.json() for image_info in image_api_response: print(image_info['id'], image_info['thumbnails']['origin'])