Skip to content

GitHub, WakaTime and daily.dev Activity Graphs on My Dashboard

Three activity heatmaps in green, purple and blue: GitHub contributions, articles read on daily.dev and hours coded from WakaTime

My dashboard has three of those green-square graphs you know from GitHub. One shows my GitHub contributions, one shows how many hours I coded each day (from WakaTime), and one shows how many articles I read each day on daily.dev.

They look the same because they are the same component. Only the data changes. And none of them need an API key.

GitHub contributions

Articles read on daily.dev

Hours coded, from WakaTime

Live from my dashboard, not a screenshot. Hover a square to see its day.

One shape for every graph

The trick is to turn every source into the same simple list: one item per day.

type Day = {
  date: string // "2026-11-19"
  count: number // contributions, hours or articles
  level: number // 0 to 4, how dark the square is
}

count is shown in the tooltip. level picks the colour, from empty (0) to full (4). Once a source gives me this list, the graph doesn’t care where it came from.

{ date: "2026-11-15", count: 0, level: 0 }
{ date: "2026-11-16", count: 2, level: 1 }
{ date: "2026-11-17", count: 5, level: 2 }
{ date: "2026-11-18", count: 8, level: 3 }
{ date: "2026-11-19", count: 14, level: 4 }
Five days in the shared shape and the square each one becomes. Only level decides the colour.

GitHub

GitHub’s own API needs a token for this, so I use github-contributions-api by Jonathan Gruber. It reads your public profile and gives back exactly the shape above, levels included.

export async function getContributions(): Promise<Day[]> {
  const res = await fetch("https://github-contributions-api.jogruber.de/v4/YOUR_USERNAME?y=last")
  if (!res.ok) throw new Error(`Contributions API ${res.status}`)
  return (await res.json()).contributions ?? []
}

?y=last means the last 365 days. That’s it for GitHub.

WakaTime

WakaTime has a proper API, but it needs a login. Your public WakaTime profile also has a heatmap, though, and that heatmap loads its data from a public endpoint. I found it in the browser’s dev tools.

Open your WakaTime profile, open dev tools (F12), go to the Network tab and reload. Look for a request ending in insights/days/public. The long ID in its URL is your user ID.

An illustration of what to look for (your ID will be different). Pick the request that ends in insights/days/public; the highlighted part of its URL is your user ID.

This only works if your profile is public in your WakaTime settings.

The endpoint gives the seconds coded per day. I turn them into hours, and every 3 hours is one more level.

const DAYS_URL = "https://wakatime.com/api/v1/users/YOUR_USER_ID/insights/days/public"

export async function getCodingActivity(): Promise<Day[]> {
  const res = await fetch(DAYS_URL)
  if (!res.ok) throw new Error(`WakaTime days ${res.status}`)

  const days: { date: string; total: number }[] = (await res.json())?.data?.days ?? []
  return days.map(({ date, total }) => {
    const hours = total / 3600
    return {
      date,
      count: Math.round(hours * 10) / 10, // 2.4 hours
      level: Math.min(Math.ceil(hours / 3), 4),
    }
  })
}

Level 0

0 h

Level 1

up to 3 h

Level 2

3–6 h

Level 3

6–9 h

Level 4

9 h+

Every 3 hours is one more level, so a 2.4-hour day is level 1 and anything past 9 hours is full blue.

daily.dev

daily.dev shows a reading heatmap on your profile too, and it does the same thing: the page asks daily.dev’s GraphQL API for your read history. Same dev tools trick, but this time filter the Network tab by graphql and click the requests until you find one with userReadHistory in its Payload. Your user ID is in the variables.

An illustration of what to look for (your ID will be different). Click through the graphql requests until the Payload mentions userReadHistory; the id in its variables is your user ID.

Now ask for the last year of reads. I ask for the streak in the same request, because it’s free.

const DAY = 24 * 60 * 60 * 1000

export async function getReadingActivity(): Promise<Day[]> {
  const now = Date.now()
  const res = await fetch("https://api.daily.dev/graphql", {
    method: "POST",
    headers: { "content-type": "application/json" },
    body: JSON.stringify({
      query: `query($id: ID!, $after: String!, $before: String!) {
        userReadHistory(id: $id, after: $after, before: $before) { date reads }
        userStreakProfile(id: $id) { current max total }
      }`,
      variables: {
        id: "YOUR_USER_ID",
        after: new Date(now - 371 * DAY).toISOString(),
        before: new Date(now + DAY).toISOString(),
      },
    }),
  })
  const { data } = await res.json()
  // ...
}

