Calling webpagetest.org REST API from some other domain

Hi,

We are developing an internal tool which would give few other information apart from performance view of the webpage. For the performance part I would like to use some of the information provided by the webpagetest.org REST API. This is not a commercial tool.
And we already got the API key after sending a mail to You.

The problem comes when I am trying to call the API from some other domain.

My question here is : Is this API can be called from some other domain or Is it restricted from cross-domain calls because this has to be configured on the server itself?

For example : I want to call the API[webpagetest.org/runtest.php] from mydomain.org by making an AJAX call[along with the API key and some additional parameters] and expecting the webpagetest server to send me some xml as response which I will render in my customized UI. Is it possible?

Because when I am trying to do so, the call is getting cancelled in chrome and in firefox, it’s prompting that - Redirecting to another page- but nothing happens even though I press Yes.

I know about the private instance of webpagetest but that will not solve my problem as I just want the xml response to integrate this with my application.

Please help.

Thanks in advance

You can’t make cross-domain AJAX calls from within a browser page - period. You either need to send the calls to your server and then make the API calls from there or use JSONP for the cross-domain calls.

For JSONP to work you need to use the JSON version of the API (&f=json) and also pass a callback function. Then you add a script tag to your page (using javascript) with the src pointing to the runtest API with the json and callback. The specified callback will get called when the API call completes with the data passed as a parameter.