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
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
- JavaScript
- cURL
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",
}),
});
curl -X 'POST' \
'https://web-counter.azurewebsites.net/api/webevent/count' \
-H 'accept: application/json' \
-H 'Content-Type: application/json' \
-d '{
"eventName": "Page Visit",
"pathname": "/",
"hostname": "riddlelink.com"
}'
Example Responses
- 200 OK
- 201 Created
- 400 Bad Request
- 401 Unauthorized
- 409 Conflict
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"
}
A Status 201 is returned on the initial entry creation for the current day - the count will always be 0 in this situation.
{
"hostname": "string",
"pathname": "string",
"eventName": "string",
"count": 0,
"date": "2023-10-18T23:42:28.808Z"
}
{
"type": "string",
"title": "string",
"status": 0,
"detail": "string",
"instance": "string",
"errors": {
"additionalProp1": ["string"],
"additionalProp2": ["string"],
"additionalProp3": ["string"]
},
"additionalProp1": "string",
"additionalProp2": "string",
"additionalProp3": "string"
}
{
"type": "https://tools.ietf.org/html/rfc7235#section-3.1",
"title": "Invalid API Key",
"status": 401,
"detail": "The provided API Key was invalid. Please check your API Key and try again.",
"instance": "/api/webevent"
}
{
"type": "application/json",
"title": "Duplicate",
"status": 409,
"detail": "WebEvent already exists.",
"instance": "/api/webevent/"
}
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
- JavaScript
- cURL
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",
},
}
);
curl -X 'GET' \
--location 'https://web-counter.azurewebsites.net/api/webevent/count?eventname=Page%20Visit&pathname=%2F' \
--header 'X-API-Key: OdL1EqH6qsyv0JUMkq1URwTDebOUPZFG'
Example Responses
- 200 Success
- 400 Bad Request
- 401 Unauthorized
- 404 Not Found
{
"hostname": "string",
"pathname": "string",
"eventName": "string",
"count": 0,
"date": "2023-10-20T02:55:09.466Z"
}
{
"type": "string",
"title": "string",
"status": 0,
"detail": "string",
"instance": "string",
"errors": {
"additionalProp1": ["string"],
"additionalProp2": ["string"],
"additionalProp3": ["string"]
},
"additionalProp1": "string",
"additionalProp2": "string",
"additionalProp3": "string"
}
{
"type": "https://tools.ietf.org/html/rfc7235#section-3.1",
"title": "Invalid API Key",
"status": 401,
"detail": "The provided API Key was invalid. Please check your API Key and try again.",
"instance": "/api/webevent"
}
{
"type": "string",
"title": "string",
"status": 0,
"detail": "string",
"instance": "string",
"additionalProp1": "string",
"additionalProp2": "string",
"additionalProp3": "string"
}
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
- JavaScript
- cURL
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",
},
}
);
curl -X 'GET' \
--location 'https://web-counter.azurewebsites.net/api/webevent/counts?eventname=Page%20Visit&pathname=%2F' \
--header 'X-API-Key: OdL1EqH6qsyv0JUMkq1URwTDebOUPZFG'
Example Responses
- 200 Success
- 400 Bad Request
- 401 Unauthorized
[
{
"hostname": "string",
"pathname": "string",
"eventName": "string",
"count": 1,
"date": "2023-10-20T03:27:50.456Z"
}
]
{
"type": "string",
"title": "string",
"status": 0,
"detail": "string",
"instance": "string",
"errors": {
"additionalProp1": ["string"],
"additionalProp2": ["string"],
"additionalProp3": ["string"]
},
"additionalProp1": "string",
"additionalProp2": "string",
"additionalProp3": "string"
}
{
"type": "https://tools.ietf.org/html/rfc7235#section-3.1",
"title": "Invalid API Key",
"status": 401,
"detail": "The provided API Key was invalid. Please check your API Key and try again.",
"instance": "/api/webevent"
}