PiShock.Net 1.0.0

dotnet add package PiShock.Net --version 1.0.0
                    
NuGet\Install-Package PiShock.Net -Version 1.0.0
                    
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="PiShock.Net" Version="1.0.0" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="PiShock.Net" Version="1.0.0" />
                    
Directory.Packages.props
<PackageReference Include="PiShock.Net" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add PiShock.Net --version 1.0.0
                    
#r "nuget: PiShock.Net, 1.0.0"
                    
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#:package PiShock.Net@1.0.0
                    
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=PiShock.Net&version=1.0.0
                    
Install as a Cake Addin
#tool nuget:?package=PiShock.Net&version=1.0.0
                    
Install as a Cake Tool

PiShock.Net

An unofficial .NET SDK for PiShock authentication, device lookup APIs, and Redis control.

Features

  • ✅ Cross-platform local login flow (tiny localhost webserver) to obtain UserId and Token
  • ✅ Ability to fetch all owned shockers and all shockers shared to you
  • ✅ Execute commands via PiShock Redis (shock, vibrate, beep, etc.)

Install

dotnet add package pishock.net

Quick Start

Login

using var login = new PiShockWebLogin();
var (userId, token) = await login.LoginAsync(); // Blocks until successful or throws TimeoutException

Console.WriteLine($"Logged in! UserId={userId}, Token={token}");

Fetch shockers (owned + shared)

using var http = new HttpClient();

var api = new PiShockApiClient(http);
var all = await api.GetAllShockersAsync(userId, token);

// Note: if you have shared your own devices, those shockers may also appear in the shared list.

Console.WriteLine($"Owned shockers:  {all.Owned.Count}");
Console.WriteLine($"Shared shockers: {all.Shared.Count}");

foreach (var s in all.Owned)
    Console.WriteLine($"[Owned]  {s.ShockerName} (ShockerId={s.ShockerId}, ClientId={s.ClientId})");

foreach (var s in all.Shared)
    Console.WriteLine($"[Shared] {s.OwnerUsername} -> {s.ShockerName} (ShockerId={s.ShockerId}, ClientId={s.ClientId}, ShareCode={s.ShareCode})");

Send a command via Redis

To send a command to your own device, specify the ClientId and ShockerId:

var redis = new PiShockRedisClient(new PiShockRedisOptions
{
    Host = "redis.pishock.com",
    Port = 6379,

    // IMPORTANT: Redis auth uses website token (from login), not API key
    UserId = userId,
    Token = token,
    Origin = "PiShock.Net"
});

await redis.ConnectAsync();

// Shock 10 intensity for 1 second
await redis.SendAsync(new PiShockCommand
{
    ClientId = all.Owned[0].ClientId,
    ShockerId = all.Owned[0].ShockerId,
    Mode = PiShockMode.Shock,
    Intensity = 10,
    DurationMs = 1000
});

To send a command to a shared device, specify the ShareCode, ClientId, and ShockerId:

await redis.SendShareCodeAsync(
    shareCode: all.Shared[0].ShareCode,
    command: new PiShockCommand
    {
        ShareCode = all.Shared[0].ShareCode,
        ClientId = all.Shared[0].ClientId,
        ShockerId = all.Shared[0].ShockerId,
        Mode = PiShockMode.Vibrate,
        Intensity = 20,
        DurationMs = 500,
    });

Notes

  • The PiShock website token expires (documentation mentions roughly two weeks). If Redis/API calls fail, log in again.
  • PiShock’s Redis API does not support API key authentication, which is why the local login webserver is required.
Product Compatible and additional computed target framework versions.
.NET net9.0 is compatible.  net9.0-android was computed.  net9.0-browser was computed.  net9.0-ios was computed.  net9.0-maccatalyst was computed.  net9.0-macos was computed.  net9.0-tvos was computed.  net9.0-windows was computed.  net10.0 was computed.  net10.0-android was computed.  net10.0-browser was computed.  net10.0-ios was computed.  net10.0-maccatalyst was computed.  net10.0-macos was computed.  net10.0-tvos was computed.  net10.0-windows was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
1.0.0 112 1/19/2026