Try it with: https://api.opennotification.org for free!
A simple real-time notification service built with ASP.NET Core and WebSockets. It allows clients to subscribe to a specific channel using a GUID and receive notifications sent to that channel.
- .NET 8.0 SDK or later
- Clone the repository.
- Navigate to the project directory
OpenNotification-API
. - Run the application using the .NET CLI:
dotnet run
The API will be running on http://localhost:5193.
Clients must connect to the WebSocket endpoint to subscribe to a notification channel.
Endpoint:
GET /ws/{guid}
URL Parameter:
guid
(string, required): A unique identifier for the notification channel.
Example URL:
ws://localhost:5193/ws/123e4567-e89b-12d3-a456-426614174000
Once connected, the client will receive notifications sent to this GUID.
Send a POST request to this endpoint to push a notification to all clients subscribed to a specific GUID.
Endpoint:
POST /notification
Body (JSON):
{
"guid": "string (required)",
"title": "string (required)",
"description": "string (optional)",
"pictureLink": "string (optional)",
"icon": "string (optional)",
"actionLink": "string (optional)",
"isAlert": "bool (optional, false)"
}
Example Request:
POST /notification HTTP/1.1
Host: localhost:5193
Content-Type: application/json
{
"guid": "123e4567-e89b-12d3-a456-426614174000",
"title": "New Update",
"description": "Version 2.0 is now available.",
"pictureLink": "https://example.com/banner.png",
"icon": "https://example.com/icon.png",
"actionLink": "https://example.com/update/2.0",
"isAlert": true
}
Success Response (200 OK):
{
"guid": "123e4567-e89b-12d3-a456-426614174000",
"title": "New Update",
"description": "Version 2.0 is now available.",
"pictureLink": "https://example.com/banner.png",
"icon": "https://example.com/icon.png",
"actionLink": "https://example.com/update/2.0",
"isAlert": true
}