### Example - Show latest movies Source: https://github.com/mediabrowser/emby/wiki/Latest-Items Demonstrates how to retrieve the latest 20 unplayed movies. ```APIDOC ## Example - Show latest movies ### Description This example demonstrates how to retrieve the latest 20 unplayed movies. ### Method GET ### Endpoint `/Users/{UserId}/Items/Latest?IncludeItemTypes=Movie&Limit=20&IsPlayed=false` ### Parameters #### Query Parameters - **UserId** (string) - Required - The ID of the user. - **IncludeItemTypes** (string) - Required - Set to 'Movie' to filter for movies. - **Limit** (integer) - Required - Set to 20 to retrieve the latest 20 movies. - **IsPlayed** (boolean) - Required - Set to false to retrieve only unplayed movies. ``` -------------------------------- ### Playback Started Source: https://github.com/mediabrowser/emby/wiki/Playback-Check-ins Notify the server that media playback has started. This updates the server dashboard and records the user's activity. ```APIDOC ## Playback Started To let the server know playback started, make an HTTP POST call to **/Sessions/Playing** The body of the request should be a JSON object with the following properties: * QueueableMediaTypes (Array[string] - Audio,Video) * CanSeek (boolean) * ItemId (string) or Item {object} * MediaSourceId (string) * AudioStreamIndex (int, optional) * SubtitleStreamIndex (int, optional) * IsPaused (boolean) * IsMuted (boolean) * PositionTicks (long, optional) * VolumeLevel (int, optional 0-100) * PlayMethod (string) = ['Transcode' or 'DirectStream' or 'DirectPlay'] * PlaySessionId * LiveStreamId * PlaylistIndex (current index in the play queue) * PlaylistLength (current length of the play queue) * SubtitleOffset (floating point value) * PlaybackRate (floating point value) The content type of the request should be **application/json**. ### ItemId vs Item If the user is playing a server library item, simply supply the ItemId property and omit Item. If the user is playing content that is not part of the server library, it can still be reported by supplying an object containing information describing the media. ### Item Properties * Name (string) * MediaType (string - Audio, Video, Book, Game) * Type (string - Movie, Episode, Trailer, Video, Audio, Book, Game) * RunTimeTicks (long, optional) * PremiereDate (Date, optional) * ProductionYear (int, optional) * IndexNumber (int, optional) * IndexNumberEnd (int, optional) * ParentIndexNumber (int, optional) * SeriesName (string) * Album (string) * Artists (Array[string]) ``` -------------------------------- ### Example - Show latest episodes (with grouping) Source: https://github.com/mediabrowser/emby/wiki/Latest-Items Demonstrates how to retrieve the latest 20 unplayed episodes, with items grouped by series. ```APIDOC ## Example - Show latest episodes (with grouping) ### Description This example retrieves the latest 20 unplayed episodes, with items grouped by their respective series. The result will be a list of series groupings. ### Method GET ### Endpoint `/Users/{UserId}/Items/Latest?IncludeItemTypes=Episode&Limit=20&IsPlayed=false&GroupItems=true` ### Parameters #### Query Parameters - **UserId** (string) - Required - The ID of the user. - **IncludeItemTypes** (string) - Required - Set to 'Episode' to filter for episodes. - **Limit** (integer) - Required - Set to 20 to retrieve the latest 20 episodes. - **IsPlayed** (boolean) - Required - Set to false to retrieve only unplayed episodes. - **GroupItems** (boolean) - Required - Set to true to group episodes by series. ``` -------------------------------- ### Get Programs Source: https://github.com/mediabrowser/emby/wiki/Live-TV Queries for program guide (EPG) data. Supports filtering by various program attributes. ```APIDOC ## GET /LiveTv/Programs ### Description Queries for program guide (EPG) data. ### Method GET ### Endpoint /LiveTv/Programs ### Parameters #### Query Parameters - **channelId** (string) - Optional - Filters programs by channel ID. - **startIndex** (integer) - Optional - The record index to start at. - **limit** (integer) - Optional - The maximum number of records to return. - **enableTotalRecordCount** (boolean) - Optional - If true, the total number of records will be returned. - **isSeries** (boolean) - Optional - Filters for series programs. - **isMovie** (boolean) - Optional - Filters for movie programs. - **isSports** (boolean) - Optional - Filters for sports programs. - **isNews** (boolean) - Optional - Filters for news programs. - **isKids** (boolean) - Optional - Filters for kids programs. - **minStartDate** (string) - Optional - Filters programs starting on or after this date/time. - **minEndDate** (string) - Optional - Filters programs ending on or after this date/time. ### Response #### Success Response (200) - **Name** (string) - The name of the program (series name if part of a series). - **EpisodeTitle** (string) - The title of the specific episode (if applicable). - **OfficialRating** (string) - The official rating of the program. - **RunTimeTicks** (integer) - The runtime of the program in ticks. - **StartDate** (string) - The start date and time of the program. - **EndDate** (string) - The end date and time of the program. - **IsMovie** (boolean) - True if the program is a movie. - **IsSports** (boolean) - True if the program is sports. - **IsNews** (boolean) - True if the program is news. - **IsKids** (boolean) - True if the program is for kids. - **IsSeries** (boolean) - True if the program is part of a series. - **ChannelId** (string) - The ID of the channel the program airs on. ``` -------------------------------- ### Emby Plugin Constructor Example Source: https://github.com/mediabrowser/emby/wiki/How-to-build-a-Server-Plugin Implement the constructor for your main plugin class, inheriting from BasePlugin, to accept required dependencies. ```csharp public Plugin(IApplicationPaths applicationPaths, IXmlSerializer xmlSerializer) : base(applicationPaths, xmlSerializer) ``` -------------------------------- ### Basic API Endpoint Creation Source: https://github.com/mediabrowser/emby/wiki/Creating-Api-Endpoints Demonstrates how to create a simple API endpoint with a GET request, including the service class, request DTO, and route definition. ```APIDOC ## GET /Weather ### Description Gets weather information for a given location. ### Method GET ### Endpoint /Weather ### Parameters #### Query Parameters - **Location** (string) - Required - The location for which to retrieve weather information. ### Request Example ```json { "Location": "New York" } ``` ### Response #### Success Response (200) - **WeatherInfo** (object) - Contains the weather information for the specified location. ### Response Example ```json { "example": "WeatherInfo object" } ``` ``` -------------------------------- ### Example - Show latest episodes for a specific series Source: https://github.com/mediabrowser/emby/wiki/Latest-Items Demonstrates how to retrieve the latest 4 unplayed episodes for a specific series, without grouping. ```APIDOC ## Example - Show latest episodes for a specific series ### Description This example retrieves the latest 4 unplayed episodes belonging to a specific series, with grouping disabled. This is useful for displaying episodes after a user has selected a series from a grouping. ### Method GET ### Endpoint `/Users/{UserId}/Items/Latest?Limit=4&IsPlayed=false&GroupItems=false&ParentId={SeriesId}` ### Parameters #### Query Parameters - **UserId** (string) - Required - The ID of the user. - **Limit** (integer) - Required - Set to 4 to retrieve the latest 4 episodes. - **IsPlayed** (boolean) - Required - Set to false to retrieve only unplayed episodes. - **GroupItems** (boolean) - Required - Set to false to disable grouping. - **ParentId** (string) - Required - The ID of the series to filter episodes by. ``` -------------------------------- ### Authorization Header Example Source: https://github.com/mediabrowser/emby/wiki/User-Authentication Include this header in all API requests for user authentication. Customize parameters like UserId, Client, Device, DeviceId, and Version. ```text Authorization=Emby UserId="e8837bc1-ad67-520e-8cd2-f629e3155721", Client="Android", Device="Samsung Galaxy SIII", DeviceId="xxx", Version="1.0.0.0" ``` -------------------------------- ### Send Play Command Source: https://github.com/mediabrowser/emby/wiki/Remote-control Instructs a client to play specified media. Supports various playback options and starting positions. ```APIDOC ## POST /Sessions/{Id}/Playing ### Description Instructs a client to play specified media. Supports various playback options and starting positions. ### Method POST ### Endpoint /Sessions/{Id}/Playing ### Parameters #### Path Parameters - **Id** (string) - Required - The ID of the session to control. #### Request Body - **ItemIds** (string) - Required - A comma-delimited list of item IDs to play. - **PlayCommand** (string) - Required - The playback command (e.g., PlayNow, PlayNext, PlayLast). - **StartPositionTicks** (integer) - Optional - The starting position in ticks for the first title. - **MediaSourceId** (string) - Optional - The media source to use for the first item. - **AudioStreamIndex** (integer) - Optional - The audio stream to use for the first item. - **SubtitleStreamIndex** (integer) - Optional - The subtitle stream to use for the first item. - **StartIndex** (integer) - Optional - The index of the first item to play when playing a list. ``` -------------------------------- ### Retrieve a Single Item Source: https://github.com/mediabrowser/emby/wiki/Browsing-the-Library Get detailed information for a specific item. ```APIDOC ## GET /Users/{UserId}/Items/{Id} ### Description Retrieves all details for a single item identified by its ID. ### Endpoint /Users/{UserId}/Items/{Id} ### Parameters #### Path Parameters - **UserId** (string) - Required - The ID of the user. - **Id** (string) - Required - The ID of the item. ``` -------------------------------- ### Box Set Shortcut Example Source: https://github.com/mediabrowser/emby/wiki/Movie-Library Use shortcut files (.lnk) within a box set folder to link to movie folders located elsewhere in the library. ```text /Movies /Home Alone (1990) /Home Alone (1990).mkv /Boxsets /Home Alone Collection [boxset] /homealone.lnk (points to /Home Alone (1990) folder) ``` -------------------------------- ### Get Series Timers Source: https://github.com/mediabrowser/emby/wiki/Live-TV Queries for scheduled series timers. Supports sorting. ```APIDOC ## GET /LiveTv/SeriesTimers ### Description Queries for scheduled series timers. ### Method GET ### Endpoint /LiveTv/SeriesTimers ### Parameters #### Query Parameters - **startIndex** (integer) - Optional - The record index to start at. - **limit** (integer) - Optional - The maximum number of records to return. - **enableTotalRecordCount** (boolean) - Optional - If true, the total number of records will be returned. - **sortBy** (string) - Optional - Sorts the results by Name or Priority. ### Response #### Success Response (200) - **Name** (string) - The name of the series. - **Priority** (integer) - The priority of the series timer. ``` ```APIDOC ## POST /LiveTv/SeriesTimers ### Description Creates or updates a series timer. ### Method POST ### Endpoint /LiveTv/SeriesTimers ### Request Body - **Name** (string) - The name of the series. - **Priority** (integer) - The priority of the series timer. - **ProgramId** (string) - Optional - The ID of a program to base the series timer on. ``` ```APIDOC ## POST /LiveTv/SeriesTimers/{Id} ### Description Creates or updates a series timer. ### Method POST ### Endpoint /LiveTv/SeriesTimers/{Id} ### Parameters #### Path Parameters - **Id** (string) - Required - The ID of the series timer to update. ### Request Body - **Name** (string) - The name of the series. - **Priority** (integer) - The priority of the series timer. - **ProgramId** (string) - Optional - The ID of a program to base the series timer on. ``` -------------------------------- ### Configure .NET Standard Project for Emby Plugin Source: https://github.com/mediabrowser/emby/wiki/How-to-build-a-Server-Plugin Replace the contents of your .csproj file with this to target .NET Standard and include the Emby server core package. ```xml netstandard2.0; 1.0.0.0 1.0.0.0 ``` -------------------------------- ### Retrieve Items from a View Source: https://github.com/mediabrowser/emby/wiki/Browsing-the-Library Get items within a specific view or folder. ```APIDOC ## GET /Users/{UserId}/Items ### Description Retrieves items within a specified view or folder. Supports generic navigation and can be filtered and sorted. ### Endpoint /Users/{UserId}/Items ### Parameters #### Query Parameters - **parentId** (string) - Required - The ID of the view or folder to retrieve items from. - **SortBy** (string) - Optional - Fields to sort on, comma-delimited (e.g., `Artist,Album`). - **SortOrder** (string) - Optional - Order for sorting (e.g., `Ascending`, `Descending`). Can be a comma-delimited list matching `SortBy`. - **Fields** (string) - Optional - Comma-delimited list of additional fields to include in the output (e.g., `PrimaryImageAspectRatio,SortName`). - **Recursive** (boolean) - Optional - Set to `true` to search recursively. - **Limit** (integer) - Optional - Limits the number of results. - **Filters** (string) - Optional - Filters to apply (e.g., `IsResumable`). - **IncludeItemTypes** (string) - Optional - Comma-delimited list of item types to include (e.g., `Movie,Episode`). ``` -------------------------------- ### Multiple Sort Orders Example Source: https://github.com/mediabrowser/emby/wiki/Browsing-the-Library Demonstrates sorting albums by release date descending, then by sort name ascending. Multiple sort orders are supported by providing comma-delimited values for SortBy and SortOrder. ```http SortBy=ProductionYear,PremiereDate,SortName&SortOrder=Descending,Descending,Ascending ``` -------------------------------- ### Retrieve User Views Source: https://github.com/mediabrowser/emby/wiki/Browsing-the-Library Get the user's top-level categories (views). ```APIDOC ## GET /Users/{UserId}/Views ### Description Retrieves the top-level categories or views for a specific user. ### Endpoint /Users/{UserId}/Views ``` -------------------------------- ### Get Timers Source: https://github.com/mediabrowser/emby/wiki/Live-TV Queries for scheduled recordings (timers). Supports filtering and retrieving individual timers. ```APIDOC ## GET /LiveTv/Timers ### Description Queries for scheduled recording timers. ### Method GET ### Endpoint /LiveTv/Timers ### Parameters #### Query Parameters - **channelId** (string) - Optional - Filters timers by channel ID. - **seriesTimerId** (string) - Optional - Filters timers by series timer ID. - **startIndex** (integer) - Optional - The record index to start at. - **limit** (integer) - Optional - The maximum number of records to return. - **enableTotalRecordCount** (boolean) - Optional - If true, the total number of records will be returned. ### Response #### Success Response (200) - **ProgramInfo** (object) - Information about the program being recorded. Can be null. - **ChannelId** (string) - The ID of the channel for this timer. - **StartDate** (string) - The start date and time of the recording. - **EndDate** (string) - The end date and time of the recording. ``` ```APIDOC ## GET /LiveTv/Timers/{Id} ### Description Retrieves a single scheduled recording timer by its ID. ### Method GET ### Endpoint /LiveTv/Timers/{Id} ### Parameters #### Path Parameters - **Id** (string) - Required - The ID of the timer to retrieve. ``` ```APIDOC ## POST /LiveTv/Timers ### Description Creates or updates a scheduled recording timer. ### Method POST ### Endpoint /LiveTv/Timers ### Request Body - **ProgramInfo** (object) - Information about the program to record. - **ChannelId** (string) - The ID of the channel for this timer. - **StartDate** (string) - The start date and time of the recording. - **EndDate** (string) - The end date and time of the recording. ``` ```APIDOC ## POST /LiveTv/Timers/{Id} ### Description Creates or updates a scheduled recording timer. ### Method POST ### Endpoint /LiveTv/Timers/{Id} ### Parameters #### Path Parameters - **Id** (string) - Required - The ID of the timer to update. ### Request Body - **ProgramInfo** (object) - Information about the program to record. - **ChannelId** (string) - The ID of the channel for this timer. - **StartDate** (string) - The start date and time of the recording. - **EndDate** (string) - The end date and time of the recording. ``` -------------------------------- ### Send General Command with Arguments Source: https://github.com/mediabrowser/emby/wiki/Remote-control Execute general commands on a session by POSTing to /Sessions/{Id}/Command/{CommandName}. Arguments should be provided in JSON format in the request body. ```http POST /Sessions/{Id}/Command/{CommandName} Content-Type: application/json { "Arguments":{ "Name": "Value" } } ``` -------------------------------- ### Create Playlist Source: https://github.com/mediabrowser/emby/wiki/Playlists Creates a new playlist for a user. You can specify the media type and optionally provide item IDs to populate the playlist initially. ```APIDOC ## POST /Playlists ### Description Creates a new playlist. ### Method POST ### Endpoint /Playlists ### Parameters #### Query Parameters - **UserId** (string) - Required - The ID of the user for whom to create the playlist. - **Name** (string) - Required - The name of the playlist. - **MediaType** (string) - Optional - The type of media in the playlist (Audio or Video). Required if Ids is not specified. - **Ids** (string) - Optional - A comma-delimited list of item IDs to add to the playlist. If provided, MediaType can be omitted. ### Response #### Success Response (200) Details about the created playlist. ``` -------------------------------- ### Get Timer Defaults Source: https://github.com/mediabrowser/emby/wiki/Live-TV Retrieves a default timer object, which can be populated and then used to schedule a new recording. ```APIDOC ## GET /LiveTv/Timers/Defaults ### Description Retrieves a default timer object that can be populated and used to schedule a new recording. ### Method GET ### Endpoint /LiveTv/Timers/Defaults ### Parameters #### Query Parameters - **programId** (string) - Optional - If provided, the default timer will be populated with details for this program. ``` -------------------------------- ### Get Channels Source: https://github.com/mediabrowser/emby/wiki/Live-TV Queries for available TV channels. Supports filtering and retrieving detailed channel information. ```APIDOC ## GET /LiveTv/Channels ### Description Queries for TV channels. Can optionally include current program information. ### Method GET ### Endpoint /LiveTv/Channels ### Parameters #### Query Parameters - **enableTotalRecordCount** (boolean) - Optional - If true, the total number of records will be returned. - **startIndex** (integer) - Optional - The record index to start at. - **limit** (integer) - Optional - The maximum number of records to return. - **currentProgram** (boolean) - Optional - If true, includes the current program for each channel. ### Response #### Success Response (200) - **Name** (string) - The name of the channel. - **Number** (string) - The channel number. - **ChannelType** (string) - The type of the channel (e.g., 'TV', 'Radio'). - **CurrentProgram** (object) - Information about the program currently airing on the channel (if requested). - **Id** (string) - The unique identifier for the channel. ``` -------------------------------- ### Create a Basic API Service Source: https://github.com/mediabrowser/emby/wiki/Creating-Api-Endpoints Define a request DTO and a service class to handle API requests. The `Route` attribute specifies the URL and HTTP method. The service method should return an object, string, byte array, or stream. ```csharp [Route("/Weather", "GET")] [Api(Description = "Gets weather information for a given location")] public class GetWeather : IReturn { public string Location { get; set; } } public class WeatherService : IService { public object Get(GetWeather request) { var result = GetWeatherInfo(); return result; } } ``` -------------------------------- ### Emby Audio Streaming URL Example Source: https://github.com/mediabrowser/emby/wiki/Audio-streaming This URL demonstrates how to request an audio stream, specifying various parameters for direct play or transcoding. It includes supported containers, transcoding settings, and playback session information. ```url /Audio/{ItemId}/universal?UserId=xxx&DeviceId=xxx&MaxStreamingBitrate=140000000&Container=opus,mp3,aac,m4a,flac,webma,webm,wav,ogg,aac,mp3,mpa,wav,wma,mp2,ogg,oga,webma,ape,opus,flac,m4a&TranscodingContainer=ts&TranscodingProtocol=hls&AudioCodec=aac&MaxSampleRate=48000&PlaySessionId=1496213367201 ```