One catch: daily.dev only returns the days you actually read something. A graph needs every day, or the columns won’t line up. So I fill in the empty days myself:

const reads = new Map(data.userReadHistory.map(({ date, reads }) => [date.slice(0, 10), reads]))

const days = Array.from({ length: 371 }, (_, i) => {
  const date = new Date(now - (370 - i) * DAY).toISOString().slice(0, 10)
  const count = reads.get(date) ?? 0
  return { date, count, level: Math.min(Math.ceil(count / 2), 4) }
})
Six weeks of sample reads. With only the days you read, every square slides up into the wrong weekday and the latest day (ringed) lands far from the end. Filling in the empty days puts each one back on its own row.

Every 2 articles is one more level.

Level 0

0

Level 1

1–2

Level 2

3–4

Level 3

5–6

Level 4

7+

Articles read in a day and the level each count becomes.

The graph

Now the fun part. The graph is a CSS grid with 7 rows, one for each day of the week. grid-auto-flow: column fills it top to bottom, then moves to the next column, so each column is one week.

1234567891011121314151617181920212223242526272829303132333435
Each square is numbered in the order it was added. With grid-auto-flow: column, 1 to 7 fill the first column top to bottom, so every column is a week and every row is a weekday. Switch to row and the weeks fall apart.
---
const { days, color = "34, 197, 94" } = Astro.props

// Five shades of one colour, from empty to full
const LEVELS = [
  "rgba(107, 114, 128, 0.125)",
  `rgba(${color}, 0.25)`,
  `rgba(${color}, 0.5)`,
  `rgba(${color}, 0.75)`,
  `rgb(${color})`,
]

// 51 full weeks, then this week up to today
const expected = 51 * 7 + new Date().getDay() + 1
const tiles = days.slice(-expected)
---

<div class="grid w-max grid-flow-col grid-rows-7 gap-0.5">
  {tiles.map(({ date, count, level }) => (
    <div
      class="size-[9px] rounded-[2px]"
      style={{ backgroundColor: LEVELS[level] }}
      title={`${count} on ${date}`}
    />
  ))}
</div>

The expected line is the one I got wrong first. If you just take the last 365 days, the last column doesn’t end on today and the weekdays shift. Taking 51 full weeks plus the days of this week so far keeps today in the bottom-right corner, like on GitHub.

The ringed square is the latest day, a Tue. With the last 365 days, the grid starts on whatever weekday that was, so every column is shifted and the latest day always lands in the Sunday row. With 51 weeks plus this week, it sits in the last column on its own weekday.

Each graph only passes its own colour:

<Heatmap days={contributions} />
<Heatmap days={reading} color="206, 61, 243" />
<Heatmap days={coding} color="59, 130, 246" />

On my site I swapped title for one small tooltip that follows the mouse, but title works fine to start.

color="34, 197, 94"

One component, one set of sample data. Switching the colour prop is the only difference between the three graphs. Hover a square for its tooltip.

Keep it from breaking

The WakaTime and daily.dev endpoints aren’t documented. They’re what their own websites use, so they can change any day without warning. So every source gets its own try/catch, and returns an empty list when it fails:

const getCoding = async () => {
  try {
    return await getCodingActivity()
  } catch (error) {
    console.error("WakaTime failed:", error)
    return []
  }
}

When the list is empty, the graph shows “Coding graph is unavailable right now.” instead. If one API goes down, the other two graphs and the rest of the dashboard keep working.

Coding graph is unavailable right now.

Sample data. When WakaTime fails, its source returns an empty list and the graph swaps itself for one quiet line. Nothing else on the page notices.

That’s all. Three sources, one shape, one component. You can see them live on my dashboard.



© 2023-2026 Manish Tamang · RSS · GitHub

Not vibe coded: how I use AIgolecodesMade in NepalBuilt with AstroIndieWeb Camp/slash: all my slash pages
I like computer: what I useUbuntu on WSL 2: what I usePearl Jam and SoundgardenSay no to web3Say no to drugsCheck out my GitHub!