Jump to content

More /Collections Endpoints


Poppabear
Go to solution Solved by PenkethBoy,

Recommended Posts

Poppabear

I'm noticing that the Collections endpoints are fairly limited

 

I would like to see:

 

GET /Collections that obviously retrieves all collection resources.

GET /Collections/{id} that retrieves a single collection resource.

 

Those are the most important that are missing.

 

Thanks in advance

 

Link to comment
Share on other sites

Hi, you can do this using our generic /items api so there is no need to have specific versions just for collections.

Link to comment
Share on other sites

Poppabear

Hi, you can do this using our generic /items api so there is no need to have specific versions just for collections.

 

Well, its not well documented, I'm checking out the API via Swagger UI ...

 

Can you show me an example of how I can accomplish the previous results from the GET /Items Endpoint ?

 

Thanks again in advance

Edited by Poppabear
Link to comment
Share on other sites

Poppabear

I appreciate the time, However this does not demonstrate how to query the collections through the various options.

 

Its not a simple inCollection(collectionId) returns all items in collection by collection id

 

I see a filter - Specify one or more ItemFilters, comma delimeted (see server-side enum),  However I must be overlooking the documentation to know how to use this filter option correctly ?

 

Or maybe i'm mis-understanding something ?

 

Thanks

Link to comment
Share on other sites

Poppabear
 {
      "Name": "collections",
      "ServerId": "2e82ca2c732946bb9421bf857eb0d302",
      "Id": "234738",
      "IsFolder": true,
      "Type": "Folder",
      "ImageTags": {},
      "BackdropImageTags": []
}

I do see this in the /Items Results ... but using /Items/234738 i get "Unable to find the specified file."

 

I can see this being used here ? https://github.com/MediaBrowser/Emby.ApiClient.Javascript/blob/master/apiclient.js#L804

Edited by Poppabear
Link to comment
Share on other sites

Poppabear

... there is no need to have specific versions just for collections.

 

 And just to touch on this a little bit ... To add an endpoint here takes very little logic as its just a wrapper for the items query. But to say there is "No Need" I have to argue even if its not simply for readability. Readability is very important to developers as they would like to know what they are looking at.

 

I'm certain I can't be the only one that's looked at the Collection Services to be like "Where are the GET endpoints ??" Especially since the  documentation for the API is incomplete.

 

I think the little things is what shows your user base that you are paying attention to the details.

 

With all that said I am in no way trying to discredit anything you and your team does, just my opinion.

 

I am a senior software developer and architect so I'm not just some kid trying to play around with some code ;)

 

Now that that's said, I'm ok with whatever solution is offered ... i'm just struggling to get the collections

 

Thanks

Link to comment
Share on other sites

  • Solution
PenkethBoy

I had to work this out myself a while ago.

 

Yes the documentation is very lacking when you first start out - Swagger is good to test stuff - but sometimes the best way to find stuff out is to do it in the web app then check the debug log to see how they query the db

 

So...

 

1. To get a list of existing collections (called 'boxset' internally by Emby) an example returning some extra "Fields" in addition to the basic info

$embyServerUrl + "/emby/users/" + $User.User.Id + "/items?Fields=ChildCount,RecursiveItemCount&Recursive=true&SortBy=SortName&SortOrder=Ascending&IncludeItemTypes=boxset" + "&api_key=" + $User.AccessToken

You get json returned that looks like this.

 

You could also filter by Emby Library if you wanted to narrow your search as the url above will return all Collections

