everhour-api-client
TypeScript icon, indicating that this package has built-in type declarations

1.0.0 • Public • Published

Everhour API Client

Simple client to use the everhour API in your javascript or typescript project or on your website.

State & Production Readiness

Beware: I won't consider this production ready. Only trust your own tests... Background: The types, method signatures and comments derived from the Everhour API blueprint. The blueprint file was processed with SwaggerHub to export typescript code. This resulted in file with about 30k lines. I broke it down to 2k line by reducing code duplication and simplifying the structure of the methods. As I only needed a fraction of the API calls most of them are UNTESTED! So take it as it is and feel free to contribute tests, fixes etc.

Installation

You can install it as dependency through NPM or download it directly from the releases page.

npm i everhour-api-client

Usage

ECMAScript Module

The ES module is tree-shakable. Import only the functions you need:

import { initEverhourApiClient, getCurrentUser } from "everhour-api-client";

initEverhourApiClient(process.env.EVERHOUR_API_KEY);
const currentProfile = await getCurrentUser();

CommonJS Module

The CommonJS module contains all methods of the client:

const client = require("everhour-api-client");
client.initEverhourApiClient(process.env.EVERHOUR_API_KEY);
const currentProfile = await client.getCurrentUser();

As a script in your HTML project

You can also use the client.min.js file from the releases in your HTML page. Like the CommonJS module, it provides all available API methods under a single global variable:

<script src="client.min.js" defer></script>
<script>
  document.addEventListener('DOMContentLoaded', () => {
      const client = globalThis.EverhourApiClient;
      client.initEverhourApiClient(EVERHOUR_API_KEY);
      const currentProfile = await client.getCurrentUser();
  });
</script>

Documentation

Refer to the Everhour API blueprint for more documentation and examples.

Package Sidebar

Install

npm i everhour-api-client

Weekly Downloads

3

Version

1.0.0

License

MIT-0

Unpacked Size

311 kB

Total Files

15

Last publish

Collaborators

  • levma