SharePoint Stack Exchange is a question and answer site for SharePoint enthusiasts. Join them; it only takes a minute:

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

How do I get the names of all libraries within a given site using jquery/javascript?

the only way i know of is using getByTitle('listtitle'), but I would like all names of libraries (hopefully there is a way to do libraries only and not just all lists) in a site?

Thanks as always!

share|improve this question
up vote 3 down vote accepted

I'm not sure if you can query for only libraries tbh, an option is too look at the SP.BaseType. Something like this:

ExecuteOrDelayUntilScriptLoaded(Initialize, "sp.js");
function Initialize()
    var clientContext = new SP.ClientContext.get_current();
    var web = clientContext.get_web();
    this.lists = web.get_lists();

    clientContext.executeQueryAsync(Function.createDelegate(this, this.onListItemsLoadSuccess), Function.createDelegate(this, this.onQueryFailed));

function onListItemsLoadSuccess(sender, args) {

    var count = this.lists.get_count();

    for (x = 0; x < count; x++)
        if(this.lists.itemAt(x).get_baseType() === 1) {
            var listTitle = this.lists.itemAt(x).get_title();

function onQueryFailed(sender, args) {
    alert('request failed ' + args.get_message() + '\n' + args.get_stackTrace());
share|improve this answer
thanks Anders.....i think baseType === '101' will get me libraries! thanks for the direction. – Justin Jun 8 '13 at 13:24

The SiteData web service will return all that data for you. The link is for SP 2007, but it still exists in 2010 and functions the same.


I'm not entirely sure where that would fit in within the client object model, but it would be easily accessed with a more familiar tool to me, SPServices.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.