Sheetbase middleware to authorize with the API Key.

Usage no npm install needed!

<script type="module">
  import sheetbaseApiKey from 'https://cdn.skypack.dev/@sheetbase/api-key';


Sheetbase Module: @sheetbase/api-key

Sheetbase middleware to authorize with the API Key.

Build Status Coverage Status NPM License clasp Support me on Patreon PayPal Ask me anything


Using npm: npm install --save @sheetbase/api-key

import * as ApiKey from "@sheetbase/api-key";

As a library: 1NulS_tPHLm401X7Km_ONKgtRK-VHnC5ODmNZ1sMt0QgXuDgtffxJ-Zzv

Set the Indentifier to ApiKeyModule and select the lastest version, view code.

declare const ApiKeyModule: { ApiKey: any };
const ApiKey = ApiKeyModule.ApiKey;


Getting started

Install: npm install --save @sheetbase/api-key

import { middleware as apiKeyMiddleware } from "@sheetbase/api-key";

const ApiKeyMiddleware = apiKeyMiddleware({ key: apiKey });

router.get("/", ApiKeyMiddleware, (req, res) => {
  return res.send("Aye!");



  • Type: string

A single key.


  • Type: {[key: string]: string | APIKey}

Multiple api keys for multiple clients.

interface APIKey {
  value?: string;
  id?: string;
  title?: string;
  description?: string;
  createdAt?: string | number;
  [k: string]: any;


  • Type: (req: RouteRequest, res: RouteResponse) => any (Sheetbase route handler)

Custom handler if not passed, default showing an unauthorized message.

  failure: (req, res) => res.json({ hey: "Go away!" });


  • Type: (req: RouteRequest, apiKey: APIKey) => void

Trigger when the middileware is call, useful for logging multiple API keys usage.

  trigger: (req, apiKey) => {
    return console.log("A client access using this API Key:", apiKey);


@sheetbase/api-key is released under the MIT license.