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 🙏

© 2025 – Pkg Stats / Ryan Hefner

@panoptic-it-solutions/autotask-rate-limiter

v1.0.19

Published

Rate limiting utilities for Autotask API integration

Readme

Autotask Rate Limiting Utilities

This package provides utilities for rate limiting Autotask API calls using Upstash Redis. It includes:

  • Rate limiting middleware for Next.js API routes
  • Autotask-specific rate monitoring
  • Fetch utilities for making API calls
  • Environment variable configuration

Installation

npm install @your-org/autotask-rate-limiter
# or
pnpm add @your-org/autotask-rate-limiter

Usage

  1. Set up your environment variables:
cp .env.example .env
# Edit .env with your values
  1. Use the utilities in your API routes:
// app/api/your-route/route.ts
import { NextRequest } from 'next/server';
import { withAutotaskRateLimit } from '@your-org/autotask-rate-limiter';

export async function POST(request: NextRequest) {
  return withAutotaskRateLimit(request, async () => {
    // Your API logic here
  });
}

Features

  • Automatic rate limiting using Upstash Redis
  • Autotask-specific usage monitoring
  • Middleware for Next.js API routes
  • TypeScript support
  • Configurable rate limits
  • Backoff strategy for API calls

API

Rate Limiter

import { rateLimiter } from '@your-org/autotask-rate-limiter';

// Check rate limit
const { success, limit, remaining } = await rateLimiter.checkRateLimit(identifier);

Autotask Rate Monitor

import { checkAutotaskLimits, applyAutotaskBackoff } from '@your-org/autotask-rate-limiter';

// Check Autotask limits
const { success, estimatedUsage } = await checkAutotaskLimits(identifier);

// Apply backoff if needed
await applyAutotaskBackoff();

Fetch Utilities

import { fetchAutotaskData } from '@your-org/autotask-rate-limiter';

// Make API calls
const data = await fetchAutotaskData(
  'YourEndpoint/query',
  filter,
  headers
);

Configuration

The package requires the following environment variables:

  • UPSTASH_REDIS_REST_URL
  • UPSTASH_REDIS_REST_TOKEN
  • AUTOTASK_API_INTEGRATION_CODE
  • AUTOTASK_USERNAME
  • AUTOTASK_PASSWORD
  • AUTOTASK_API_URL (Optional): You can optionally provide the full base URL for the Autotask REST API, overriding the zone-based default.

Prerequisites

To use these utilities within your Next.js project, ensure the following prerequisites are met:

1. Environment Variables

The following environment variables must be defined in your project's .env file (e.g., .env):

  • UPSTASH_REDIS_REST_URL: The REST URL for your Upstash Redis instance (used for rate limiting).
  • UPSTASH_REDIS_REST_TOKEN: The access token for your Upstash Redis instance.
  • AUTOTASK_API_INTEGRATION_CODE: Your Autotask API integration code.
  • AUTOTASK_USERNAME: The username for Autotask API access.
  • AUTOTASK_SECRET: The secret/password for Autotask API access.
  • AUTOTASK_API_URL (Optional): You can optionally provide the full base URL for the Autotask REST API, overriding the zone-based default.

2. Required Packages

Ensure the following packages are installed in your main Next.js project's package.json dependencies:

pnpm install @upstash/ratelimit @upstash/redis
# or
npm install @upstash/ratelimit @upstash/redis
# or
yarn add @upstash/ratelimit @upstash/redis

Note: These utilities were originally developed for a Next.js environment and rely on Next.js types and runtime features (like NextRequest, NextResponse, and the fetch API). Ensure your project environment is compatible.

Usage

You can now import and use the functions directly from this directory using relative paths or path aliases configured in your tsconfig.json.

Example (tsconfig.json path alias):

// tsconfig.json
{
  "compilerOptions": {
    "paths": {
      "@/autotask-utils/*": ["./autotask-utils/*"]
      // ... other paths
    }
    // ... other options
  }
}

Example Import:

import { checkAutotaskLimits } from "@/autotask-utils/autotask-rate-monitor";
import { fetchAutotaskData } from "@/autotask-utils/fetch";

async function someAction() {
  const rateCheck = await checkAutotaskLimits("some-identifier");
  // ... use utilities
}