{
    "Items":  [
                  {
                      "Name":  "Harry Potter Collection",
                      "ServerId":  "393d783c30484015a24645f7844060b4",
                      "Id":  "56363",
                      "IsFolder":  true,
                      "Type":  "BoxSet",
                      "UserData":  {
                                       "PlaybackPositionTicks":  0,
                                       "PlayCount":  0,
                                       "IsFavorite":  false,
                                       "Played":  false
                                   },
                      "RecursiveItemCount":  4,
                      "ChildCount":  4,
                      "ImageTags":  {
                                        "Primary":  "569c475e2cd007115791315c045191eb",
                                        "Art":  "dc3acd1748b8e0f96ff73e67f3cfe1e4",
                                        "Banner":  "843348644e3b13c8a58fd0db7ea57a91",
                                        "Logo":  "7747bfd998e9b4fbb940fc3c4ac20af5",
                                        "Thumb":  "e92392142d45e1b03f3e3f425de4263b"
                                    },
                      "BackdropImageTags":  [
                                                "b1565e7944dcc949107a01873b63405d",
                                                "b00e2dd87f96b13eadb7c8daa2af9d0e",
                                                "227151d95c53883f7edffdbe8fac0ea3",
                                                "931b2e44b1285e9d729185c2b16c1fb7",
                                                "4d91bf5d13d45a3da510b856dd6ac480",
                                                "8621e25e6a216def9de9f90ea7cbbd1a",
                                                "2279f79684d21913cf7922ecef9c564b",
                                                "bf03924b4cd421c8601161668b19cb98",
                                                "7edc51c8bda707c9616b3f7747fe19e7",
                                                "169d42390e150470c71cf33fda182fbd"
                                            ]
                  },
                  {
                      "Name":  "Star Wars Collection",
                      "ServerId":  "393d783c30484015a24645f7844060b4",
                      "Id":  "416",
                      "IsFolder":  true,
                      "Type":  "BoxSet",
                      "UserData":  {
                                       "PlaybackPositionTicks":  0,
                                       "PlayCount":  0,
                                       "IsFavorite":  false,
                                       "Played":  false
                                   },
                      "RecursiveItemCount":  1,
                      "ChildCount":  1,
                      "ImageTags":  {
                                        "Primary":  "84de2db74a56e59a3799ce2947152a7d",
                                        "Art":  "cfa0c0a01423f6504b4eb55a20d3c377",
                                        "Banner":  "da0f9c9993eddd66e4ce2a42f665a2b3",
                                        "Logo":  "bea979a28dac37896de6c33bf5f9cf2a",
                                        "Thumb":  "47c3c3486474c3d1da12b20e364de771"
                                    },
                      "BackdropImageTags":  [
                                                "6ecbdbf35fd5ecfdaa0f4b8124173b57",
                                                "2d9bb1d814bbe51c375855a6dfa9b5a6",
                                                "3cfa7f2ffba2bb8e8d4bceb2d7821747",
                                                "9c343c59eb879c70dd45e53181cad582",
                                                "a262a67e72be3284fc6fe72550fe8b81",
                                                "e7a935b3369e2a3730628f2539f52c08",
                                                "40efd2edf57e57a390bc111dbde1cfaa",
                                                "cd8d97de7d5f152247ff3cdededc9d2b",
                                                "486451aa6b4b44e797f67ce193494523",
                                                "077aa4d71bca91a8826fd4c392932357"
                                            ]
                  }
              ],
    "TotalRecordCount":  2
}

2. To get the items belonging to a Collection

$embyServerUrl + "/emby/users/" + $User.User.Id + "/items?Parentid=416" + "&api_key=" + $User.AccessToken

In this case the Star Wars collection which only has one item added on my test server - i.e. Parentid = the star wars collection Id above

 

Json output looks like this

{
    "Items":  [
                  {
                      "Name":  "Star Wars: Episode I - The Phantom Menace",
                      "ServerId":  "393d783c30484015a24645f7844060b4",
                      "Id":  "444",
                      "RunTimeTicks":  81709430000,
                      "IsFolder":  false,
                      "Type":  "Movie",
                      "UserData":  {
                                       "PlaybackPositionTicks":  0,
                                       "PlayCount":  0,
                                       "IsFavorite":  false,
                                       "Played":  false
                                   },
                      "ImageTags":  {
                                        "Primary":  "938b87a88c41cf9e16146585b8e0d64f",
                                        "Art":  "2e7998c27b3737369a69da0d7a70984a",
                                        "Banner":  "cd00fa054ed582ceab695a13b079256a",
                                        "Disc":  "c950ccae536d575e9bdf74880ece1ccc",
                                        "Logo":  "5cbec617403ce68eec3ece2fa5465319",
                                        "Thumb":  "8eee6ab5a4a9fe50de05b6bb81064a6b"
                                    },
                      "BackdropImageTags":  [
                                                "247566be6830b3c45d115442ad109a27",
                                                "76058351d92676d9919259980371c642",
                                                "2209b6498fe2d8687481ece8032c5f24",
                                                "c44caafbf09e2b2e9cf9275d6c05ca40",
                                                "7b401e273ab90207b89a225fab2c3992",
                                                "7f43e593f84264f9c0bbc25f8d1a06c9",
                                                "3d065d03b4e719d0cf9addc638f17ee7",
                                                "7a81f4d78acdc768b31a72bdb076f360",
                                                "32e4a1be647223cdae95e589246a3869",
                                                "ce6d3010f3888d191c05b15c3d929da2"
                                            ],
                      "MediaType":  "Video"
                  }
              ],
    "TotalRecordCount":  1
}

Have fun

 

@@Poppabear

  • Like 2
Link to comment
Share on other sites

Poppabear

Thank you for your help ... I am working on a set of nice tools (one of them being one you had responded to back in January 2018) that runs on Windows

 

A little teaser

 

5d85341eb2621_explorer_Dpq9hipwkg.png

Edited by Poppabear
Link to comment
Share on other sites

PenkethBoy

LOL

 

Use this then

 

/emby/Items?ParentId=416......

 

i use the User so things re restriction/parent control still apply

Link to comment
Share on other sites

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...