Get started with a free 7-day trial on our Startup plan.

start trial

PushRadar and .NET

The latest version of PushRadar's API is v2, released July 5, 2019.

Welcome to PushRadar's API documentation for .NET. This article covers calling the various methods of the PushRadar object to publish messages to a channel in realtime.


PushRadar's .NET library supports .NET Standard 2+.

You will need to install the latest version of the PushRadar NuGet package in order to use the library.

(server)"Hello World!" example

The following example, written in C#, demonstrates broadcasting a "Hello World!" message on a channel called test-channel. Replace your-secret-key with your actual PushRadar secret, which may be obtained from the API page of your dashboard.

  • .NET
var radar = new PushRadar.PushRadar("your-secret-key");
radar.AddDataItem("message", "Hello World!").Broadcast("test-channel");
(client)Receiving messages

To find out how to receive messages by subscribing to channels, check out the documentation for our JavaScript client library.

(tip)Adding multiple data items

For convenience, PushRadar's .NET library supports a fluent syntax to structure broadcasts. To add multiple data items, you can do either of the following:

  • .NET
// ... var radar = new PushRadar.PushRadar(...);
radar.AddDataItem("message", "Hello World!").AddDataItem("item-2", "It's me!")

// --- or ---

    new KeyValuePair<string, object>("message", "Hello World!"),
    new KeyValuePair<string, object>("item-2", "It's me!")
(security)Private channels

PushRadar supports private channels, which allow you to ensure that certain channels are only subscribed to by certain users.

The process is as follows. First you must set up an authentication endpoint, a URL that PushRadar will call to authenticate users when they subscribe to a channel. From this endpoint, you will need to check whether the user is allowed to subscribe to the desired channel. If they are, the endpoint should return an authentication token which can be generated using the ChannelAuth method.

The final step is to register your authentication endpoint using the JavaScript client library.

Note:   Private channels must start with the prefix "private-"

Here is some code showing the whole process:

  • .NET
var radar = new PushRadar.PushRadar("your-secret-key");

// Get request query parameter "channel" and determine whether the user can join it
var channel = ...

// ... if they can, return the auth token
return JsonConvert.SerializeObject(new Dictionary<string, string>() {
    { "authToken", radar.ChannelAuth(channel) }

Lastly, register your authentication endpoint URL using the JavaScript client library:

  • JavaScript
var radar = new PushRadar("your-api-key");