TypeScript
The ONLYOFFICE DocSpace SDK for TypeScript is a library that provides tools for integrating and managing DocSpace features within your applications.
It simplifies interaction with the DocSpace API by offering ready-to-use methods and models.
ONLYOFFICE TypeScript Library on GitHub
Installation
Install the package:
npm install @onlyoffice/docspace-api-sdk
Yarn:
yarn add @onlyoffice/docspace-api-sdk
pnpm:
pnpm add @onlyoffice/docspace-api-sdk
Building
To build and compile the TypeScript sources to JavaScript, use the following commands:
npm install
npm run build
Consuming
To use the SDK in your project, navigate to the root folder of your consuming project and run one of the following commands:
From published package (recommended)
npm install @onlyoffice/docspace-api-sdk --save
From local build (not recommended)
npm install PATH_TO_GENERATED_PACKAGE --save
Getting Started
Please follow the building instruction and execute the following TS code:
import { Configuration, RoomsApi } from '@onlyoffice/docspace-api-sdk';
const config = new Configuration ({
basePath: "https://your-docspace.onlyoffice.com",
accessToken: "YOUR ACCESS TOKEN",
});
const roomsApi = new RoomsApi(config);
try {
const result = await roomsApi.getRoomsFolder({ type: [6,5]});
console.log('API called successfully. Returned data: ', result.data);
} catch (error) {
console.error(error);
}