From 4b498503235c6529fddc3170a5e9887fb9d4f271 Mon Sep 17 00:00:00 2001 From: Wing-Kam Wong Date: Sat, 16 Apr 2022 16:20:20 +0800 Subject: [PATCH] docs: update SDK content Signed-off-by: Wing-Kam Wong --- .../content/en/developer-resources/sdk.md | 49 ++++++++++++++++--- 1 file changed, 43 insertions(+), 6 deletions(-) diff --git a/packages/noco-docs/content/en/developer-resources/sdk.md b/packages/noco-docs/content/en/developer-resources/sdk.md index 90296ee001..b28337202b 100644 --- a/packages/noco-docs/content/en/developer-resources/sdk.md +++ b/packages/noco-docs/content/en/developer-resources/sdk.md @@ -9,22 +9,59 @@ menuTitle: 'NocoDB SDK' We provide SDK for users to integrate with their applications. Currently only SDK for Javascript is supported. -Note: The NocoDB SDK requires API token for authorization. If you haven't created an API token, please check out API Tokens and create one first. +Note: The NocoDB SDK requires authorization token. If you haven't created one, please check out Accessing APIs for details. -### SDK For Javascript +## SDK For Javascript + +### Install nocodb-sdk + +```bash +npm i nocodb-sdk +``` + +### Import Api ```js import { Api } from 'nocodb-sdk' +``` + +### Configure Api + +The Api can be authorizated by either Auth Token or API Token. +#### Example: Auth Token + +```js const api = new Api({ - baseURL: 'http://:', + baseURL: 'https://:', headers: { - 'xc-token': '' + 'xc-auth': '' } }) +``` + +#### Example: API Token -// await api.meta.something() -// await api.data.something() +```js +const api = new Api({ + baseURL: 'https://:', + headers: { + 'xc-token': '' + } +}) ``` +### Call Functions + +Once you have configured `api`, you can call different types of APIs by `api..`. + + +For Tag and FunctionName, please check out the API table here. + + +#### Example: Calling API - /api/v1/db/meta/projects/{projectId}/tables + +```js +await api.dbTable.create(params) +``` \ No newline at end of file