Anonymous file upload with Python

There are many file and image sharing web sites but we need one that allows upload via an API. provides an easy API for an anonymous file upload so lets use that. Images are hosted and displayed on the service so we can use it for file hosting too.

Below you can see an example of a CURL request to upload an image file, the API returns us the information we need to access the file upload.

$ curl -F file=@anonymous_activists.jpg
{"url": "", "id": "qZB1DXsM", "name": "anonymous_activists.jpg", "size": 114230, "mime_type": "image/jpeg"}

So now we can translate the CURL request into Python using the requests library.

import requests
r ='', files={'file': open('/Users/myself/anonymous_activists.jpg', 'rb')})
#{"url": "", "id": "qZB1DXsM", "name": "anonymous_activists.jpg", "size": 114230, "mime_type": "image/jpeg"}

We grab the url param from the response and we can see our image uploaded and hosted in all its glory.