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 🙏

© 2024 – Pkg Stats / Ryan Hefner

untappd-graphql

v1.4.0

Published

GraphQL for the Untappd API

Downloads

20

Readme

GraphQL for the Untappd API

npm install untappd-graphql

Features

  • a GraphQL server that delegates to the Untappd API
  • optional caching of Untappd API results
  • exports for use in your own project

Prerequisites

You will need an approved Untappd API app and the following information from the app's settings:

  • Client ID
  • Client Secret

API Endpoints Implemented

The following are currently implemented. If you'd like to see others, please add an issue (or, even better, submit a PR that implements them).

Queries

Info / Search

  • Brewery Search - (brewerySearch)
  • A convenience query, brewerySearchInflated, provides the results of brewerySearch inflated with breweryInfo for each brewery returned by brewerySearch. Since this requires an API call for every brewery you should use caching if using this.
  • Brewery Info - (breweryInfo)

Running the GraphQL server

Configuration

The following environment variables must be set:

  • UNTAPPD_CLIENT_ID: the Client ID from your Untappd app
  • UNTAPPD_CLIENT_SECRET: the Client Secret from your Untappd app

Running the Example Server

DEBUG=* npm start

This will run the /graphql endpoint on localhost on the PORT environment variable, if defined (defaults to 9090). In non-production environments, the GraphQL Playground interface will run here too.

In-memory caching (see below) is enabled on the example server.

Test query:

{
  brewerySearch(q: "Inefficient Prohibitions") {
    brewery_id
    brewery_name
  }
}

User Authentication

To use an Untappd user's API limits instead of your app's limits, you can authenticate the user and pass their access_token to the API.

To do this, set user.data.untappd on the context property to the user's Untappd access token when creating the GraphQL server.

Using in Your Own Project

This module exports the following for use in your GraphQL project:

  • Type definitions: typeDefs
  • Resolvers: resolvers
  • An executable schema: schema

For example, you could use the typeDefs and resolvers to make an executable schema for you own GraphQL server (see server.js) or for schema stitching it with another schema.

Caching

To cache the API results from Untappd pass in a cache object as a property of context when creating the GraphQL server. The cache must support the following function signatures (such as node-cache):

  • get(key)
  • set(key, value)

Caching is recommended, especially if using the brewerySearchInflated Query since it requires one API call for the search and one for each Brewery returned.

For an example using node-cache as an in-memory cache with apollo-server-express see server.js.