Show / Hide Table of Contents

Class Client

A Client to interact with the ntfy.sh API.

Inheritance
object
Client
Inherited Members
object.Equals(object)
object.Equals(object, object)
object.GetHashCode()
object.GetType()
object.MemberwiseClone()
object.ReferenceEquals(object, object)
object.ToString()
Namespace: ntfy
Assembly: ntfy.dll
Syntax
public class Client

Constructors

| Improve this Doc View Source

Client(string?)

Constructs a new Client.

Declaration
public Client(string? serverUrl = null)
Parameters
Type Name Description
string serverUrl

The base URL of the ntfy.sh server.

Methods

| Improve this Doc View Source

ChangeUserPassword(User, string, string)

Declaration
public Task<bool> ChangeUserPassword(User user, string oldPassword, string newPassword)
Parameters
Type Name Description
User user
string oldPassword
string newPassword
Returns
Type Description
Task<bool>
| Improve this Doc View Source

CheckAuthentication(string, User?)

Check if the provided user is authorized to access the provided topic. If not user is provided, check if the provided topic is anonymously accessible.

Declaration
public Task<bool> CheckAuthentication(string topic, User? user = null)
Parameters
Type Name Description
string topic

Topic the user is attempting to access.

User user

Optional specific user attempting to access the topic.

Returns
Type Description
Task<bool>

true if the topic is accessible, false otherwise.

Exceptions
Type Condition
UnexpectedException

An unexpected HTTP status code was encountered during the request.

| Improve this Doc View Source

DeleteUserToken(string)

Declaration
public Task<bool> DeleteUserToken(string token)
Parameters
Type Name Description
string token
Returns
Type Description
Task<bool>
| Improve this Doc View Source

ExtendUserToken(User)

Declaration
public Task<bool> ExtendUserToken(User user)
Parameters
Type Name Description
User user
Returns
Type Description
Task<bool>
| Improve this Doc View Source

GenerateUserToken(User)

Declaration
public Task<UserTokenDetails> GenerateUserToken(User user)
Parameters
Type Name Description
User user
Returns
Type Description
Task<UserTokenDetails>
| Improve this Doc View Source

GetAttachmentAllowance(User?)

Get the total storage allowance for attachments, in bytes.

Declaration
public Task<long> GetAttachmentAllowance(User? user = null)
Parameters
Type Name Description
User user

Optional specific user to check the allowance for.

Returns
Type Description
Task<long>

The max amount of bytes of attachments the user can upload to the server.

| Improve this Doc View Source

GetAttachmentAllowanceRemaining(User?)

Get the remaining storage allowance for attachments, in bytes.

Declaration
public Task<long> GetAttachmentAllowanceRemaining(User? user = null)
Parameters
Type Name Description
User user

Optional specific user to check the allowance for.

Returns
Type Description
Task<long>

The remaining amount of bytes of attachments the specific user can upload to the server.

| Improve this Doc View Source

GetAttachmentAllowanceUsed(User?)

Get the user storage allowance for attachments, in bytes.

Declaration
public Task<long> GetAttachmentAllowanceUsed(User? user = null)
Parameters
Type Name Description
User user

Optional specific user to check the allowance for.

Returns
Type Description
Task<long>

The amount of bytes of attachments the specific user has previously uploaded to the server.

| Improve this Doc View Source

GetAttachmentSizeByteLimit(User?)

Get the maximum allowed file size for an attachment, in bytes.

Declaration
public Task<long> GetAttachmentSizeByteLimit(User? user = null)
Parameters
Type Name Description
User user

Optional specific user to check the allowance for.

Returns
Type Description
Task<long>

The maximum allowed file size for an attachment, in bytes.

| Improve this Doc View Source

GetServerHealthInfo()

Get health information about the server.

Declaration
public Task<ServerHealth> GetServerHealthInfo()
Returns
Type Description
Task<ServerHealth>

Health information about the server.

| Improve this Doc View Source

GetServerInfo()

Get information about the server.

Declaration
public Task<ServerInfo> GetServerInfo()
Returns
Type Description
Task<ServerInfo>

Information about the server.

| Improve this Doc View Source

GetUserInfo(User?)

Get information about the provided user. Get server-wide information if no user is provided.

Declaration
public Task<UserInfo> GetUserInfo(User? user = null)
Parameters
Type Name Description
User user

Optional user to get information for.

Returns
Type Description
Task<UserInfo>

Information about the specific user, or server-wide information if no user is provided.

| Improve this Doc View Source

GetUserLimits(User?)

Get limits about the provided user. Get server-wide limits if no user is provided.

Declaration
public Task<UserLimits> GetUserLimits(User? user = null)
Parameters
Type Name Description
User user

Optional user to get limits for.

Returns
Type Description
Task<UserLimits>

Limits about the specific user, or server-wide limits if no user is provided.

| Improve this Doc View Source

GetUserStats(User?)

Get stats about the provided user. Get server-wide stats if no user is provided.

Declaration
public Task<UserStats> GetUserStats(User? user = null)
Parameters
Type Name Description
User user

