Stack Apps is a question and answer site for apps, scripts, and development with the Stack Exchange API. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I want to write a program using PhoneGap. How can I use the Stack Exchange API in PhoneGap?

share|improve this question
up vote 2 down vote accepted

I haven't used PhoneGap yet, but they claim that you develop apps with plain old JS, CSS, and HTML.

If that's true, then use the API just like you would from a web page -- with simple AJAX calls.

Here's a working example (using jQuery):

var userID      = 1416412;
var pageNum     = 1;
var pageSize    = 100;
var siteParam   = 'stackoverflow';
var appKey      = 'Get your own key!';

$.ajax ( {
    type:       'GET',
    url:        '' + userID
                + '/answers?page=' + pageNum
                + '&pagesize=' + pageSize + '&order=desc&sort=votes'
                + '&site=' + siteParam
                + '&filter=!3u0zcO(lpHVEGuskA&key=' + appKey,
    dataType:   'JSON',
    cache:      true,
    success:    function (apiJson) {
                    //-- Provide a closure.
                    console.log (apiJson);
} );

Get a key, it greatly increases your quota and is needed if you want one of the methods that needs authentication.

Reference the API docs and the API “Hello World” code.

share|improve this answer
I dont think "cache: true" is appropriate because its very much possible that the answer might have been edited. – Bhavik Shah Sep 19 '13 at 11:02
@BhavikShah, this cache has nothing to do with that and will not miss updates. It's just about not refetching the exact same data unnecessarily. – Brock Adams Oct 25 '13 at 20:13

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .