Skip to main content

WebEvent Count Endpoints

These are the endpoints for managing your Web Events

Base URL: https://web-counter.azurewebsites.net

Increment a WebEvent Count

Increments the counter for the specified Web Event and Web Page combination

info

The endpoint below will not require adding a X-API-Key Header to allow easily incrementing counts from your Front-End Application and keep the API Key secure.

URL: /api/webevent/count

Method: PUT

Content Type: application/json

Request Body

{
"eventName": "Page Visit",
"pathname": "/",
"hostname": "riddlelink.com"
}

Example Requests

const response = await fetch("https://web-counter.azurewebsites.net/api/webevent/count", {
method: "PUT",
headers: {
"Content-Type": "application/json",
},
body: JSON.stringify({
eventName: "Page Visit",
pathname: "/",
hostname: "riddlelink.com",
}),
});

Example Responses

A Status 200 is returned when the entry was incremented - the count will always be greater than 0

{
"hostname": "string",
"pathname": "string",
"eventName": "string",
"count": 1,
"date": "2023-10-18T23:42:28.808Z"
}

Retrieve Today's Count

Get a Web Event Count for Today's Date

URL: /api/webevent/count

Method: GET

Request Parameters

Headers

X-API-Key: YOUR_API_KEY_GOES_HERE

Request Query Paramters

eventname: Event Name

pathname: Pathname

Example Requests

const response = await fetch(
"https://web-counter.azurewebsites.net/api/webevent/count?" +
new URLSearchParams({
eventname: "EVENT_NAME",
pathname: "PATH_NAME",
}),
{
method: "GET",
headers: {
"Content-Type": "application/json",
},
}
);

Example Responses

{
"hostname": "string",
"pathname": "string",
"eventName": "string",
"count": 0,
"date": "2023-10-20T02:55:09.466Z"
}

Retrieve All Counts

Get a Web Event Count Lifetime Counts

URL: /api/webevent/counts

Method: GET

Request Parameters

Headers

X-API-Key: YOUR_API_KEY_GOES_HERE

Request Query Paramters

eventname: Event Name

pathname: Pathname

Example Requests

const response = await fetch(
"https://web-counter.azurewebsites.net/api/webevent/counts?" +
new URLSearchParams({
eventname: "EVENT_NAME",
pathname: "PATH_NAME",
}),
{
method: "GET",
headers: {
"Content-Type": "application/json",
},
}
);

Example Responses

[
{
"hostname": "string",
"pathname": "string",
"eventName": "string",
"count": 1,
"date": "2023-10-20T03:27:50.456Z"
}
]