# JavaScript library

# Introduction

The Trusted Twin JavaScript library makes it easy to use the Trusted Twin user infrastructure API in applications written in server-side JavaScript. The library can be used in the browser or Node.js environment. It has Promise-based methods that wrap individual REST API endpoint calls. In TypeScript the definition should be automatically resolved via package.json.

# Requirements

The Trusted Twin JavaScript library requires:

# Environment

  • Node.js
  • Webpack
  • Browserify

# Language level

  • ES5 - you must have a Promises/A+ library installed
  • ES6

# Module system

  • CommonJS
  • ES6 module system

# Installation

To install the library:

# Authorization

On the Trusted Twin platform, User authentication is based on User Secrets. The User Secret is the API key on the Trusted Twin platform as it is required to access Trusted Twin API methods. To configure the client service provide the API key in the object constructor:

# Responses

To retrieve only data returned by an endpoint, use regular API methods:

If you want to read the response metadata, use methods with the Raw suffix:

# Resources

For more information, see the Trusted Twin JavaScript(opens new window) GitHub repository.

You can explore an example web application using the Trusted Twin REST API JavaScript Client(opens new window).

Was this article helpful?