There used to be a way if you use an access token and request key from one of the Stack Exchange mobile app to upload the image. It does not work anymore now that the mobile apps have been discontinued; one of my scripts now simply tries to mimic browser requests (logging in, and using the image uploader).
You'll need to make a POST call to https://mobile.stackexchange.com/1/image/upload and supply the following parameters (as application/x-www-form-urlencoded
):
access_token
key
(the iOS app uses kJ1geZUa*oJVMN229qwESg((
, the Android app r0aEx)wmOcRhhPMdffXeUQ((
)
image_mime_type
: image/png
, image/jpeg
or image/gif
(other image types are not supported)
image_name
: just a random string, doesn't really matter
filter
: vqc7J
(I have no idea which fields these correspond to, since this call is not documented)
image_data
: the image data, encoded as Base64
If the upload succeeds, you'll get the URL back (the response is in the usual API style, a root object with an items
array; there'll be a single item with a url
property).
You can then use this URL in the Markdown you supply to the create question API method. Of course, it might be easier using another image hosting server, but keeping it on Stack Exchange's imgur channel is commendable.