npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

gatsby-source-codestats

v1.0.0

Published

Plugin that uses codestats API for getting a users stats as gatsby nodes

Downloads

12

Readme

Description

This is a simple plugin that allows you to pull stats from the profile API of CodeStats.

The plugin hits the profile endpoint and converts the returned JSON into language, date, and machine nodes which can be accessed via GraphQL. The plugin also creates a user node allowing for multiple queries to be made fetching a number of users, with the user being linked to the languages, dates, and machines.

How to install

To install the plugin run npm i gatsby-source-codestats.

How to use

module.exports = {
    plugins: [
        {
            resolve: `gatsby-source-codestats`,
            options: {
                user: "USERNAME", // Required, defines the user to pull stats from the codestats API for
            }
        }
    ]
}

Available options

The plugin only takes one option, user, which is required. This defines the user that will be sent to the CodeStats API to pull stats for.

When do I use this plugin?

This plugin is useful for when you want to pull stats from CodeStats and have them available for use in your Gatsby site at build time. In most cases you will want to fetch these stats from the API with the page load, this plugin provides a way to fetch the stats at build time for the static generation of a page and then replace these with more up-to-date stats when a user loads the page.

Examples of usage

Queries

const languageStats = useStaticQuery(graphql`
    query {
        allCodeStatsMachine {
            nodes {
            new_xps
            name
            xps
            }
        }
        allCodeStatsUser {
            nodes {
            name
            newXp
            totalXp
            }
        }
        allCodeStatsLanguage {
            nodes {
            name
            new_xps
            xps
            }
        }
        allCodeStatsDate {
            nodes {
            xps
            dateObj
            date
            }
        }
    }
  `)

The above query returns a JSON object for use similar to the following:

{
  "data": {
    "allCodeStatsMachine": {
      "nodes": [
        {
          "new_xps": 0,
          "name": "Work",
          "xps": 1467991
        },
        {
          "new_xps": 4912,
          "name": "Home PC",
          "xps": 490476
        }
      ]
    },
    "allCodeStatsUser": {
      "nodes": [
        {
          "name": "USERNAME",
          "newXp": 4912,
          "totalXp": 1958467
        }
      ]
    },
    "allCodeStatsLanguage": {
      "nodes": [
        {
          "name": "JavaScript",
          "new_xps": 908,
          "xps": 675279
        }
      ]
    },
    "allCodeStatsDate": {
      "nodes": [
        {
          "xps": 1449,
          "dateObj": "2020-03-11T00:00:00.000Z",
          "date": "2020-03-11"
        }
      ]
    }
  },
  "extensions": {}
}

How to contribute

If you have any questions or run into any issues feel free to raise an issue/bug in this plugins git repo