gjbae1212 / hit-counter

:rocket: Easy way to know how many visitors are viewing your Github, Website, Notion. :tada:
https://hits.seeyoufarm.com
GNU General Public License v3.0
1.05k stars 87 forks source link

Solved: How to Query Raw Counts from Command Line #38

Open JamesDBartlett3 opened 1 year ago

JamesDBartlett3 commented 1 year ago

Here's how you can retrieve the raw count data from the command line using PowerShell:

$response = Invoke-WebRequest -Uri "https://hits.seeyoufarm.com/api/count/keep/badge.svg?url=https://your-website.com"
$content = $response.Content
$counts = ($content | Select-String -Pattern "[0-9]+ / [0-9]+" -All).Matches[0].Value
Write-Host "Counts: $counts"

image

The history graph data can be queried in a similar fashion using this endpoint: https://hits.seeyoufarm.com/api/count/graph/dailyhits.svg?url=https://your-website.com You'll need to do a lot of RegEx parsing to pull the historical data out of the SVG code, but the general principle is the same as my prior example above.