Optional user to get stats for.

Returns
Type Description
Task<UserStats>

Stats about the specific user, or server-wide stats if no user is provided.

| Improve this Doc View Source

IsAttachmentOfSizeAllowed(User, long)

Check if the provided attachment size can be uploaded by the provided user.

Declaration
public Task<bool> IsAttachmentOfSizeAllowed(User user, long size)
Parameters
Type Name Description
User user

User attempting to upload an attachment.

long size

Size of the attempted attachment.

Returns
Type Description
Task<bool>

true if the provided user can upload the attachment, false otherwise.

| Improve this Doc View Source

Poll(IEnumerable<string>, Since?, bool, ReceptionFilters?, User?)

Poll the server for new messages.

Declaration
public Task<List<ReceivedMessage>> Poll(IEnumerable<string> topics, Since? since = null, bool getScheduledMessages = false, ReceptionFilters? filters = null, User? user = null)
Parameters
Type Name Description
IEnumerable<string> topics

A list of topics to poll messages for.

Since since

Optional since filter to use when polling.

bool getScheduledMessages

Whether to get messages scheduled for the future. Defaults to false.

ReceptionFilters filters

Optional additional filters to use when polling.

User user

Optional user to use when polling.

Returns
Type Description
Task<List<ReceivedMessage>>

A list of all filtered ReceivedMessage objects.

| Improve this Doc View Source

Publish(string, SendingMessage, User?)

Publish a message to the server.

Declaration
public Task Publish(string topic, SendingMessage message, User? user = null)
Parameters
Type Name Description
string topic

Topic to publish the message to.

SendingMessage message

SendingMessage message to publish.

User user

Optional user to use when publishing.

Returns
Type Description
Task
Exceptions
Type Condition
UnauthorizedException

Provided user is unauthorized to publish to the topic.

EntityTooLargeException

Provided SendingMessage payload is too large to publish.

TooManyRequestsException

Server is rate-limiting due to too many requests.

UnexpectedException

An unexpected HTTP status code was encountered during the request.

| Improve this Doc View Source

ReserveTopic(User, string, Permission)

Declaration
public Task<bool> ReserveTopic(User user, string topic, Permission permissionForOthers)
Parameters
Type Name Description
User user
string topic
Permission permissionForOthers
Returns
Type Description
Task<bool>
| Improve this Doc View Source

SignUp(string, string)

Declaration
public Task<User> SignUp(string username, string password)
Parameters
Type Name Description
string username
string password
Returns
Type Description
Task<User>
| Improve this Doc View Source

Subscribe(IEnumerable<string>, Since?, bool, ReceptionFilters?, User?, CancellationToken?, bool)

Subscribe to a topic. Opens an asynchronous stream to the server and returns an IAsyncEnumerable of ReceivedMessage objects. New messages will be pushed to the stream as they are received.

Declaration
public IAsyncEnumerable<ReceivedMessage> Subscribe(IEnumerable<string> topics, Since? since = null, bool getScheduledMessages = false, ReceptionFilters? filters = null, User? user = null, CancellationToken? cancellationToken = null, bool ignoreKeepAlive = true)
Parameters
Type Name Description
IEnumerable<string> topics

List of topics to subscribe to.

Since since

Optional since filter to use when polling.

bool getScheduledMessages

Whether to get messages scheduled for the future. Defaults to false.

ReceptionFilters filters

Optional additional filters to use when polling.

User user

Optional user to use when polling.

CancellationToken? cancellationToken

Optional cancellation token to use to cancel the stream.

bool ignoreKeepAlive

Ignore keepalive messages. Defaults to true.

Returns
Type Description
IAsyncEnumerable<ReceivedMessage>

An IAsyncEnumerable of ReceivedMessage objects.

| Improve this Doc View Source

SubscribeAndProcess(IEnumerable<string>, Func<ReceivedMessage, Task>, Since?, bool, ReceptionFilters?, User?, CancellationToken?, bool)

Subscribe to a topic. Opens an asynchronous stream to the server and processes each ReceivedMessage object as it is received.

Declaration
public Task SubscribeAndProcess(IEnumerable<string> topics, Func<ReceivedMessage, Task> onNotification, Since? since = null, bool getScheduledMessages = false, ReceptionFilters? filters = null, User? user = null, CancellationToken? cancellationToken = null, bool ignoreKeepAlive = true)
Parameters
Type Name Description
IEnumerable<string> topics

List of topics to subscribe to.

Func<ReceivedMessage, Task> onNotification

Function to execute when a new message is received.

Since since

Optional since filter to use when polling.

bool getScheduledMessages

Whether to get messages scheduled for the future. Defaults to false.

ReceptionFilters filters

Optional additional filters to use when polling.

User user

Optional user to use when polling.

CancellationToken? cancellationToken

Optional cancellation token to use to cancel the stream.

bool ignoreKeepAlive

Ignore (do not process) keepalive messages. Defaults to true.

Returns
Type Description
Task
  • Improve this Doc
  • View Source
In This Article
Back to top Generated by DocFX