CORS or Cross Origin Resource Sharing

The Bitly API supports CORS, or Cross Origin Resource Sharing.

Historically, Javascript AJAX requests were restricted to a same domain origin policy. This meant that your website at could not make AJAX requests to, since they were not the same domain.

With the introduction of HTML5 and advancements in modern browsers, CORS allows website owners to control who can access data via Javascript AJAX requests. In this way, CORS functions like Flash's Cross Domain Origin Policy. The latest version of the Bitly API (V3) supports CORS requests from any domain.

Here is some basic example Javascript to get you started:

var xhr = new XMLHttpRequest();"GET", "");
xhr.onreadystatechange = function() { 
    if(xhr.readyState == 4) { 
        if(xhr.status==200) {
            console.log("CORS works!", xhr.responseText);         
        } else {
            console.log("Oops", xhr);

You can also read more about CORS here.