Shell Script That Automates URL Submission to Bing

- 2 minutes read

Microsoft’s search engine, Bing, offers a free API for webmasters.

This API enables webmasters, such as myself, to submit our new URLs for indexing.

What’s really cool is that your fresh new pages can show up in search results within just ten minutes or so, sometimes even quicker.

While Bing allows you to manually submit URLs via their Webmaster Tools dashboard, I didn’t want to have to sign in each time.

So I made a simple shell script to automatically submit my URLs with cURL:


var() {
    VAR=$(grep $1 $2 | xargs)
    IFS="=" read -ra VAR <<< "$VAR"
    echo ${VAR[1]}




curl -X POST "$BING_API_KEY" -H "Content-Type: application/json" -H "charset: utf-8" -d '{"siteUrl":"'$site'", "urlList":["'$url'"]}'

Be sure to replace site with the base URL of your site, in double quotes!

Let’s save it to a file called

And in the same directory, let’s add a file called .env.

In the .env file, add the following line, replacing your Bing Webmaster API key with EXAMPLE:


Link to this section Usage

Then just run the following command from your terminal:

./ <url>

Here is an example (I’m going to run this as soon as I post this article!):


Lastly, as of writing this, a successful response will print this output:


Otherwise, cURL will display an error message.

Link to this section Conclusion

The full script is also available as a Gist on my GitHub account.

Enjoy your speedy display in search results!