DocStudio API客户端为Node.js
的TypeScript客户端 DocStudio API,由
服务器的OpenAPI文档
openapi-generator (typescript-axios)。
- API版本:
R168.21- 发电机版本:
7.24.0
- 发电机版本:
- 建设方案:
org.openapitools.codegen.languages.TypeScriptAxiosClientCodegen
要求
package.json tsconfig是手工维护的;生成器的副本
被丢弃。
Node.js 18或更高版本。 axios 是唯一的运行时依赖项;包中包含CommonJS
和ES模块构建加上TypeScript声明。
安装
npm install @docstudio/api-client
开始
import {
AuthenticationControllerApi,
MailboxControllerApi,
Configuration,
} from '@docstudio/api-client';
const basePath = 'https://api.docstudio.com';
const auth = new AuthenticationControllerApi(new Configuration({ basePath }));
const { data: session } = await auth.login({ login: email, password });
const config = new Configuration({ basePath, accessToken: session.token });
const mailboxes = new MailboxControllerApi(config);
const { data } = await mailboxes.getAllForUser();
大多数端点都限定在邮箱的范围内,并将其UUID作为 mailbox 参数,
客户端发送的是什么 Mailbox 头。
身份验证
每个文件只设置一个凭证 Configuration.
// user API - bearer token
new Configuration({ basePath, accessToken: token });
// form API - form token, with the prefix included in the value
new Configuration({ basePath, apiKey: `Form ${formToken}` });
这两种证书都在 Authorization 头。少数端点接受
要么;如果两者都设置了,则最后应用表单令牌并获胜,这就是为什么a
Configuration 应该只带一个。
二进制响应
返回文件的端点解析为 ArrayBuffer. 客户端设置
responseType 因为axios会将正文解码为UTF-8文本和
腐败。注意生成的签名如下 File -这是发电机的标签
二进制主体,而不是运行时类型。
const { data } = await envelopes.downloadFinalPdf(id, documentId, mailbox);
await writeFile('envelope.pdf', Buffer.from(data as unknown as ArrayBuffer));
释放
这个包是从DocStudio OpenAPI文档生成的;以上API版本为 生成它的API版本。版本由DocStudio团队从 内部工具。
许可证
麻省理工学院