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,
});