Get the requested page's views or unique visitors from Plausible Analytics
Find a file
sangelo a18735f874
All checks were successful
Build and Push Docker Image / docker-build (push) Successful in 1m55s
[a] add license
2024-12-12 10:14:15 +00:00
.forgejo/workflows [c] set registry and image name statically 2024-10-21 16:00:28 +02:00
.env.example [c] change default port in env example 2024-10-21 20:33:19 +00:00
.gitignore Initial Commit 2024-10-21 15:13:13 +02:00
compose.yml [a] add metrics port export to Dockerfile 2024-10-21 16:13:39 +02:00
Dockerfile [c] bugfix a brainfart 2024-10-21 16:57:02 +02:00
LICENSE [a] add license 2024-12-12 10:14:15 +00:00
main.js [a] add proxy trust num 2024-10-21 17:35:04 +02:00
package.json Initial Commit 2024-10-21 15:13:13 +02:00
README.md [c] change default port in readme env example 2024-10-21 20:33:51 +00:00
yarn.lock Initial Commit 2024-10-21 15:13:13 +02:00

plausible-pageviews-api

Get the requested page's views or unique visitors from Plausible Analytics.

Configuration in .env

PORT=3000 # the api port
METRICS_PORT=3001 # the port on which prometheus metrics are hosted on, endpoint: /metrics
PLAUSIBLE_DOMAIN=plausible.io # the plausible instance domain
PLAUSIBLE_API_KEY="api_key_goes_here" # your plausible API key
ALLOWED_ORIGINS="https://example.com" # allowed CORS origins
RATE_LIMIT_MINUTES=15 # the amount of time in minutes to rate limit
RATE_LIMIT_REQUESTS=100 # amount of max. requests
NUM_PROXY_TRUST=1 # amount of proxies to trust, set 0 to disable

Don't change the PORT and METRICS_PORT values when running in a Docker Container. Instead, export a different port and forward that to the container's ports 3000 and 3001 for the main API port and the metrics port respectively.

# example for docker-compose.yml:
ports:
  - "5678:3000"
  - "6789:3001"

You also have to mount the .env file inside the container, if you're using Docker:

volumes:
  - .env:/app/.env

Run the API

$ yarn install
$ yarn start