Jump to content

EMBY APi - swagger


kingy444

Recommended Posts

kingy444

I currently use the API for a multitude of different personal applications,

 

looking to build a new interface but the swagger-ui no longer appears available. I remember seeing a post that it was undergoing some work some while ago but cant find that post again.

 

Any info appreciated.

Link to comment
Share on other sites

kingy444

What do you mean?  API link at bottom center of Dashboard.

 

Thanks mate - i used to access it from the tray icon, guess that shows how long its been. never even paid attention to those links at the bottom before

  • Like 1
Link to comment
Share on other sites

kingy444

Looks like there might actually be a problem? I can access the API - but the swagger-ui isnt actually providing me with the info around a call.

 

For Instance: One that I Know has parameters and works fine in some current calls reports no parameters and returns no results

 

I cant even find anywhere on the page to input an API key?

 

5a850f4d416c4_api.jpg

Edited by kingy444
Link to comment
Share on other sites

That looks like an end point that is provided by a community plug-in (AutoOrganize).  Those will not be covered by Swagger.

Link to comment
Share on other sites

kingy444

That looks like an end point that is provided by a community plug-in (AutoOrganize).  Those will not be covered by Swagger.

 

@@ebr

This is just an example because i know it has parameters as I already use it. I assume that the below items query is inbuilt and expected in swagger. I havent seen an API end point listed correctly in swagger at all.

 

On a side note - Why would something that is built to have an API endpoint not be in swagger? shouldnt that be a pre-requisite? otherwise it makes actually using said API quite difficult

 

5a8754e159f5f_items.jpg

Link to comment
Share on other sites

AutoOrganize is a standalone plugin. It was never intended to have an API for others to interact with. It is possible to figure it out and talk to it, but it wasn't designed for that.

Link to comment
Share on other sites

Yes we do know that the swagger implementation is not complete as we had to completely convert it over to a new version recently and that is still in process but, admittedly, on a back burner due to the lack of need.

Link to comment
Share on other sites

kingy444

@@ebr @@Luke

 

What i was trying to do is make an API call to force specific movies to "Refresh All Metadata"

 

I have the info i need to make a call to /Items to get the Movie ID etc, could you provide an example string to refresh metadata on a specific Library Item?

 

Would also be good to know how to restrict a call to a specific library. At the moment I use IncludeItemTypes=Movie and filter based on the Path of the item returned. Would be good to filter prior to getting the data

Link to comment
Share on other sites

Would also be good to know how to restrict a call to a specific library. At the moment I use IncludeItemTypes=Movie and filter based on the Path of the item returned. Would be good to filter prior to getting the data

 

parentId=[libraryID]  (or the ID of any container item).

  • Like 1
Link to comment
Share on other sites

diamondq

I ran into a similar problem with the current lack of information in the Swagger file. While waiting for the official version, I've spent some time adding a bunch of the parameters and data types for a number of the API calls (mostly around Items / Playlists at the moment). You might find my version helpful: https://github.com/diamondq/emby-swagger

  • Like 1
Link to comment
Share on other sites

I ran into a similar problem with the current lack of information in the Swagger file. While waiting for the official version, I've spent some time adding a bunch of the parameters and data types for a number of the API calls (mostly around Items / Playlists at the moment). You might find my version helpful: https://github.com/diamondq/emby-swagger

 

Very cool, thanks ! I need to do another round of development on swagger and get it completed.

Link to comment
Share on other sites

@@diamondq so it looks like you added more info to the json that gets fed into swagger.

 

Did you figure out how to have swagger present a text field that you can enter an access token in? It used to have this and then the access token would go on the query string as api_key=xxx. But now with swagger 3.x, everything is restructured so I haven't looked at whatever the new method is. Thanks.

Link to comment
Share on other sites

diamondq

I'm still using Swagger 2.0, since there isn't let great tool support for 3.0, but I added the following to to the global security definitions. This puts them all as headers, which works fine, even in the Swagger UI. You just have to click the 'Authorize' button to enter the data for either of the two fields.

 

securityDefinitions:
  auth_header:
    name: X-Emby-Authorization
    description: Should be in the format of MediaBrowser Client="MyClient", DeviceId="MyDeviceId", Device="MyDeviceName", Version="MyVersion", UserId="MyUserId"
    type: apiKey
    in: header
  access_token:
    name: X-MediaBrowser-Token
    description: Token provided by Authenticate call
    type: apiKey
    in: header
Edited by diamondq
Link to comment
Share on other sites

Ok we used to use Swagger v2 but at this point I've done much of the work on v3 that I don't really want to start over again and build based on v2. So I just need to set aside time to figure out how to do these things with v3. Thanks.

Link to comment
Share on other sites

  • 1 month later...
kingy444

@@ebr @@Luke

quick one i hope you can answer before i kick this off - can you confirm if making a call to /Items/{0}/Refresh is the equivalent of "Replace all Metadata" and "Replace Existing Images"

 

Long explanation to why i am trying to achieve this, but basically i would like to be able to force all metadata and replace existing images for certain items on task that i will run in the background - im sure i'm just a special use case who likes to automate everything :)

 

Just need to know if there are some extra parameters that need to be passed to the API call to achieve the above

Link to comment
Share on other sites

kingy444

Apparantly it doesnt work at all.

I thought i muse be missing a parameter - but a call to "$($EmbyURL)/Items/731865995b6ce9d735859dd9721dea0c/Refresh?format=json&api_key=$($EmbyAPIKey)" (PowerShell) doesn't appear to do anything

 

This made me dig through the l and find:

2018-04-22 11:05:10.433 Error HttpServer: Could not find handler for /Items/731865995b6ce9d735859dd9721dea0c/Refresh

731865995b6ce9d735859dd9721dea0c is the id= handler from emby url  so i would assume there is something wrong with the API call?

Link to comment
Share on other sites

It works just fine. If it didn't work, then the refresh metadata function in the web app wouldn't work either. 

 

Try using the Chrome debugger to monitor the http requests with the web app. You should be able to use that to compare to yours and find out what is missing.

Link to comment
Share on other sites

kingy444

It works just fine. If it didn't work, then the refresh metadata function in the web app wouldn't work either. 

 

Try using the Chrome debugger to monitor the http requests with the web app. You should be able to use that to compare to yours and find out what is missing.

 

Thanks for the tip - i take it most of the api end points handle the same parameters as the web interface?

 

Comparing the two it appears that when you call /Items/{0}/Refresh you get the 'Could not find a handler' error

 
There are some additional parameters, of which im not sure which are mandatory but as i'm only emulating the web interface command i can now make it work with the below. Thanks for the help
/Items/{0}/Refresh?Recursive=true&ImageRefreshMode=FullRefresh&MetadataRefreshMode=FullRefresh&ReplaceAllImages=true&ReplaceAllMetadata=true&api_key={2}
 
@@diamondq - for info incase you are still maintaining your swagger doco
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...