Welcome! This repository provides Power Query M scripts to easily fetch data directly from the Exercism.org API. This allows you to pull information about language tracks and their exercises into environments like Excel or Power BI for analysis, reporting, or track maintenance.
This collection currently focuses on the following core scripts:
ExercismAPIToken.pq
: A parameter query to securely store your Exercism API token.ExercismTracks.pq
: A query that retrieves a comprehensive list of all language tracks available on Exercism.GetTrackExercises.pq
: A function that fetches all exercises for a specified language track.
These scripts are designed to be robust, including basic error handling for API connectivity and JSON parsing. Both ExercismTracks.pq
and GetTrackExercises.pq
can optionally use the ExercismAPIToken
for authenticated API requests.
- File:
powerquery/ExercismAPIToken.pq
- Type: Parameter Query
- Description: Defines a Power Query parameter to securely store your personal Exercism API token. This allows other queries to make authenticated requests to the Exercism API.
- How to Obtain Your Token:
- Log in to Exercism.org.
- Click the three-dot menu (top right) -> "Settings".
- Select "API / CLI Token" and copy your token.
- Usage:
- Import
ExercismAPIToken.pq
into Power Query (see Setup). - Rename the imported query to
ExercismAPIToken
. - Edit the query and replace the placeholder
"put your Exercism API Token here"
with your actual token.
- Import
- File:
powerquery/ExercismTracks.pq
- Type: Query (Self-executing when loaded)
- Description: Fetches a list of all language tracks from the Exercism API. If the
ExercismAPIToken
parameter is set, it will be used for authentication. - Output Columns:
slug
(text): The unique identifier for the track (e.g., "csharp", "awk").Title
(text): The display name of the track.HasCourse
(logical):true
if the track is structured as a course.ConceptsCount
(Int64.Type): The number of concepts in the track.ExercisesCount
(Int64.Type): The number of exercises in the track.WebURL
(text): The direct URL to the track page.TagsList
(text): A comma-separated string of tags.
- Usage:
- Optionally, set up the
ExercismAPIToken
parameter first. - Import
ExercismTracks.pq
into Power Query. - Rename the query to
ExercismTracks
. It will execute automatically.
- Optionally, set up the
-
Type: Function
-
Description: Fetches a list of exercises for a specific language track. If the
ExercismAPIToken
parameter is set, it will be used for authentication, which can provide user-specific data for fields likeIsUnlocked
andIsRecommended
. -
Parameter:
trackName
(text): The slug of the track (e.g.,"bash"
,"awk"
).
-
Output Columns:
slug
(text): The exercise's unique identifier.Type
(text): The type of exercise.Title
(text): The exercise's title.Difficulty
(text): The exercise's difficulty level.Blurb
(text): A short description.IsExternal
(logical): If the exercise is external.IsUnlocked
(logical): If the exercise is unlocked (reflects user state if authenticated).IsRecommended
(logical): If the exercise is recommended (reflects user state if authenticated).
-
Usage:
- Optionally, set up the
ExercismAPIToken
parameter. - Import
GetTrackExercises.pq
and rename the query toGetTrackExercises
. - In a new query, invoke the function:
GetTrackExercises("your-track-slug")
.
- Optionally, set up the
- A Power Query compatible environment:
- Microsoft Excel (Windows or Mac)
- Power BI Desktop
- Power Query Online (Dataflows)
- Internet connectivity to reach the Exercism API (
https://exercism.org
).
- Download: Clone this repository or download the individual
.pq
files from thesrc/
directory. - Import into Power Query:
- Open your Power Query Editor.
- Excel:
Data
tab ->Get Data
->Launch Power Query Editor...
. - Power BI Desktop:
Home
tab ->Transform data
.
- Excel:
- In the Power Query Editor, create a new query:
- Right-click in the Queries pane ->
New Query
->Other Sources
->Blank Query
.
- Right-click in the Queries pane ->
- With the new blank query selected, click
Advanced Editor
on theHome
tab. - Open the downloaded
.pq
file (e.g.,ExercismAPIToken.pq
) in a text editor. - Copy the entire M code from the
.pq
file. - Paste it into the Advanced Editor, replacing any existing content.
- Click
Done
. - Rename the query to match the intended name (e.g., "ExercismAPIToken", "ExercismTracks", "GetTrackExercises"). This is crucial for them to work together correctly.
Repeat the import process for each .pq
file. It's recommended to set up ExercismAPIToken.pq
first if you plan to use authenticated requests.
For a practical example of how to use the GetTrackExercises
function to compare tracks (e.g., finding BASH exercises not yet in AWK), see:
HOW_TO_USE.md
(This guide primarily uses GetTrackExercises.pq
)
- Authenticated vs. Anonymous Requests: If
ExercismAPIToken
is not set up or empty, API calls will be anonymous. This might affect the data returned for user-specific fields likeIsUnlocked
orIsRecommended
in theGetTrackExercises
function. - API Rate Limits: Be mindful of potential API rate limits. Using an API token might provide higher limits.
- API Changes: The data returned depends on the Exercism API (v2). Future API changes might require script updates.
- Error Handling: The scripts include basic error handling. Check your internet and API status if issues persist.
Contributions, issues, and feature requests are welcome!
- Open an issue to report a bug or suggest an improvement.
- Fork the repository and submit a pull request.
This project is licensed under the MIT License. See the LICENSE file for details.