How to use imgbb API for for command line image hosting

Here’s a little, easy tutorial I’ve written for those API lovers for using imgbb API for command line photo hosting.

My requirements were that the script had to work on both Linux and macOS and not require any third-party modules because I didn’t want to have to keep them updated on different operating systems. There are some nice Python scripts but they require the requests module (which is great, but is third-party). Likewise while the right thing to do is parse the JSON response with something like jq, that’s a third-party dependency, so I’ll just munge it with a regex.

Domain Name Registration Web Hosting

Here’s code showing how easy it is.

First, create an account on and then login with it. Then visit and click “Get API Key”.

Here’s the script I’m using, which is modified from the example on their site:


# change this to your actual API KEY
RESPONSE=$(curl -s --location \
--request POST "${API_KEY}" \
--form "image=@$1")
URL=$(echo $RESPONSE | sed 's/^.*"display_url":"//' | sed 's/",.*$//')
URL=$(echo $URL | sed 's#\\/#/#g')
echo $URL

Here’s the output:

$ ~/Dropbox/bin/ ~/Desktop/leb_logo.png

That URL is now suitable for use on any forum.