{"id":37031239,"url":"https://github.com/jensenkd/plex-api","last_synced_at":"2026-01-14T03:49:39.393Z","repository":{"id":38187792,"uuid":"245302499","full_name":"jensenkd/plex-api","owner":"jensenkd","description":".NET Core SDK for Plex Media Server","archived":false,"fork":false,"pushed_at":"2024-05-26T21:37:26.000Z","size":921,"stargazers_count":97,"open_issues_count":16,"forks_count":27,"subscribers_count":8,"default_branch":"master","last_synced_at":"2025-12-08T09:41:12.177Z","etag":null,"topics":["plex","plex-api","plex-library","plex-media-server","plexmediaserver","pms"],"latest_commit_sha":null,"homepage":"","language":"C#","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/jensenkd.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":".github/CONTRIBUTING.md","funding":null,"license":"LICENSE.md","code_of_conduct":".github/CODE_OF_CONDUCT.md","threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":".github/SECURITY.md","support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2020-03-06T01:16:10.000Z","updated_at":"2025-11-28T23:57:39.000Z","dependencies_parsed_at":"2024-06-21T19:08:47.844Z","dependency_job_id":"3198cc82-f44a-429c-9017-3ae13ad02548","html_url":"https://github.com/jensenkd/plex-api","commit_stats":null,"previous_names":[],"tags_count":76,"template":false,"template_full_name":null,"purl":"pkg:github/jensenkd/plex-api","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jensenkd%2Fplex-api","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jensenkd%2Fplex-api/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jensenkd%2Fplex-api/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jensenkd%2Fplex-api/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/jensenkd","download_url":"https://codeload.github.com/jensenkd/plex-api/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jensenkd%2Fplex-api/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":28408870,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-01-14T01:52:23.358Z","status":"online","status_checked_at":"2026-01-14T02:00:06.678Z","response_time":107,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["plex","plex-api","plex-library","plex-media-server","plexmediaserver","pms"],"created_at":"2026-01-14T03:49:38.722Z","updated_at":"2026-01-14T03:49:39.366Z","avatar_url":"https://github.com/jensenkd.png","language":"C#","readme":"plex-api\n==============\n\n[![.NET](https://github.com/jensenkd/plex-api/actions/workflows/dotnet.yml/badge.svg)](https://github.com/jensenkd/plex-api/actions/workflows/dotnet.yml)\n[![CodeQL](https://github.com/jensenkd/plex-api/actions/workflows/codeql-analysis.yml/badge.svg)](https://github.com/jensenkd/plex-api/actions/workflows/codeql-analysis.yml)\n[![Nuget Pre-Release](https://github.com/jensenkd/plex-api/actions/workflows/pre-release.yml/badge.svg)](https://github.com/jensenkd/plex-api/actions/workflows/pre-release.yml)\n[![Nuget Release](https://github.com/jensenkd/plex-api/actions/workflows/release.yml/badge.svg)](https://github.com/jensenkd/plex-api/actions/workflows/release.yml)\n[![NuGet version (Newtonsoft.Json)](https://img.shields.io/nuget/v/Plex.Api.svg?style=flat-square)](https://www.nuget.org/packages/Plex.Api/)\n\n\nOverview\n--------\nUnofficial c# bindings for the Plex Media Server API. Our goal is to match all capabilities of the official\nPlex Web Client. A few of the many features we currently support are:\n\n* Navigate local or remote shared libraries.\n* Perform library actions such as scan, analyze, empty trash.\n* Remote control and play media on connected clients.\n* Listen in on all Plex Server notifications.\n\n\nInstallation \u0026 Documentation\n----------------------------\n\nFrom Powershell\n```c#\n    Nuget-Install 'Plex.Api'\n```\n\nDotnet Cli\n```c#\n    dotnet add package 'Plex.Api'\n```\n\nGetting a PlexAccount Instance\n-----------------------------\n\nNOTE: v2.0 documentation updates are incoming...\n\nBoiler plate dependency injection setup.\n\n```c#\n    // Create Client Options\n    var apiOptions = new ClientOptions\n    {\n        Product = \"API_UnitTests\",\n        DeviceName = \"API_UnitTests\",\n        ClientId = \"MyClientId\",\n        Platform = \"Web\",\n        Version = \"v1\"\n    };\n\n    // Setup Dependency Injection\n    var services = new ServiceCollection();\n    services.AddSingleton(apiOptions);\n    services.AddTransient\u003cIPlexServerClient, PlexServerClient\u003e();\n    services.AddTransient\u003cIPlexAccountClient, PlexAccountClient\u003e();\n    services.AddTransient\u003cIPlexLibraryClient, PlexLibraryClient\u003e();\n    services.AddTransient\u003cIApiService, ApiService\u003e();\n    services.AddTransient\u003cIPlexFactory, PlexFactory\u003e();\n    services.AddTransient\u003cIPlexRequestsHttpClient, PlexRequestsHttpClient\u003e();\n    \n    this.ServiceProvider = services.BuildServiceProvider();\n```    \n\nThe entry point to Plex-Api is with the PlexAccount class.  You can instantiate a PlexAccount class using either your \u003cbr /\u003e\nPlex account login and password, or your Plex Auth Token.\n\n```c#\n    var plexFactory = this.ServiceProvider.GetService\u003cIPlexFactory\u003e();\n    \n    // Signin with Username, Password\n    PlexAccount account = plexFactory\n        .GetPlexAccount(\"username\", \"password\");\n    \n    // or use and Plex Auth token\n    PlexAccount account = plexFactory\n        .GetPlexAccount(\"access_token_here\");\n\n```\n\nPlexAccount Documentation\n-----------------------------\n```c#\n    // Get Announcements for Plex Account\n    var announcements = account.Announcements().Result;\n     \n    // Get Server Summaries.  This does not return a Server Instance but a summary\n    // of all servers tied to your Plex Account.  The servers may not be active/online.\n    var servers = account.ServerSummaries().Result;\n         \n    // Get Servers (Active Servers w/Details)\n    var servers = account.Servers().Result;\n    \n    // Get list of Friends for Plex Account\n    var friends = account.Friends().Result;\n    \n    // Get Resources\n    var resources = account.Resources().Result;\n    \n    // Get Providers\n    var providers = account.Providers().Result;\n    \n    // Returns a list of all User objects connected to your account.\n    // This includes both friends and pending invites. You can reference the user.Friend to\n    // distinguish between the two.\n    var users = account.users().Result;\n    \n    // Opt in or out of sharing stuff with plex.\n    // See: https://www.plex.tv/about/privacy-legal/\n    bool optOutOfPlaybackDetails = true;\n    bool optOutOfLibraryDetails = true;\n    account.OptOut(optOutOfPlaybackDetails, optOutOfLibraryDetails);\n \n    // Get Account Devices\n    var devices = account.Devices().Result;      \n```\n\nServer Documentation\n-----------------------------\n```c#\n    var servers = account.Servers().Result;\n    var myServer = servers.Where(c=\u003ec.Owned == \"1\").First();\n    \n    // Get Home OnDeck items\n    var onDeckItems = myServer.HomeOnDeck().Result;\n    \n    // Get Recently Added items for the Home Hub\n    var recentItems = myServer.HomeHubRecentlyAdded().Result;\n    \n    // Get Continue Watching items for the Home Hub\n    var continueItems = myServer.HomeHubContinueWatching().Result;\n    \n    // Share library content with the specified user.\n    string sections = \"1,3,4\";\n    myServer.InviteFriend(\"testuser\", sections); \n    \n    // Get Providers for this Server\n    var providers = myServer.Providers().Result;\n    \n    // Search Across All Hubs on this Server\n    var items = myServer.HubLibrarySearch(\"Harry Potter\").Result;\n    \n    // Get Play History for all library sections on this server.\n    var playHistory = myServer.PlayHistory().Result;\n    \n    // Get Devices connected to this Server\n    var devices = myServer.Devices().Result;\n    \n    // Get list of all Client objects connected to server.\n    var clients = myServer.Clients().Result;\n    \n    // Scrobble Item on this server\n    myServer.ScrobbleItem(\"123\");\n\n    // UnScrobble Item on this server\n    myServer.UnScrobbleItem(\"123\");\n\n    // Downloads Server Logs\n    var logs = myServer.DownloadLogs().Result;\n    \n    // Get list of all release updates available for this Server\n    var updates = myServer.CheckForUpdate().Result;\n    \n    // Get Server Activities.\n    var activities = myServer.Activities().Result;\n\n    // Get Server Statistics.\n    var statistics = myServer.Activities().Result;\n    \n    // Force Plex Server to download new SyncList from Plex.tv.\n    myServer.RefreshSyncList();\n    \n    // Force Plex Server to refresh content for known SyncLists.\n    myServer.RefreshContent();\n    \n    // Force Plex Server to download new SyncList and refresh content.\n    myServer.RefreshSync();\n    \n    // Get Transcode Sessions\n    var transcodeSessions = myServer.TranscodeSessions().Result;\n    \n    // Get Server active Sessions\n    var sessions = myServer.Sessions().Result;\n    \n    // Get Server Playlists\n    var playlists = myServer.Playlists().Result;\n\n```\n\nLibrary Documentation\n-----------------------------\n\n```c#\n    var servers = account.Servers().Result;\n    var myServer = servers.Where(c=\u003ec.Owned == \"1\").First();\n     \n    // Get Libraries for server\n    var libraries = myServer.Libraries().Result;\n    \n     // Get Movies library\n    var movieLibrary = libraries.Single(c =\u003e c.Title == \"Movies\");\n  \n    // Get Search Filters available for this Library\n    var filters = movieLibrary.SearchFilters().Result;\n  \n    // Search Library for item\n    string title = \"Harry Potter\";\n    string sort = \"rating:desc\";\n    string libraryType = \"movie\";\n    var items = movieLibrary.Search(title, sort, libraryType).Result;\n \n    // Get Recently Added for Library\n    var recentlyAdded = movieLibrary.RecentlyAdded().Result;\n    \n    // Return list of Hubs on this library along with their Metadata items\n    var hubs = movieLibrary.Hubs();\n    \n    // Empty Trash for this Library\n    movieLibrary.EmptyTrash();\n    \n    // Scan for new items on this Library\n    movieLibrary.ScanForNewItems();\n    \n    // Cancel running Scan on this library\n    movieLibrary.CancelScan();\n\n```\n\n\n#OLD DOCUMENTATION (NEED TO UPDATE)\n\nMetadata\n\n```c#\n\n    var plexApi = ServiceProvider.GetService\u003cIPlexClient\u003e();\n         \n    // Get Metadata for Library\n    var metadatas = plexApi.MetadataForLibraryAsync(string authToken, string plexServerHost, string libraryKey).Result;\n  \n    // Get Children for Metadata by Metadata Key\n    var metadatas = plexApi.GetChildrenMetadataAsync(string authToken, string plexServerHost, int metadataKey).Result;\n\n    // Get Metadata by Key\n    var metadata = plexApi.GetMetadataAsync(string authToken, string plexServerHost, int metadataKey).Result;\n\n    // Search\n    var metadatas = plexApi.SearchAsync(string authToken, string plexServerHost, string query).Result;   \n```\n\nSessions\n\n```c#\n\n    var plexApi = ServiceProvider.GetService\u003cIPlexClient\u003e();\n    \n    // Get All Sessions on Server\n    var sessions = plexApi.GetSessionsAsync(string authToken, string plexServerHost).Result;\n    \n    // Get Session for Player Machine Id\n    var session = plexApl.GetSessionByPlayerIdAsync(string authToken, string plexServerHost, string playerKey).Result;\n```\n\n\nCollections\n\n```c#\n\n    var plexApi = ServiceProvider.GetService\u003cIPlexClient\u003e();\n    \n    // Get Collections for Library\n    var collections = plexApi\n        .GetCollections(authKey, plexServerUrl, libraryKey).Result;\n        \n    // Get Collection Tags for Movie\n    var collectionTags = plexApi.GetCollectionTagsForMovieAsync(authKey, plexServerUrl, movieKey).Result;\n        \n    // Get Collection\n    var collection = plexApi.GetCollectionAsync(authKey, plexServerUrl, collectionKey).Result;    \n    \n    // Get Collection Movies\n    var movies = plexApi.GetCollectionMoviesAsync(authKey, plexServerUrl, collectionKey).Result;\n\n    // Delete Collection from Movie\n    plexApi.DeleteCollectionFromMovieAsync(authKey, plexServerUrl, libraryKey, movieKey, collectionName);\n    \n    // Add Collection to Movie\n    plexApi.AddCollectionToMovieAsync(authKey, plexServerUrl, libraryKey, movieKey, collectionName);\n\n    // Update Collection\n    var collection = plexApi.GetCollectionAsync(authKey, fullUri, collectionRatingKey).Result;\n    collection.Title = \"New Title for Collection\";\n    plexApi.UpdateCollection(authKey, plexServerUrl, libraryKey, collection);\n\n```\n\nOAuth Implementation Example\n\n```c#\n\n    public class PlexLoginController : Controller\n    {\n        private readonly HttpClient _httpClient = new HttpClient();\n        private readonly PlexOAuthClient _plexOAuthClient;\n        private readonly IPlexClient _plexClient;\n\n        public PlexLoginController(PlexOAuthClient plexOAuthClient, IPlexClient plexClient)\n        {\n            _plexOAuthClient = plexOAuthClient;\n            _plexClient = plexClient;\n        }\n\n        public async Task\u003cIActionResult\u003e IndexAsync()\n        {\n            var redirectUrl = Url.Action(\"PlexReturn\", \"PlexLogin\", null, Request.Scheme);\n            var oauthUrl = await _plexClient.CreateOAuthPinAsync(redirectUrl);\n            HttpContext.Session.SetString(\"PlexOauthId\", oauthUrl.Id.ToString());\n            return Redirect(oauthUrl.Url);\n        }\n\n        public async Task\u003cIActionResult\u003e PlexReturn()\n        {\n            var oauthId = HttpContext.Session.GetString(\"PlexOauthId\");\n            var oAuthPin = await _plexClient.GetAuthTokenFromOAuthPinAsync(oauthId);\n\n            if (string.IsNullOrEmpty(oAuthPin.AuthToken))\n                throw new Exception(\"Plex auth failed.\");\n            HttpContext.Session.Remove(\"PlexOauthId\");\n            HttpContext.Session.SetString(\"PlexKey\", oAuthPin.AuthToken);\n\n            return Redirect(\"/plex\");\n        }\n    }\n```\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjensenkd%2Fplex-api","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fjensenkd%2Fplex-api","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjensenkd%2Fplex-api/lists"}