API endpoints
note
Having publicly-visible API endpoints is optional. API endpoints only work after you have enabled GitHub Pages and have a public repository or a private repository with a Pro plan.
Base URL
The commits with your data also summarize it for easy consumption through an API. The data
directory contains a list of integrations, and each of them has a api.json
file.
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
CNAME
file 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)summary
top-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:
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