API endpoints
note
Publishing data endpoints is optional. Enabling GitHub Pages makes the generated site public, so publish only a repository whose tracked data you intend to share. For private tracking, leave Pages disabled and keep the repository private.
Base URL
The commits with your data can also include summaries for easy consumption through static JSON endpoints. Data is stored below data/. A category has an api.json index only when Stethoscope generated summaries for that category; raw-only and daily-only categories can legitimately have no api.json.
After you have enabled publishing to GitHub Pages, your repository will be available at https://username.github.io/repo/ where username is your GitHub username and repo is the name of your repository. This is your base URL.
Custom domain
You can also enable custom domains on your GitHub repository. To enable publishing with a custom domain:
- Create a new
CNAMEfile in your repository root - Enter your domain name in the file and commit it
- Set GitHub Pages' DNS records for your domain
For more information, including a list of DNS records, read the following article on the GitHub website: Configuring a custom domain for your GitHub Pages site.
API
Each integration has its own API. For example, time tracking from RescueTime is available at https://username.github.io/repo/data/rescuetime-time-tracking/api.json. As an example, the template repository's RescueTime data is available at https://stethoscope-js.github.io/stethoscope/data/rescuetime-time-tracking/api.json.
The JSON response of this endpoint is:
In this example, RescueTime has tracked the top categories for the months 01 to 04 in 2020 (January to April), and the week numbers 1 to 3.
Fetching data
In the above example, the keys under top-overview are days, months, weeks, and years. If you want to access a yearly summary, you have to visit years.json like so:
The structure of this URL is, after your base URL:
data(the directory for data)rescuetime-time-tracking(the name of the integration data point)summarytop-overview(the name of the key to access)years.json(the endpoint to access)
The response for this URL will be the yearly RescueTime top activities:
Similarly, each integration data point has its own summary for all the time periods โ years, months, weeks, and days.
Some integrations that don't have multiple keys don't require that additional parameter in the URL. For example, the URL for the Wakatime API is https://stethoscope-js.github.io/stethoscope/data/wakatime-time-tracking/api.json. Its response does not have any additional keys, just the time periods:
Likewise, its years.json endpoint is https://stethoscope-js.github.io/stethoscope/data/wakatime-time-tracking/summary/years.json. The response is:
Latest-run manifest
The current Stethoscope action also writes an additive v3 run manifest at:
When GitHub Pages is enabled, its public URL is:
This file describes the latest action run. It contains:
format, currently3generatedAt, the run timestampgenerator, with the action version, integrations version, and source commitadapters, with asucceeded,skipped, orfailedoutcome for every adapterv2Files, a map of v2 files changed by that run to their SHA-256 hashes
The manifest is an audit aid, not a replacement for existing v2 data URLs. It does not contain provider error messages, credentials, response bodies, or account identifiers, and it is overwritten by the next run rather than kept as a historical log.
note
The manifest lives in a dot-prefixed directory. Repositories created from the current template include an empty .nojekyll file so GitHub Pages publishes that path. Existing repositories should add the same empty file at the repository root if the manifest URL returns 404 while non-dot data/ URLs work.
Rate limits
Since we're using GitHub Pages to publish your API, you have to respect their usage limits. In most cases, you will not have a problem, but it's good to know (source):
- There are no rate limits on using these JSON endpoints
- Published site may be no larger than 1 GB in size
- Soft bandwidth limit of 100 GB per month
- Soft limit of 10 builds per hour