docs: dev resources (#8588)

* docs: dev resources

* Update packages/noco-docs/docs/160.developer-resources/010.rest-APIs/010.accessing-apis.md

Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>

* Update packages/noco-docs/docs/160.developer-resources/010.rest-APIs/010.accessing-apis.md

Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>

* Update packages/noco-docs/docs/160.developer-resources/010.rest-APIs/010.accessing-apis.md

Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>

* Update packages/noco-docs/docs/160.developer-resources/020.webhook/040.actions-on-webhook.md

Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>

* Update packages/noco-docs/docs/160.developer-resources/020.webhook/020.create-webhook.md

Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>

* Update packages/noco-docs/docs/160.developer-resources/020.webhook/020.create-webhook.md

Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>

* Update packages/noco-docs/docs/160.developer-resources/010.rest-APIs/010.accessing-apis.md

Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>

* Update packages/noco-docs/docs/160.developer-resources/020.webhook/020.create-webhook.md

Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>

* Update packages/noco-docs/docs/160.developer-resources/020.webhook/040.actions-on-webhook.md

Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>

* Update packages/noco-docs/docs/160.developer-resources/010.rest-APIs/010.accessing-apis.md

Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>

* Update packages/noco-docs/docs/160.developer-resources/010.rest-APIs/050.upload-via-api.md

Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>

* Update packages/noco-docs/docs/160.developer-resources/010.rest-APIs/005.overview.md

Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>

* Update packages/noco-docs/docs/160.developer-resources/010.rest-APIs/005.overview.md

Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>

* Update packages/noco-docs/docs/160.developer-resources/010.rest-APIs/005.overview.md

Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>

* Update packages/noco-docs/docs/160.developer-resources/020.webhook/040.actions-on-webhook.md

Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>

* Update packages/noco-docs/docs/160.developer-resources/020.webhook/020.create-webhook.md

Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>

* fix: review comments

Signed-off-by: Raju Udava <86527202+dstala@users.noreply.github.com>

---------

Signed-off-by: Raju Udava <86527202+dstala@users.noreply.github.com>
Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>
This commit is contained in:
Raju Udava
2024-05-31 06:42:43 +05:30
committed by GitHub
parent 30d43d7252
commit 27a5149d8e
9 changed files with 665 additions and 0 deletions

View File

@@ -0,0 +1,86 @@
---
title: 'Overview'
description: 'NocoDB REST API Overview'
---
Once you've created the schemas, you can manipulate the data or invoke actions using the REST APIs. We provide several types of APIs for different usages. Refer to the following links for more details:
[Meta APIs](https://meta-apis-v2.nocodb.com/)
- [Data APIs](https://data-apis-v2.nocodb.com/)
Additional information on the REST APIs is provided below.
## Query params
| **Name** | **Alias** | **Use case** | **Default value** |**Example value** |
|---|---|---|---|---|
| [where](#comparison-operators) | [w](#comparison-operators) | Complicated where conditions | | `(colName,eq,colValue)~or(colName2,gt,colValue2)` <br />[Usage: Comparison operators](#comparison-operators) <br />[Usage: Logical operators](#logical-operators) |
| limit | l | Number of rows to get (SQL limit value) | 10 | 20 |
| offset | o | Offset for pagination (SQL offset value) | 0 | 20 |
| sort | s | Sort by column name, Use `-` as a prefix for descending sort | | column_name |
| fields | f | Required column names in result | * | column_name1,column_name2 |
| shuffle | r | Shuffle the result for pagination | 0 | 1 (Only allow 0 or 1. Other values would see it as 0) |
## Comparison Operators
| Operation | Meaning | Example |
|---|---|---|
| eq | equal | (colName,eq,colValue) |
| neq | not equal | (colName,neq,colValue) |
| not | not equal (alias of neq) | (colName,not,colValue) |
| gt | greater than | (colName,gt,colValue) |
| ge | greater or equal | (colName,ge,colValue) |
| lt | less than | (colName,lt,colValue) |
| le | less or equal | (colName,le,colValue) |
| is | is | (colName,is,true/false/null) |
| isnot | is not | (colName,isnot,true/false/null) |
| in | in | (colName,in,val1,val2,val3,val4) |
| btw | between | (colName,btw,val1,val2) |
| nbtw | not between | (colName,nbtw,val1,val2) |
| like | like | (colName,like,%name) |
| nlike | not like | (colName,nlike,%name) |
| isWithin | is Within (Available in `Date` and `DateTime` only) | (colName,isWithin,sub_op) |
| allof | includes all of | (colName,allof,val1,val2,...) |
| anyof | includes any of | (colName,anyof,val1,val2,...) |
| nallof | does not include all of (includes none or some, but not all of) | (colName,nallof,val1,val2,...) |
| nanyof | does not include any of (includes none of) | (colName,nanyof,val1,val2,...) |
## Comparison Sub-Operators
The following sub-operators are available in the `Date` and `DateTime` columns.
| Operation | Meaning | Example |
|-----------------|-------------------------|-----------------------------------|
| today | today | (colName,eq,today) |
| tomorrow | tomorrow | (colName,eq,tomorrow) |
| yesterday | yesterday | (colName,eq,yesterday) |
| oneWeekAgo | one week ago | (colName,eq,oneWeekAgo) |
| oneWeekFromNow | one week from now | (colName,eq,oneWeekFromNow) |
| oneMonthAgo | one month ago | (colName,eq,oneMonthAgo) |
| oneMonthFromNow | one month from now | (colName,eq,oneMonthFromNow) |
| daysAgo | number of days ago | (colName,eq,daysAgo,10) |
| daysFromNow | number of days from now | (colName,eq,daysFromNow,10) |
| exactDate | exact date | (colName,eq,exactDate,2022-02-02) |
For `isWithin` in `Date` and `DateTime` columns, the different set of sub-operators are used.
| Operation | Meaning | Example |
|------------------|-------------------------|-----------------------------------------|
| pastWeek | the past week | (colName,isWithin,pastWeek) |
| pastMonth | the past month | (colName,isWithin,pastMonth) |
| pastYear | the past year | (colName,isWithin,pastYear) |
| nextWeek | the next week | (colName,isWithin,nextWeek) |
| nextMonth | the next month | (colName,isWithin,nextMonth) |
| nextYear | the next year | (colName,isWithin,nextYear) |
| nextNumberOfDays | the next number of days | (colName,isWithin,nextNumberOfDays,10) |
| pastNumberOfDays | the past number of days | (colName,isWithin,pastNumberOfDays,10) |
## Logical Operators
| Operation | Example |
|---|---|
| ~or | (checkNumber,eq,JM555205)~or((amount,gt,200)~and(amount,lt,2000)) |
| ~and | (checkNumber,eq,JM555205)~and((amount,gt,200)~and(amount,lt,2000)) |
| ~not | ~not(checkNumber,eq,JM555205) |

View File

@@ -0,0 +1,15 @@
---
title: 'Accessing APIs'
description: 'How to access NocoDB APIs with Auth or API token?'
---
## API Tokens
NocoDB APIs can be authorized by using API Tokens. API tokens allow us to integrate seamlessly with 3rd party apps. See [API Tokens Management](/account-settings/api-tokens) for more.
## Swagger UI
You can interact with the API's resources via the Swagger UI. For more details, see [Swagger APIs Doc](/bases/actions-on-base/#rest-apis)

View File

@@ -0,0 +1,137 @@
---
title: 'Upload via API'
description: 'Upload files locally present or from public remote URL via API'
hide_table_of_contents: true
---
Sample code to upload files via API is listed below.
Assumes `http://localhost:8080/` as the base URL for the API calls.
# Upload local file
```javascript
let axios = require("axios").default;
let FormData = require('form-data');
let fs = require('fs');
// Configurations
//
const project_id = '<Project Identifier>';
const table_id = '<Table Identifier>';
const xc_token = '<Auth Token>';
const file_path = '<Local File Path>';
// Insert Image
// @param image_path : local file path
// @return : JSON object to be used in insert record API for attachment field
//
async function insertImage (path) {
const formData = new FormData();
formData.append("file", fs.createReadStream(path));
const data = await axios({
url: 'http://localhost:8080/api/v2/storage/upload',
data: formData,
headers:{
'Content-Type':`multipart/form-data;`,
'xc-token': xc_token
},
method: 'post',
// Optional : storage file path
params: {"path": "somePath"}
});
return data;
}
// Insert record with attachment
// Assumes a table with two columns :
// 'Title' of type SingleLineText and
// 'Attachment' of type Attachment
//
async function uploadFileExample() {
let response = await insertImage(file_path);
let row = {
"Title": "2",
"Attachment": response.data
};
await axios({
method: 'POST',
url: `http://localhost:8080/api/v2/tables/${table_id}/records`,
data: row,
headers: {
'xc-token': xc_token
}
});
}
(async () => {
await uploadFileExample();
})();
```
# Upload via URL
```javascript
let axios = require("axios").default;
let FormData = require('form-data');
let fs = require('fs');
// Configurations
//
const project_id = '<Project Identifier>';
const table_id = '<Table Identifier>';
const xc_token = '<Auth Token>';
// URL array : URLs of files to be uploaded
const URLs = [{ url: '<URL1>' }, { url: '<URL2>' }];
// Insert Image
// @param URLs : [] containing public URL for files to be uploaded
// @return : JSON object to be used in insert record API for attachment field
//
async function insertImageByURL (URL_array) {
const data = await axios({
url: 'http://localhost:8080/api/v2/storage/upload-by-url',
data: URL_array,
headers: {
'xc-token': xc_token
},
method: 'post',
// Optional : storage file path
params: {"path": "somePath"}
});
return data;
}
// Insert record with attachment
// Assumes a table with two columns :
// 'Title' of type SingleLineText and
// 'Attachment' of type Attachment
//
async function uploadByUrlExample() {
let response = await insertImageByURL(URLs);
// Update two columns : Title and Attachment
let row = {
"Title": "3",
"Attachment": response.data
};
await axios({
method: 'POST',
url: `http://localhost:8080/api/v2/tables/${table_id}/records`,
data: row,
headers: {
'xc-token': xc_auth
}
});
}
(async () => {
await uploadByUrlExample();
})();
```

View File

@@ -0,0 +1,8 @@
{
"label": "REST APIs",
"collapsible": true,
"collapsed": true,
"link": {
"type": "generated-index"
}
}