@dynamic-labs/sdk-api
TypeScript icon, indicating that this package has built-in type declarations

0.0.431 • Public • Published

sdk-api

This library contains a generated TypeScript client using openapi. It can be used with any Javascript/Typescript project.

Documentation on the current set of REST APIs can be found at: https://docs.dynamic.xyz/api-reference/overview

APIs

  • SdkApi
    • These are endpoints used exclusively by the Dynamic React SDK. Several endpoints in these APIs require a JWT created by the verify or signin endpoints, and are specific to a user in the SDK's environment. These APIs are typically used on a client site or frontend to enhance their customers' experience.
  • Dashboard APIs
    • These endpoints are used by admins of an organization to update site settings and manage users of the environment. These APIs require an API token scoped for a specific environment. These APIs are typically used on a client backend, to manage all their users' data and make corresponding settings changes that affect all users of a site.
    • The most commonly used API among the dashboard APIs is UsersApi
    • You can read about all the other available APIs here

Examples

This section provides an example of how to use SDKApi. This would be similar to using the other available generated APIs, like UsersApi or ExportsApi, etc.

SdkApi

Initialize a new instance of the SDKApi class:

import { Configuration, SDKApi } from '@dynamic-labs/sdk-api';

const sdkApi = (jwt: string) => {
  const settings = {
    basePath: ApiEndpoint.getBaseUrl(),
    headers: {
      'Content-Type': 'application/json',
    },
  };
  settings.headers.Authorization = `Bearer ${jwt}`;
  return new SDKApi(new Configuration(settings));
};

Then you would be able to use it like this:

const response = await sdkApi(jwt).updateSelf({
  environmentId,
  userFields: fields, // { alias, firstName, lastName, username, ... }
});
// do something with the response

Readme

Keywords

none

Package Sidebar

Install

npm i @dynamic-labs/sdk-api

Homepage

dynamic.xyz

Weekly Downloads

7,012

Version

0.0.431

License

Apache-2.0

Unpacked Size

2.3 MB

Total Files

920

Last publish

Collaborators

  • jesse-at-dynamic
  • packaging-at-dynamic-labs