EventRegistry/event-registry-node-js

Utility methods not found

HARAJLI98 opened this issue · 5 comments

When trying to access API usage data, I get the following error:

TypeError: er.getRemainingAvailableRequests is not a function
    at Object.fetchRemainingTokens (/src/jobs/eventregistry.js:41:25)
    at eventRegistry (/src/server.js:37:29)
    at Object.<anonymous> (/src/server.js:43:1)
    at Module._compile (module.js:652:30)
    at Object.Module._extensions..js (module.js:663:10)
    at Module.load (module.js:565:32)
    at tryModuleLoad (module.js:505:12)
    at Function.Module._load (module.js:497:3)
    at Function.Module.runMain (module.js:693:10)
    at startup (bootstrap_node.js:191:16)

Here's how I'm using the library:

const { EventRegistry } = require('eventregistry');
const er = new EventRegistry({apiKey: EVENT_REGISTRY_API_KEY});

try {
      console.log(er);
      return await er.getRemainingAvailableRequests();
} catch (e) {
      console.log(e);
}

Thanks for the report. Fix for this issue is in the latest version (8.3.11) that was deployed today.

I'm still not seeing updated values for the dailyRemainingRequests and remainingAvailableRequests. Those values are only initialized to -1 and never updated...

The above-mentioned utility functions return values that are updated every time you make a query/request. If you only initialize the object without making any kind of requests then it only returns -1. This function is available on the EventRegistry object and you don't have to use await because it's not a Promise.

We are currently among other things adding an additional API endpoint that'll provide usage information.

@UnspokenMallard Do you have an approximate time on when the API usage endpoints will be complete?

Thanks.

@HARAJLI98 Usage information endpoint is available in the latest version (8.3.12) which was deployed today.

The function in question is called getUsageInfo and you can use it like this:

const er = new EventRegistry({apiKey: EVENT_REGISTRY_API_KEY});
er.getUsageInfo().then((data) => {
    console.log(data);
});