-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathCount_API_Cheatsheet
More file actions
30 lines (17 loc) · 847 Bytes
/
Count_API_Cheatsheet
File metadata and controls
30 lines (17 loc) · 847 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
# Count API #
1. Set up your HTML,CSS and javascript
In index.html => <h1> Page visits - <span id="visits"> .</span></h1>
2. Create a namespace
on browser: https://api.countapi.xyz/create?namespace={name of your website}&enable_reset=1
sitename: suraj.com -> namespace: suraj.com
3. Add this script at the top of your index.html file
<script async src="https://api.countapi.xyz/hit/mysite.com/key?callback=websiteVisits"></script>
4. Add this function in your script.js file
function websiteVisits(response) {
document.querySelector("#visits").textContent = response.value;
}
*Bonus*
5. Reset the value of your key
https://api.countapi.xyz/set/{namespace}/{key}?value={whatever you want , most likely 0}
6. View the current value of your key
https://api.countapi.xyz/get/{namespace}/{key}