Use the GitHub API Octokit client with Deno

2 min read

315 words

Using the GitHub API in Deno is as simple as importing the Octokit client shown in the GitHub documentation. Since Deno supports npm packages, you can easily use the Octokit client in Deno. In this short article I will show you how to use the Octokit client to get the workflow runs for a repository.

The documentation for retrieving the runs of a workflow can be found in the GitHub API documentation. The documentation shows how to use the Octokit client to get the workflow runs for a repository's workflow. The example is written in JavaScript, but can be used in Deno without any problems. It even supports Typescript types out of the box, which makes it much easier to use and find the properties you need.

For this example to work, you will need a personal GitHub token with the repo scope. You can create a token in the GitHub Settings. Copy the value to your clipboard and store it in an environment variable called GITHUB_TOKEN. This can be done either by putting it in your .bashrc/.zshrc or by prepending GITHUB_TOKEN=<your-token> to your deno run command.

Without further ado, here is the sample code to get the workflow runs for a repository's workflow:

import { Octokit } from "npm:@octokit/core";

const octokit = new Octokit({ auth: Deno.env.get("GITHUB_TOKEN") });

const OWNER = "niklasmtj";
const REPO = "deno-actions";
const WORKFLOW_ID = "ci.yml";

const response = await octokit.request(
  "GET /repos/{owner}/{repo}/actions/workflows/{workflow_id}/runs",
    owner: OWNER,
    repo: REPO,
    workflow_id: WORKFLOW_ID,
    headers: {
      "X-GitHub-Api-Version": "2022-11-28",


I hope this example helps you to get started with the GitHub API in Deno.

Thanks for reading and have a great day!