UNPKG

@truestamp/client

Version:
103 lines (72 loc) 2.91 kB
# Truestamp Client ## Description A small Truestamp API wrapper library, written in Typescript, for usage in Deno and Node.js. Usage of this library requires an active [Truestamp](https://www.truestamp.com) account, and an associated API key. ## Features - Small library size - Zero dependencies - Built with Typescript - Promise based API (async/await) - Supports Deno (ESM), Node.js (CommonJS) - [esm.sh CDN](https://esm.sh) support - [SkyPack CDN](https://www.skypack.dev/view/@truestamp/client) support - [JSDELIVR CDN](https://www.jsdelivr.com/package/npm/@truestamp/client) support - [UNPKG CDN](https://unpkg.com/browse/@truestamp/client/) support ## Installation How to install and use the `TruestampClient` in different runtime environments. ### Node.js (CommonJS) In your NPM project root. ```bash npm install @truestamp/client --save ``` Require the `@truestamp/client` CommonJS module in your project and initialize it with an [api key](https://www.truestamp.com/dashboard/keys). ```js const { TruestampClient } = require("@truestamp/client") ... ``` ### Deno (ES Modules) Import the `@truestamp/client` ESM module in your project via [esm.sh](https://esm.sh) and initialize it with an [apiKey](https://www.truestamp.com/dashboard/keys). ```typescript // Tip : Load module from esm.sh CDN, pinned to a specific version. import { TruestampClient } from "https://esm.sh/@truestamp/client@0.15.0" ... ``` ## API Usage Example The first step is to instantiate an instance of the `TruestampClient` class, passing it your `apiKey` as an argument. The client class instance the makes available a number of functions, each of which accepts typed arguments and returns typed response `Objects`. ```js // See installation section for your runtime environment. import { TruestampClient } from "@truestamp/client" const ts = new TruestampClient({ apiKey: "%yourApiKey%" }) const myHash = "e728e4adeb8c0606fce4686552338622efeb8c63b53d072a323a4914d1aa5c07" // Create new Item const resp = await ts.createItem( { itemData: [ { hash: myHash, hashType: "sha-256", }, ], }, { skipCF: false, skipOE: false } ) // Success! `resp` contains good response JSON // of the appropriate type. console.log("createItem", resp) ``` ### Examples There are working code examples for Deno and Node.js in the [/examples](/examples) directory. Take a look at the [examples/README.md](examples/README.md) for usage instructions. ## Truestamp Community Hub Please see our Github organization's profile at [github.com/truestamp](https://github.com/truestamp?view_as=public) for quick access to links related to these and other important topics. - Filing Issues (bug reports & feedback) - Community Discussions - Security Reporting - Code of Conduct - Code Contributions - Public roadmap - Support ## Legal Copyright © 2019-2023 Truestamp Inc. All Rights Reserved.