mirror of
https://github.com/nocodb/nocodb.git
synced 2026-05-06 01:47:28 +00:00
docs: update SDK content
Signed-off-by: Wing-Kam Wong <wingkwong.code@gmail.com>
This commit is contained in:
@@ -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-auth': '<AUTH_TOKEN>'
|
||||
}
|
||||
})
|
||||
```
|
||||
|
||||
#### Example: API Token
|
||||
|
||||
```js
|
||||
const api = new Api({
|
||||
baseURL: 'https://<HOST>:<PORT>',
|
||||
headers: {
|
||||
'xc-token': '<API_TOKEN>'
|
||||
}
|
||||
})
|
||||
|
||||
// await api.meta.something()
|
||||
// await api.data.something()
|
||||
```
|
||||
|
||||
### 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)
|
||||
```
|
||||
Reference in New Issue
Block a user