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

api_counter

v1.1.5

Published

Count the request you make. This npm package is nothing more than a counter, it was created out of restrictions on food2fork.com api. food2fork only allow up to 50 request per day (for free).

Downloads

5

Readme

API Counter

Count the request you make. This npm package is nothing more than a counter.
This package was created out of restrictions on certain free API's limiting 50 request per day.

forthebadge forthebadge

Goals

  • [x] Count the the number of request and store (cache) in browser.
  • [x] Add function to list all counters and Localstrorge keys
  • [x] Convert counter from simple string to json (json)
  • [x] Log the number of request per day (json)
  • [x] Warn the developer if they are about to reach their limit
  • [x] Warn the developer if they have reached their limit
  • [x] Notify the developer that they have 1 request left
  • [x] Notify the developer that they have gone over there request
  • [x] The ability to reset a counter
  • [x] The ability to remove or reset one counter with out localStorage.clear()
    • restCounter('counterAPI','soft') soft to reset to 0 or hard to erase counter
  • [x] Return the object if requested
    • getCLS = (cn = 'mainCounter', 1) giveback = 1: Return Object or 0: Update CLS (0 is default)
  • [ ] The ability to choice how to receive alert by console.log, alert or return counter
  • [ ] Create a mini version of this package
  • [ ] add the ability to log every add and request beside hard reset
  • [ ] Provide the length of time until they can use there API again.
  • [ ] The current local storage size
  • [ ] Update method from daily counter to specified counter
    • Hourly, daily, weekly, monthly and yearly

How to use APICounter()

All you have todo is add APICounter() to your project via npm i api_counter, add it to your try and catch or where ever you want to count.

You can have multiple counters, just pass in a name as a 'string'. If you do not pass in a name as the variable it will default to 'mainCounter'.
You can also add a limit to alert you that you have used 50% or 100% of your daily use. APICounter('counterNameAsString', limit as intiger)

try {
    const result = fetch(`https://www.apiurl.com/api/search?key=1235`);
    APICounter('mainCounter', 50);
} catch (error) {
    console.log(error);
    APICounter('errorCount')
}

Function that you can use

Gives you everything in localstorage (Current web page/domain)

allStorage()

understanding the acronyms and format

  • Function Format = cn , cls , limit, type
  • cn = counter name
  • cls = current local storage
  • limit = at what count do you want to be warn by
  • type = soft or hard reset
  • cy = current year
  • cm = current month
  • cdy = current day
  • clsli = current local storage last item - meaning the last object in the array
  • ldt = last date
  • tm = time

Data structure of JSON "file"

let cls = {
  data: [
    {
      counterAPI: 13,
      counterYear: 2022,
      counterMonth: 12,
      counterDay: 24,
      counterTime: 1568681773241
    },
    {
      counterAPI: 48,
      counterYear: 2022,
      counterMonth: 12,
      counterDay: 25,
      counterTime: 1568681901168
    }
  ]
};
Pull request are recommend and any features you want let's collaborate