Browse Source

docs: update SDK content

Signed-off-by: Wing-Kam Wong <wingkwong.code@gmail.com>
pull/1700/head
Wing-Kam Wong 2 years ago
parent
commit
4b49850323
  1. 49
      packages/noco-docs/content/en/developer-resources/sdk.md

49
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.
<alert>
Note: The NocoDB SDK requires API token for authorization. If you haven't created an API token, please check out <a href="./accessing-apis#api-token" target="_blank">API Tokens</a> and create one first.
Note: The NocoDB SDK requires authorization token. If you haven't created one, please check out <a href="./accessing-apis" target="_blank">Accessing APIs</a> for details.
</alert>
### 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://<HOST>:<PORT>',
baseURL: 'https://<HOST>:<PORT>',
headers: {
'xc-token': '<API_TOKEN>'
'xc-auth': '<AUTH_TOKEN>'
}
})
```
#### Example: API Token
// await api.meta.something()
// await api.data.something()
```js
const api = new Api({
baseURL: 'https://<HOST>:<PORT>',
headers: {
'xc-token': '<API_TOKEN>'
}
})
```
### Call Functions
Once you have configured `api`, you can call different types of APIs by `api.<Tag>.<FunctionName>`.
<alert>
For Tag and FunctionName, please check out the API table <a href="./rest-apis" target="_blank">here</a>.
</alert>
#### Example: Calling API - /api/v1/db/meta/projects/{projectId}/tables
```js
await api.dbTable.create(params)
```
Loading…
Cancel
Save