OctoPrintSharpApi 1.2.0
See the version list below for details.
dotnet add package OctoPrintSharpApi --version 1.2.0
NuGet\Install-Package OctoPrintSharpApi -Version 1.2.0
<PackageReference Include="OctoPrintSharpApi" Version="1.2.0" />
paket add OctoPrintSharpApi --version 1.2.0
#r "nuget: OctoPrintSharpApi, 1.2.0"
// Install OctoPrintSharpApi as a Cake Addin #addin nuget:?package=OctoPrintSharpApi&version=1.2.0 // Install OctoPrintSharpApi as a Cake Tool #tool nuget:?package=OctoPrintSharpApi&version=1.2.0
OctoPrintRestApiSharp
A simple C# library to communicate with an OctoPrint server via REST-API.
Important!
With the upcoming version, starting from 1.2.0
, OctoPrintServer
become OctoPrintClient
. also the namespaces will changed and generalized with our other print server api nugets.
Old | New |
---|---|
AndreasReitberger |
AndreasReitberger.API.OctoPrint |
OctoPrintServer |
OctoPrintClient |
Nuget
Get the latest version from nuget.org<br>
Usage
You can find some usage examples in the TestProject of the source code.
Platform specific setup
Android
On Android
you need to allow local connections in the AndroidManifest.xml
.
For this, create a new xml file and link to it in your manifest at android:networkSecurityConfig
Content of the network_security_config.xml
file
<?xml version="1.0" encoding="utf-8" ?>
<network-security-config>
<base-config cleartextTrafficPermitted="true" />
</network-security-config>
The manifest
<?xml version="1.0" encoding="utf-8"?>
<manifest
xmlns:android="http://schemas.android.com/apk/res/android"
android:versionName="1.0.0"
android:versionCode="1"
package="com.company.app"
>
<application
android:label="App Name"
android:allowBackup="true"
android:icon="@mipmap/appicon"
android:roundIcon="@mipmap/appicon_round"
android:supportsRtl="true"
android:networkSecurityConfig="@xml/network_security_config"
>
</application>
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.ACCESS_WIFI_STATE" />
<uses-permission android:name="android.permission.FOREGROUND_SERVICE" />
<uses-permission android:name="android.permission.WAKE_LOCK" />
<uses-permission android:name="android.permission.INTERNET" />
</manifest>
Init a new server
Just create a new OctoPrintClient
object by passing the host, api, port and ssl connection type.
OctoPrintClient _server = new OctoPrintClient(_host, _api, _port, _ssl);
await _server.CheckOnlineAsync();
if (_server.IsOnline)
{
// Sets the first printer active
if (_server.ActivePrinter == null)
await _server.SetPrinterActiveAsync(0, true);
await _server.RefreshAllAsync();
Assert.IsTrue(_server.InitialDataFetched);
}
Since then, you can access all functions from the OctoPrintServer
object.
Instance
If you want to use the OctoPrintClient
from different places, use the Instance
.
OctoPrintClient.Instance = new OctoPrintClient(_host, _api, _port, _ssl);
await OctoPrintClient.Instance.CheckOnlineAsync();
Aferwards you can use the OctoPrintServer.Instance property to access all functions through your project.
var files = await OctoPrintClient.Instance.GetAllFilesAsync("local");
Available methods
Please find the some usage examples for the methods below.
// Load all files from the Server
var files = await OctoPrintClient.Instance.GetAllFilesAsync("local");
// Get all printer profiles
var printers = await OctoPrintClient.Instance.GetAllPrinterProfilesAsync();
// Update heated bed temperature & read back the state
bool result = await OctoPrintClient.Instance.SetBedTemperatureAsync(25);
var state = await OctoPrintClient.Instance.GetCurrentBedStateAsync(true);
// Update extruder (tool0 or / and tool1) & read back the state
bool result = await OctoPrintClient.Instance.SetToolTemperatureAsync(30);
var state = await OctoPrintClient.Instance.GetCurrentToolStateAsync(true);
var jobinfo = await OctoPrintClient.Instance.GetJobInfoAsync();
Dependencies
RCoreSharp: https://github.com/AndreasReitberger/CoreSharp
Product | Versions Compatible and additional computed target framework versions. |
---|---|
.NET | net5.0 is compatible. net5.0-windows was computed. net6.0 is compatible. net6.0-android was computed. net6.0-ios was computed. net6.0-maccatalyst was computed. net6.0-macos was computed. net6.0-tvos was computed. net6.0-windows was computed. net7.0 is compatible. net7.0-android was computed. net7.0-ios was computed. net7.0-maccatalyst was computed. net7.0-macos was computed. net7.0-tvos was computed. net7.0-windows was computed. net8.0 was computed. net8.0-android was computed. net8.0-browser was computed. net8.0-ios was computed. net8.0-maccatalyst was computed. net8.0-macos was computed. net8.0-tvos was computed. net8.0-windows was computed. |
.NET Core | netcoreapp3.0 was computed. netcoreapp3.1 was computed. |
.NET Standard | netstandard2.1 is compatible. |
.NET Framework | net472 is compatible. net48 was computed. net481 was computed. |
MonoAndroid | monoandroid was computed. |
MonoMac | monomac was computed. |
MonoTouch | monotouch was computed. |
Tizen | tizen60 was computed. |
Xamarin.iOS | xamarinios was computed. |
Xamarin.Mac | xamarinmac was computed. |
Xamarin.TVOS | xamarintvos was computed. |
Xamarin.WatchOS | xamarinwatchos was computed. |
-
.NETFramework 4.7.2
- CommunityToolkit.Mvvm (>= 8.1.0-preview1)
- Newtonsoft.Json (>= 13.0.2)
- RCoreSharp (>= 1.0.8)
- RestSharp (>= 108.0.3)
- System.Memory (>= 4.5.5)
- System.Net.Http (>= 4.3.4)
- WebSocket4Net (>= 0.15.2)
-
.NETStandard 2.1
- CommunityToolkit.Mvvm (>= 8.1.0-preview1)
- Newtonsoft.Json (>= 13.0.2)
- RCoreSharp (>= 1.0.8)
- RestSharp (>= 108.0.3)
- System.Memory (>= 4.5.5)
- System.Net.Http (>= 4.3.4)
- WebSocket4Net (>= 0.15.2)
-
net5.0
- CommunityToolkit.Mvvm (>= 8.1.0-preview1)
- Newtonsoft.Json (>= 13.0.2)
- RCoreSharp (>= 1.0.8)
- RestSharp (>= 108.0.3)
- System.Memory (>= 4.5.5)
- System.Net.Http (>= 4.3.4)
- WebSocket4Net (>= 0.15.2)
-
net6.0
- CommunityToolkit.Mvvm (>= 8.1.0-preview1)
- Newtonsoft.Json (>= 13.0.2)
- RCoreSharp (>= 1.0.8)
- RestSharp (>= 108.0.3)
- System.Memory (>= 4.5.5)
- System.Net.Http (>= 4.3.4)
- WebSocket4Net (>= 0.15.2)
-
net7.0
- CommunityToolkit.Mvvm (>= 8.1.0-preview1)
- Newtonsoft.Json (>= 13.0.2)
- RCoreSharp (>= 1.0.8)
- RestSharp (>= 108.0.3)
- System.Memory (>= 4.5.5)
- System.Net.Http (>= 4.3.4)
- WebSocket4Net (>= 0.15.2)
NuGet packages (2)
Showing the top 2 NuGet packages that depend on OctoPrintSharpApi:
Package | Downloads |
---|---|
GcodeParserSharp
A simple C# Gcode parser to read gcodes and get out the filament volume and estimated print time. |
|
GcodeParserSharp.Maui
A simple C# Gcode parser to read gcodes and get out the filament volume and estimated print time. |
GitHub repositories
This package is not used by any popular GitHub repositories.