Jump to content

API Access to Collections


Go to solution Solved by Amything,

Recommended Posts

Posted

Still pretty much a newbie with the Emby API, I need some help on how to access collection info. ("Collection" being somewhat an overloaded term, what I mean here is the information you get from the web through My Media -> Collections, and I am looking to access the set of collections at a global level, i.e., not those visible to any particular user).

Basically what I want to  be able to do is get the  list of all the collections in the system and then for each collection, a list of all the items contained in that collection. There is nothing useful for this purpose in the Collections service, so I suspect what I want is accomplished through the ItemsLookupService and/or the Items service. But I'm not seeing it.  Can you help?

Thanks!

  • Solution
Amything
Posted

To get all collections

_libraryManager.GetItemIds(new InternalItemsQuery
{
    IncludeItemTypes = new[] { "collection", "Boxset" }
});

Items in collection

InternalItemsQuery query = new InternalItemsQuery
{
    CollectionIds = new[] { collectionId },
};
long[] items = _libraryManager.GetInternalItemIds(query);

 

Posted
6 hours ago, jhyler said:

Still pretty much a newbie with the Emby API, I need some help on how to access collection info. ("Collection" being somewhat an overloaded term, what I mean here is the information you get from the web through My Media -> Collections, and I am looking to access the set of collections at a global level, i.e., not those visible to any particular user).

Basically what I want to  be able to do is get the  list of all the collections in the system and then for each collection, a list of all the items contained in that collection. There is nothing useful for this purpose in the Collections service, so I suspect what I want is accomplished through the ItemsLookupService and/or the Items service. But I'm not seeing it.  Can you help?

Thanks!

Hi, what have you done so far with the api?

Posted (edited)

Not a whole lot, Luke, if you look back in my history you'll find two or three threads having to do with extracting info regarding missing episodes - this after the info stopped appearing in the database. Mostly I'm maintaining, and occasionally extending, a reporting system for my library that gives me details of what I hold, what quality I've got it in, what I am missing, where I might find missing or better quality material, etc. The system is most;y based off of SQL queries but as I revisit areas I may switch over to the API when it doesn't cause too much disruption.  Today's thread was due to my revisiting a part of the system that ensures the consistency of some collections (I have a folder where everything in it should be part of a particular collection and nothing else should be - turns out it's easier for me to provide the collection than it is to continually remind people that there is a folder view).

I puzzled over Amything's C++ for a while, but it led me to the RESTful API entry points I was hoping for. So thanks, Amything! I had gotten myself tripped up since the API was referring to collections as "box sets". My library makes heavy use of box sets (in the '[boxset]' naming convention sense) even though Emby doesn't do much with them anymore) as well as collections, and that led me astray.

And thank you too, Luke.  

Edited by jhyler
Amything
Posted

Ah sorry, reading fail, for some reason I thought you were talking about the SDK.

Posted

OK so the api you probably want to look at is:

/Users/{UserId}/Items?Recursive=true&IncludeItemTypes=BoxSet

 

Posted (edited)

What I actually hit on, once I picked up on the hint in Amything's snippet, was 

/emby/Items?IncludeItemTypes=BoxSet&Recursive=true

Seemed to me to be a closer fit - not all users necessarily see all collections and I wanted all.  So far it's working well.  Cheers!

Edited by jhyler
  • Thanks 1

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...