# YourTraffic > Open-source, privacy-first web analytics. Track unlimited websites and read your stats over a simple REST API. No cookies, no personal data, no consent banners. Every project has its own api key, shown under Settings in the dashboard. Pass it as a Bearer token to read that project's stats. Stats cover visitors (unique per day) and pageviews, with breakdowns by page, referrer, country, browser and device. ## Install the tracking script Add one line to the of every page you want to track. That is the whole setup. The script is a few hundred bytes, sets no cookies, reads no storage and needs no config. It sends one beacon per pageview and follows client-side navigation on single-page apps on its own. The script posts events to https://yourtraffic.dev/api/event on the same origin it was loaded from, so the self-hosted build works with no changes. Events from localhost, 127.0.0.1 and file:// pages are ignored, so local development does not pollute your stats. Add a new website in the dashboard first, then drop the snippet in and stats appear within seconds of the first real visit. ## REST API - [Stats endpoint](https://yourtraffic.dev/api/v1/stats): GET request, returns JSON. Authorize with the header "Authorization: Bearer YOUR_API_KEY". - [Health check](https://yourtraffic.dev/api/health): GET request, no auth, returns service status. ### Query parameters for the stats endpoint - period. One of 24h, 7d, 30d, 12mo. Defaults to 7d. - group. Bucket size for the time series. One of hour, day, week, month. Chosen automatically from the period when omitted. - by. A breakdown dimension, or a comma list of them. One or more of page, referrer, country, browser, device. ### Response shape A JSON object with these fields. - site. The project domain. - period. The period you asked for. - totals. An object with visitors and pageviews counts. - series. An array of buckets, each with date, visitors and pageviews. - breakdown. Present when you pass a single by value. An array of rows, each with name, visitors and pageviews, ordered by pageviews. ### Example curl "https://yourtraffic.dev/api/v1/stats?period=30d&by=page" -H "Authorization: Bearer yt_live_..." ## MCP server An MCP (Model Context Protocol) server lets agents read your stats natively. Point an MCP client at https://yourtraffic.dev/mcp. Auth is OAuth, not the api key. The endpoint advertises its authorization server, so a client registers itself and opens a browser for you to sign in. Once you approve, the agent can only see the websites on your account. Tools: - list_websites. Lists the websites on your account, each with its name and domain. - get_stats. Returns stats for one website. Takes site (the domain), an optional period (24h, 7d, 30d, 12mo) and an optional by breakdown (page, referrer, country, browser, device). ## More - [Dashboard](https://yourtraffic.dev): sign in to add websites and find your api keys. - [Source code](https://github.com/kozmos-tech/yourtraffic): the full project on GitHub.