5

Code Snippet


Demonstrates the StackUser class:

// Global object
var ss = new StackScript('');

function GetInfo()
{
    // The provided callback will be called
    // when the data arrives

    var user = ss.GetUser(document.getElementById('userid').value);

    user.InitUser(function() {
        $('#info_box').html("<b>User:</b> " + user.GetDisplayName());
    });
}

User ID: <input type='text' id='userid' /> 
<button onclick='GetInfo();'>Get User Info</button>
<div id='info_box'></div>

About

StackScript is a JavaScript wrapper that provides access to the StackOverflow API. Currently it has somewhat limited functionality, but I wanted to get something started that everyone can contribute to. There is enough code to make a simple demo, as you can see below. This wrapper even features a built-in caching class that works transparently under the hood.

License

GPL v3

Download

You can view a live demo here.

Platform

Any modern JavaScript-enabled browser.

Contact

I can be contacted at [email protected]

Code

Please head on over to http://launchpad.net/stackscript and join the project. You can find the code there.

If you want to help, I would love to add you to the project. Contact me and provide your LaunchPad ID and I will add you to the project.

7
  • 1
    @S.M: Yes, it is using jsonp. Are you interested in contributing to it? Commented May 31, 2010 at 6:40
  • @George, Thanks for the offer, but I've already start doing with python to build a site based on api, so lets see if I could manage to finished that first. btw, Its really great that you can manage to do lots of stuff at the same time!
    – YOU
    Commented May 31, 2010 at 10:31
  • Well, it helps that most of it is nearly complete. Pretty much everything else I'm working on is 70 - 90% complete. Commented May 31, 2010 at 16:53
  • @George: I have started a project which uses your wrapper ... it appears that the site name is hard coded, but can easily be passed in as a parameter. Do you have plans to change this to be configurable? Commented Jun 11, 2010 at 0:46
  • @Nippy: Although it looks like it's hardcoded in, it's not really. When you create a new StackScript object, you can pass a parameter that specifies the site. The reason it looks hardcoded is because it defaults to StackOverflow when no site is specified. Commented Jun 14, 2010 at 17:37
  • 1
    @George: well its obvious who is the JavaScript newb :) Commented Jun 14, 2010 at 23:11
  • @Nippy: No problem! The wrapper has very little functionality at this point. Just let me know what features you need and I'll prioritize them. Commented Jun 15, 2010 at 4:30

1 Answer 1

2

George,

I have written a code generator that parses the documentation into a complete API wrapper.

Not trying to step on any toes, but the logical next step is to leverage the parser and build emitters for other languages and JavaScript is my current target.

You are welcome to contribute/provide feedback. You can find more information here: SOAPI-JS

1
  • Awww... all our hard work... That will work good for everything but C++ - for which I highly recommend so++! Commented May 31, 2010 at 16:52

You must log in to answer this question.

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