views:

18

answers:

1

Given the following API call in Curl, how would I do this in JQuery?

curl -u #{api_key}:x -X GET https://#{your_account}.batchbook.com/service/people.xml

+1  A: 

You don't want to do that with jQuery, because it'll expose your API key to your users.

If you really really really decided to use a jQuery AJAX call, though (maybe some sort of internal system where everyone with access would have access to the key), here's the code:

$.ajax({
  url: 'https://your-account.batchbook.com/service/people.xml',
  username: 'your api key',
  password: 'your password'
});
ceejayoz
So in other words I need to set up a rest api for a rest api in order to use jquery to access the origin api?
Chris G.
Unless you want your users having access to your API key, yes, you'll need your server to do the accessing the API and then passing along the results to the user.
ceejayoz