13

enter image description here

About

Stack.JS is the JavaScript equivalent of Stack.PHP and aims to replicate the request structure of that library as much as possible. The library is still a long ways from being complete but is functional at this point. As was the case with Stack.PHP, Stack.JS is 100% fully documented and comes with a test suite to make sure the library functions as documented.

Request throttling was just added and there are plans to implement a cache.

Code Snippet

var site = API.Site('stackapps');

var response = site.Questions([1, 2, 3]).SortBy('creation_date').Exec();

response.Fetch(function(data) {

    for(var i=0; i<data['items'].length; ++i)
        console.log(data['items'][i]['title']);

});

License

Stack.JS (like Stack.PHP) is released under the MIT license.

Download

You will need to check out the code from the repository (see below) until an official release is made.

Platform

Stack.JS will run on all major browsers (IE, Firefox, Chrome, Opera, and Safari). Currently, I am running the tests in Chrome.

Contact

I can be reached at [email protected].

Code

The code is located at http://launchpad.net/stackjs. You can check it out using Bazaar by running these commands in an empty directory:

bzr init
bzr pull lp:stackjs
11
  • I'm wondering how I would implement using this library code to get all the three-letter tags on a site. Commented Jan 24, 2012 at 16:54
  • 2
    @hippietrail: Here is an example using the latest code in trunk: paste.ubuntu.com/815630 Commented Jan 24, 2012 at 18:45
  • Is there a URL where we can "include" the latest version in a script tag, like jQuery has? And the same for a minified version? Commented Jan 24, 2012 at 18:52
  • 2
    @hippietrail: not yet, though that is planned. In the meantime, feel free to use this: files.quickmediasolutions.com/temp/stack.min.js Keep in mind that the library is still in its early stages. Commented Jan 24, 2012 at 18:58
  • I just tried running it in jsfiddle and after some time I got my first ever API error! {"error_id":502, "error_name":"throttle_violation", "error_message":"too many requests from this IP"} Commented Jan 24, 2012 at 19:17
  • @hippietrail: Hmm... sounds like the request throttling needs some more work. Edit: okay, I've made some adjustments. Please try it again. Commented Jan 24, 2012 at 19:56
  • Had to wait for my ban to expire. Same problem still though! It seems you're not setting a page size, which could be up to 100. Commented Jan 25, 2012 at 19:45
  • 1
    @hippietrail: That's very strange. I will look into this and let you know when this gets resolved. Commented Jan 25, 2012 at 20:43
  • OK that problem seems to be solved. But now I can't figure out how to get the list of all 3-letter tag synonyms. The obvious way of just chaning Tags in the code to Synonyms didn't work and I couldn't find much useful documentation other than the source code. Commented Sep 7, 2012 at 11:40
  • 2
    Does this library (still) work? Can anyone provide a jsfiddle or some examples? Commented Feb 10, 2016 at 13:59
  • @foo I don't think it does. It was never updated for the latest version of the API. Commented Feb 10, 2016 at 16:17

0

You must log in to answer this question.

Browse other questions tagged .