##Soapi.JS2


    var ctx = new Soapi.ApiContext(apiKey);
    ctx.initialize(function() {  
    
        // get a page of users
        ctx.official.stackApps.Users().invoke(function(users) {
            users.ForEach(function(user) {
                // get a page of each user's questions w/answers
                user.Questions().withAnswers(true).invoke(function(questions) {
                    // for each of the user's questions
                    questions.ForEach(function(question) {
                        // enumerate it's answers, if any
                        question.answers.ForEach(function(answer) {
                            // and get a page of the answer's owner's favorites
                            answer.owner.Favorites().invoke(function(favorites) {
                                favorites.ForEach(function(favorite) {
                                    // shall I go on? ;-)
                                });
                            });
                        });
                    });
                });
            });
        });
    });



##About

Soapi.JS2 is being released separately from [Soapi.JS][1] as it is a completely different take on accessing the API via JavaScript.

[Soapi.JS][2] is a very lightweight library that provides full API coverage. 

Soapi.JS2 takes it to 11 with a complete paradigm shift. It is a bit heavier and revolves around a fluent, relational query approach similar to that of the [Soapi.CS][3] library, providing a seamless view on the data served by the API.

###License

MIT-X11/GPL

###Download

***Beta*** version available at [http://soapi.info/Downloads/Soapi.JS2-beta-08-25-2010.zip][4]

ChangeLog:

Soapi.JS2-beta-08-25-2010

- completed preliminary documentation (/docs/index.htm)
- adjusted default throttle to 30 per 6.5 as per current api tolerance


Soapi.JS2-beta-08-19-2010

- merged scripts
- made throttle/cache optional 
- added RepReport sample


Soapi.JS2-alpha-08-21-2010

- implemented [ThrotteCache][5]


Soapi.JS2-alpha-08-20-2010

- implemented paging fully
- implemented .total method


Soapi.JS2-alpha-08-19-2010

- initial release



###Platform

JavaScript - Any browser that doesn't burn oil.

##Contact

code poet

##Code

Included in the alpha zip is a full coverage test suite and a rather detailed walkthrough. 


###QuickStart

- [ApiContext][6] - the root of all queries <-- **start here**
- [Api Coverage][7] - how Soapi.JS2 maps to the API
- [Relational Queries][8] - how to treat the API like a database
- [Async usage pattern][9] - how to call and what to expect
- [Parameterization And Paging][10] - how to get exactly what you want from the API
- [Stubs][11] - filling placeholder objects
- [Throttling and Caching][12] - concentrate on features, not plumbing..

###Sample Code

- [Basic Usage Example 01][13] - demonstrates how to retrieve related data from the api using Soapi.JS
- [RepReport][14] - an example of using Soapi.JS2 to provide a custom view on your reputation data.
- [SiteMonitor][15] - an example of using Soapi.JS2 to retrieve and display status and statistics for all of the sites in the Stack Exchange network.

###Reference

- [Linq.js][16] - Soapi.JS will detect if linq.js is loaded and if found will return all results that would normally be JavaScript `Array` as an instance of `Enumerable`. Most sample code that I provide will utilize this functionality. 
   This is highly recommended reading for anyone building non-trivial JavaScript applications.

--- 

##PLEASE NOTE:
I try to provide quality documentation and I do appreciate the approval indicated by upvotes, but the Stack Overflow anti-vote fraud system is silently reversing votes cast in rapid succession. 

So, if you would like to upvote the documentation, please do so in moderation, perhaps no more 3 or 4 votes per day?  

--- 


  [1]: http://stackapps.com/questions/494/soapi-js-v1-0-fluent-javascript-wrapper-for-the-stackoverflow-api
  [2]: http://stackapps.com/questions/494/soapi-js-v1-0-fluent-javascript-wrapper-for-the-stackoverflow-api
  [3]: http://stackapps.com/questions/386/soapi-cs-a-fully-relational-fluent-net-stack-exchange-api-client-library
  [4]: http://soapi.info/Downloads/Soapi.JS2-beta-08-25-2010.zip
  [5]: #1448
  [6]: #1441
  [7]: #1436
  [8]: #1437
  [9]: #1435
  [10]: #1440
  [11]: #1438
  [12]: #1448
  [13]: #1434
  [14]: #1459
  [15]: #1460
  [16]: http://linqjs.codeplex.com/