Simple client to use the everhour API in your javascript or typescript project or on your website.
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.
You can install it as dependency through NPM or download it directly from the releases page.
npm i everhour-api-client
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();
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();
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>
Refer to the Everhour API blueprint for more documentation and examples.