Rudder

Rudder SDK packages

build.rudder.sdk (1.1.0)

Published 2026-10-29 17:34:27 +01:00 by edmand46

Installation

registry=https://hub.rudder.build/api/packages/rudder/npm/
npm install build.rudder.sdk@1.1.0
"build.rudder.sdk": "1.1.0"

About this package

Rudder for C#

The game client of Rudder for Unity (WebGL included) and .NET. It signs a device in and calls the functions of the modules of a project through a typed client generated for that project. It has no dependencies.

Install

  • Unity 6: add the Rudder registry and the package to Packages/manifest.json. Requests go through UnityWebRequest.

    {
      "scopedRegistries": [
        { "name": "Rudder", "url": "https://hub.rudder.build/api/packages/rudder/npm/", "scopes": ["build.rudder"] }
      ],
      "dependencies": {
        "build.rudder.sdk": "1.0.0"
      }
    }
    
  • .NET: reference Rudder.Sdk.csproj of the package (.NET Standard 2.1). Requests go through HttpClient.

Generate the client

In a repository where rudder project use chose the project:

rudder client generate --lang csharp --output Assets/Rudder/Rudder.g.cs \
  --game-address https://api.rudder.build [--environment staging|prod] [--namespace Game]

The client follows the newest release of the environment, staging by default: the class Rudder with a property per module, a method per function a game client may call (functions marked server are left out), and the types of their arguments and results in the namespace <namespace>.<Module>. Generate it again when a release changes them.

Use

using Game;
using Game.Stores;

var rudder = await Rudder.SignInDevice(sdkKey, deviceId);
var stores = await rudder.Stores.Stores();
await rudder.Stores.Buy(new BuyArguments { Offer = "pumpkin-pack" });
var balances = await rudder.Session.Wallet();

SignInDevice takes Options: Address (required when the client was generated without --game-address), Attempts, Transport and the Nickname, Avatar, Language and Region of the player.

  • Errors. A refused call throws RudderException with the Code, Message and HTTP Status of the answer: a code the module declares (such as limit_reached) or one of Rudder (such as player_banned, idempotency_key_reused or rate_limited).
  • Retries. A request that got no answer or the answer try_again is sent again after the Retry-After it gave or a short backoff, at most Attempts times (5). A mutation keeps its Idempotency-Key across them, so it runs once. Pass your own key, such as the id of a purchase, to keep that promise across restarts: new MutationOptions { IdempotencyKey = ... }.
  • Session. The access token stays in memory; when it expires the device signs in again.
  • Types. An optional field is null when missing. A value of an enum is a string, with its values as constants of a class of the same name. A field named like its type gets the suffix Value. JSON is read and written without reflection, so the client runs under IL2CPP.
  • Transport. ITransport sends the requests and waits between attempts; replace it to route or observe them.
Details
npm
2026-10-29 17:34:27 +01:00
1
Rudder
9.2 KiB
Assets (1)
Versions (4) View all
1.2.0 2026-11-01
1.1.0 2026-10-29
1.0.1 2026-10-29
1.0.0 2026-10-28