{"id":19003630,"url":"https://github.com/mpaperno/touchportal-cs-api","last_synced_at":"2025-04-22T18:16:47.826Z","repository":{"id":43457216,"uuid":"461014564","full_name":"mpaperno/TouchPortal-CS-API","owner":"mpaperno","description":"Touch Portal API for C# and .NET","archived":false,"fork":false,"pushed_at":"2024-11-26T06:08:05.000Z","size":223,"stargazers_count":6,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-04-17T09:00:44.307Z","etag":null,"topics":["api","api-client","csharp","dotnet","plugin","touch-portal","touch-portal-api","touch-portal-plugin","touchportal","touchportalapi"],"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/mpaperno.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE.md","code_of_conduct":"CODE_OF_CONDUCT.md","threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2022-02-18T21:45:29.000Z","updated_at":"2024-12-05T17:19:34.000Z","dependencies_parsed_at":"2025-04-16T23:06:17.926Z","dependency_job_id":"42b1bdba-cd43-4ab4-a69b-59a2a1a8cbf8","html_url":"https://github.com/mpaperno/TouchPortal-CS-API","commit_stats":null,"previous_names":[],"tags_count":18,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mpaperno%2FTouchPortal-CS-API","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mpaperno%2FTouchPortal-CS-API/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mpaperno%2FTouchPortal-CS-API/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mpaperno%2FTouchPortal-CS-API/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/mpaperno","download_url":"https://codeload.github.com/mpaperno/TouchPortal-CS-API/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":250296268,"owners_count":21407037,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","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":["api","api-client","csharp","dotnet","plugin","touch-portal","touch-portal-api","touch-portal-plugin","touchportal","touchportalapi"],"created_at":"2024-11-08T18:19:43.254Z","updated_at":"2025-04-22T18:16:47.800Z","avatar_url":"https://github.com/mpaperno.png","language":"C#","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Touch Portal C# and .NET API\n[![Made for Touch Portal](https://img.shields.io/static/v1?style=flat\u0026labelColor=5884b3\u0026color=black\u0026label=made%20for\u0026message=Touch%20Portal%20API%20v10\u0026logo=data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAA4AAAAOCAYAAAAfSC3RAAAAGXRFWHRTb2Z0d2FyZQBBZG9iZSBJbWFnZVJlYWR5ccllPAAAAetJREFUeNp0UruqWlEQXUePb1HERi18gShYWVqJYGeXgF+Qzh9IGh8QiOmECIYkpRY21pZWFnZaqWBhUG4KjWih4msys8FLbrhZMOfsx6w1e9beWjAYBOMtx0eOGBEZzuczrtcreAyTyQSz2QxN04j3f3J84vim8+cNR4s3rKfTSUQQi8UQjUYlGYvFAtPpVIQ0u90eZrGvnHLXuOKcB1GpkkqlUCqVEA6HsVqt4HA4EAgEMJvNUC6XMRwOwWTRfhIi3e93WK1W1Go1dbTBYIDj8YhOp4NIJIJGo4FEIoF8Po/JZAKLxQIIUSIUChGrEy9Sr9cjQTKZJJvNRtlsVs3r9Tq53W6Vb+Cy0rQyQtd1OJ1O9b/dbpCTyHoul1O9z+dzGI1Gla7jFUiyGBWPx9FsNpHJZNBqtdDtdlXfAv3vZLmCB6SiJIlJhUIB/X7/cS0viXI8n8+nrBcRIblcLlSrVez3e4jrD6LsK3O8Xi8Vi0ViJ4nVid2kB3a7HY3HY2q325ROp8nv94s5d0XkSsR90OFwoOVySaPRiF6DiHs8nmdXn+QInIxKpaJclWe4Xq9fxGazAQvDYBAKfssDeMeD7zITc1gR/4M8isvlIn2+F3N+cIjMB76j4Ha7fb7bf8H7v5j0hYef/wgwAKl+FUPYXaLjAAAAAElFTkSuQmCC)](https://www.touch-portal.com/)\n[![Nuget](https://img.shields.io/nuget/v/TouchPortal-CS-API)](https://www.nuget.org/packages/TouchPortal-CS-API)\n[![.NET](https://github.com/mpaperno/TouchPortal-CS-API/actions/workflows/dotnet.yml/badge.svg)](https://github.com/mpaperno/TouchPortal-CS-API/actions/workflows/dotnet.yml) \n[![License](https://img.shields.io/badge/license-MIT-blue.svg)](LICENSE)\n[![Discord](https://img.shields.io/static/v1?style=flat\u0026color=7289DA\u0026\u0026labelColor=7289DA\u0026message=Discord%20Chat\u0026label=\u0026logo=discord\u0026logoColor=white)](https://discord.gg/hMU9tjCG2s)\n\n----------------------\n\n## Touch Portal API for making plugins with .NET\n\nBuilt based on documentation at [Touch Portal Plugin API](https://www.touch-portal.com/api/).\n\nCurrent Touch Portal API support level: **v10.0** (Touch Portal **v4.3**)\n\nOriginally a fork of [https://github.com/oddbear/TouchPortalSDK](https://github.com/oddbear/TouchPortalSDK), optimized for performance, usability, and good behavior.\n\n### Download / Install\n\n- The API is available via a [nuget package](https://www.nuget.org/packages/TouchPortal-CS-API) along with a separate debug symbols package.\n- An equivalent .zip archive is also available for download in [Releases](https://github.com/mpaperno/TouchPortal-CS-API/releases). This includes debug symbols in external .pdb files.\n- Pre-built libraries are available for .NET versions 6, 7, and 8 via both delivery methods and include generated documentation XML.\n\n### Getting started:\n\nThe simplest way of getting started, is to implement \n[`ITouchPortalEventHandler`](https://github.com/mpaperno/TouchPortal-CS-API/blob/main/TouchPortalSDK/ITouchPortalEventHandler.cs) \nand use [`TouchPortalFactory`](https://github.com/mpaperno/TouchPortal-CS-API/blob/main/TouchPortalSDK/TouchPortalFactory.cs) to create an instance of \n[`TouchPortalClient`](https://github.com/mpaperno/TouchPortal-CS-API/blob/main/TouchPortalSDK/Clients/TouchPortalClient.cs).\nThen `TouchPortalClient.Connect()` to Touch Portal before sending or receiving events.\n\n```csharp\npublic class SamplePlugin : ITouchPortalEventHandler\n{\n    // Replace \"Plugin.Id\" with your unique id.\n    public string PluginId =\u003e \"Plugin.Id\";  \n\n    private readonly ITouchPortalClient _client;\n    private readonly ILogger\u003cSamplePlugin\u003e _logger;\n\n    public SamplePlugin()\n    {\n        _client = TouchPortalFactory.CreateClient(this);\n        _logger = new Logger\u003cSamplePlugin\u003e(default);\n    }\n\n    public void Run()\n    {\n        // Connect to Touch Portal on startup.\n        _client.Connect();\n    }\n    \n    // Event received when plugin connects to Touch Portal.\n    public void OnInfoEvent(InfoEvent message)\n    {\n        _logger.LogInformation(\n          \"[InfoEvent] VersionCode: '{TpVersionCode}', VersionString: '{TpVersionString}', SDK: '{SdkVersion}', PluginVersion: '{PluginVersion}', Status: '{Status}'\",\n          message.TpVersionCode, message.TpVersionString, message.SdkVersion, message.PluginVersion, message.Status\n        );\n        \n        // Update a static state defined in entry.tp\n        _client.StateUpdate($\"{PluginId}.staticState1\", \"Connected!\");\n\n        // Add a dynamic state\n        _client.CreateState($\"{PluginId}.dynamicState1\", \"Test dynamic state 1\", \"Test 123\");\n    }\n\n    // Event triggered when one of this plugin's actions, defined in entry.tp, is triggered.\n    public void OnActionEvent(ActionEvent message) {\n        _logger.LogInformation(\"{@message}\", message);_\n        // Handle the action....\n    }\n    // ...\n}\n```\n\nMore complete example in the [Sample project](https://github.com/mpaperno/TouchPortal-CS-API/blob/main/TouchPortalSDK.Sample/SamplePlugin.cs) of this repository.\nFor more documentation see the original [Wiki](https://github.com/oddbear/TouchPortalSDK/wiki).\n\n### Compatibility With Original\n\nDrop-in replacement for `oddbear`'s TouchPortalSDK as of his v0.30.0-beta2, **except**:\n* The `ActionEvent.Data` property, which was an array or key-value pairs, is now a `Dictionary\u003cstring, string\u003e`\nwith each data ID mapped to its corresponding value. \nSee the [SamplePllugin.cs changes on this commit](https://github.com/mpaperno/TouchPortal-CS-API/commit/8a918b5ad1e82f01b459c233447465a9c6157de0#diff-cb35f57a6de34300ca9fce15af2bada215b8c92a45456f671b02b78923a5b083)\nfor how to update (but now you can also `message.Data.TryGetValue(\"myDataId\", out string value)`, for example).\n\nSince `oddbear`'s TouchPortalSDK v 0.30.0 release version, the paths have diverged further, most notably in the handling of TP Connectors.\n\n### Change Log\n\nSee [CHANGELOG.md](https://github.com/mpaperno/TouchPortal-CS-API/blob/main/CHANGELOG.md).\n\n### Plugins Using This API\n\nWorking examples at:\n\n* https://github.com/mpaperno/MSFSTouchPortalPlugin\n* https://github.com/mpaperno/TJoy\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmpaperno%2Ftouchportal-cs-api","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmpaperno%2Ftouchportal-cs-api","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmpaperno%2Ftouchportal-cs-api/lists"}