Skip to content

Commit

Permalink
Update the RESTful API documentation and Official Website (TuGraph-fa…
Browse files Browse the repository at this point in the history
  • Loading branch information
zhangwh807 authored Oct 16, 2024
1 parent 12d9a4c commit 5eeaba6
Show file tree
Hide file tree
Showing 6 changed files with 75 additions and 520 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ NOTICE: If you want to contribute code, you should sign a [cla doc](https://cla-

## 6. Contact

Official Website: [www.tugraph.org](https://www.tugraph.org)
Official Website: [tugraph.tech](https://tugraph.tech)

Slack (For developer quick communication):
[TuGraph.slack](https://join.slack.com/t/tugraph/shared_invite/zt-1hha8nuli-bqdkwn~w4zH1vlk0QvqIfg)
Expand Down
2 changes: 1 addition & 1 deletion README_CN.md
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ $ make package

## 5. 联系我们

官网: [www.tugraph.org](https://www.tugraph.org)
官网: [tugraph.tech](https://tugraph.tech)

Slack (在线开发沟通):
[TuGraph.slack](https://join.slack.com/t/tugraph/shared_invite/zt-1hha8nuli-bqdkwn~w4zH1vlk0QvqIfg)
Expand Down
2 changes: 1 addition & 1 deletion docs/en-US/source/15.contacts.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

If you have any feedback or suggestions for the product, You are welcome to join the discussion or make suggestions through the following contact methods.

Official website: [www.tugraph.org](https://www.tugraph.org)
Official website: [tugraph.tech](https://tugraph.tech)

Github Issue:
[Issue](https://github.com/TuGraph-db/tugraph-db/issues)
Expand Down
295 changes: 36 additions & 259 deletions docs/en-US/source/7.client-tools/7.restful-api.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,23 +29,24 @@ The user sends the login request to the server with the user name and password.
- **METHOD**: POST
- **REQUEST**:

| body parameter | parameter description | parameter type | necessary |
| ------- |-----------------------|-------|------------|
| userName | name of the user | string | yes |
| password | password of the user | string | yes |
| body parameter | parameter description | parameter type | necessary |
|----------------|-----------------------|-------|------------|
| user | name of the user | string | yes |
| password | password of the user | string | yes |

- **RESPONSE**:
If successful, the success field in the returned response message will be set to 00 and the token will be included in data
If successful, the success field in the returned response message will be set to 00 and the token will be included in data

| body parameter | parameter description | parameter type | necessary |
| ------- |-------|--------|------|
| authorization | token | string | yes |
| default_password | whether the password is the default password | bool | yes |
| body parameter | parameter description | parameter type |
|------------------|------------------|----------------|
| jwt | token | string |
| is_admin | Whether the user is an admin | bool |
| default_password | Whether it is the default password | bool |

**Example request.**

```
{"userName" : "test", "password" : "123456"}
{"user" : "admin", "password" : "73@TuGraph"}
```

#### 2.2.2. User Logout
Expand All @@ -54,25 +55,38 @@ When a user logs out, the authenticated token is deleted. and the user needs to
- **URI**: /logout
- **METHOD**: POST
- **REQUEST**:
The http request header carries the token returned by login interface, and the body has no parameters
The http request header carries the token returned by login interface. The specific string to be filled is `Bearer ${jwt}`, where `${jwt}` is the "jwt" returned from the login interface,and the body has no parameters

| header parameter | parameter description | parameter type |
|------------------|-----------------------|------------|
| Authorization | Bearer ${jwt} | string |

- **RESPONSE**:
If successful, the success field in the returned response message will be set to 00, and data is empty
If successful, the success field in the returned response message will be set to 00, and data is

| body parameter | parameter description | parameter type |
|------------------|--------------------|----------------|
| is_admin | Whether the user is an admin | bool |

#### 2.2.3. Refresh Token
If the delivered token becomes invalid, you need to invoke this interface for re-authentication. The token is valid within one hour after the first login and needs to be refreshed

- **URI**: /refresh
- **METHOD**: POST
- **REQUEST**:
The http request header carries the token returned by login interface, and the body has no parameters
The http request header carries the token returned by login interface. The specific string to be filled is `Bearer ${jwt}`, where `${jwt}` is the "jwt" returned from the login interface,and the body has no parameters

| header parameter | parameter description | parameter type |
|------------------|-----------------------|------------|
| Authorization | Bearer ${jwt} | string |

- **RESPONSE**:
If successful, the success field in the returned response message will be set to 00, and the token will be included in data
If successful, the success field in the returned response message will be set to 00, and the token will be included in data

| body parameter | parameter description | parameter type | necessary |
| ------- |------|----------------|------------|
| authorization | token | string | yes |
| body parameter | parameter description | parameter type |
|----------------|------|----------------|
| jwt | token | string |
| is_admin | Whether the user is an admin | bool |

#### 2.2.4. Call Cypher
User manipulation of data and models in tugraph requires calling the cypher interface and is initiated through the standard cypher query language
Expand All @@ -81,13 +95,17 @@ User manipulation of data and models in tugraph requires calling the cypher inte
- **METHOD**: POST
- **REQUEST**:

| header parameter | parameter description | parameter type |
|------------------|-----------------------|------------|
| Authorization | Bearer ${jwt} | string |

| body parameter | parameter description | parameter type | necessary |
| ------- |------------------|---------|-----------|
| graph | the name of the subgraph to be queried | string | yes |
| script | query statement | string | yes |

- **RESPONSE**:
If successful, the success field in the returned response message will be set to 00, and the query results will be included in data
If successful, the success field in the returned response message will be set to 00, and the query results will be included in data

| body parameter | parameter description | parameter type | necessary |
| ------- |------|----------------|------------|
Expand All @@ -97,245 +115,4 @@ If successful, the success field in the returned response message will be set to

```
{"script" : "Match (n) return n", "graph" : "default"}
```

#### 2.2.5. Upload File
This interface is used to upload local files to the TuGraph machine. You can upload text/binary files, large files, and small files. For large files, the client must split the files, and each file fragment must not be larger than 1MB. Parameters Begin-Pos and Size correspond to the offset and fragment size of this fragment in the complete file. The parameter must be placed in the header of the http request, and the request body contains only the file fragment content. The request header of this interface contains more than token parameters

- **URI**: /upload_file
- **METHOD**: POST
- **REQUEST**:

| header parameter | parameter description | parameter type | necessary |
|------------------|--------------------------------------|---------|-------|
| File-Name | the name of the file | string | yes |
| Begin-Pos | Offset of the start position of the current file fragment within the file | string | yes |
| Size | the current file fragment size | string | yes |

- **RESPONSE**:
If successful, the success field in the returned response message will be set to 00

#### 2.2.6. Check File
this interface is used to check the correctness of uploaded files. If the check succeeds, the system returns a success message when the same file is uploaded again

- **URI**: /check_file
- **METHOD**: POST
- **REQUEST**:

| body parameter | parameter description | parameter type | necessary |
| ------- |-----------------------------|----------------|-----------|
| fileName | the name of the file | string | yes |
| checkSum | the checksum of the file | string | yes when flag set to "1" |
| fileSize | the size of the file | string | yes when flag set to "2" |
| flag | If flag is "1", check md5. If flag is "2",check file size | string | yes |

- **RESPONSE**:
If successful, the success field in the returned response message will be set to 00

| body parameter | parameter description | parameter type | necessary |
| ------- |------|------|------|
| pass | true on success, false otherwise | bool | yes |

**Example request.**

```
{"fileName" : "test.csv", "checkSum" : "$MD5", "flag" : “1”}
```

#### 2.2.7. Delete Cached File
The admin user can delete all the files uploaded by anyone. Other users can delete their own files. You can delete a file with a specified name, a file uploaded by a specified user, or all files

- **URI**: /clear_cache
- **METHOD**: POST
- **REQUEST**:

| body parameter | parameter description | parameter type | necessary |
| ------- |-----------------------|--------|--------|
| fileName | the name of the file | string | yes when flag set to "0" |
| userName | the name of the user | string | yes when flag set to "1" |
| flag | When flag is set to 0, the file specified by fileName is deleted; when flag is set to 1, all files uploaded by userName are deleted; when flag is set to 2, all files are deleted | string | yes |

- **RESPONSE**:
If successful, the success field in the returned response message will be set to 00

**Example request.**

```
{"fileName" : "test.csv", "userName" : "test", "flag" : “1”}
```

#### 2.2.8. Import Schema
This interface can create a schema model based on the schema information specified by description parameter. For details about the schema format, refer to data-import.md

- **URI**: /import_schema
- **METHOD**: POST
- **REQUEST**:

| body parameter | parameter description | parameter type | necessary |
| ------- |-----------------------|----------------|-----------|
| graph | name of the subgraph | string | yes |
| description | schema infomation | json string | yes |

- **RESPONSE**:
If successful, the success field in the returned response message will be set to 00

**Example request.**

```
{
"graph": "test_graph",
"description": {
"schema": [{
"label": "Person",
"type": "VERTEX",
"primary": "name",
"properties": [{
"name": "name",
"type": "STRING"
}, {
"name": "birthyear",
"type": "INT16",
"optional": true
}, {
"name": "phone",
"type": "INT16",
"unique": true,
"index": true
}]
}, {
"label": "City",
"type": "VERTEX",
"primary": "name",
"properties": [{
"name": "name",
"type": "STRING"
}]
}, {
"label": "Film",
"type": "VERTEX",
"primary": "title",
"properties": [{
"name": "title",
"type": "STRING"
}]
}, {
"label": "HAS_CHILD",
"type": "EDGE"
}, {
"label": "MARRIED",
"type": "EDGE"
}, {
"label": "BORN_IN",
"type": "EDGE",
"properties": [{
"name": "weight",
"type": "FLOAT",
"optional": true
}]
}, {
"label": "DIRECTED",
"type": "EDGE"
}, {
"label": "WROTE_MUSIC_FOR",
"type": "EDGE"
}, {
"label": "ACTED_IN",
"type": "EDGE",
"properties": [{
"name": "charactername",
"type": "STRING"
}]
}, {
"label": "PLAY_IN",
"type": "EDGE",
"properties": [{
"name": "role",
"type": "STRING",
"optional": true
}],
"constraints": [
["Person", "Film"]
]
}]
}
}
```

#### 2.2.9. Import Data
This interface allows users to specify uploaded and verified files as data files and import them to the subgraph specified by the graph parameter. The import process is asynchronous, and the server returns a task id after receiving the import request

- **URI**: /import_data
- **METHOD**: POST
- **REQUEST**:

| body parameter | parameter description | parameter type | necessary |
| ------- |---------------------------|--------|-----|
| graph | name of the subgraph | string | yes |
| schema | schema infomation | json string | yes |
| delimiter | column delimiter | string | yes |
| continueOnError | Whether to skip the error and continue when an error occurs | boolean | no |
| skipPackages | number of packets skipped | string | no |
| taskId | used to restart the failed task | string | no |
| flag | If flag is set to 1, the data file is deleted after the import is successful | string | no |
| other | other parameter | string | no |

- **RESPONSE**:
If successful, the success field in the returned response message will be set to 00

| body parameter | parameter description | parameter type | necessary |
| ------- |---------------------------------------|--------|------------|
| taskId | task id is used to find a import task | string | yes |

**Example request.**

```
{
"graph": "default", //导入的子图名称
"delimiter": ",", //数据分隔符
"continueOnError": true, //遇到错误时是否跳过错误数据并继续导入
"skipPackages": “0”, //跳过的包个数
"flag" : "1",
"schema": {
"files": [{
"DST_ID": "Film", //终点label类型
"SRC_ID": "Person", //起点label类型
"columns": [ //数据格式说明
"SRC_ID", //起点id
"DST_ID", //终点id
"SKIP", //表示跳过此列数据
"charactername" //属性名称
],
"format": "CSV", //数据文件格式类型,支持csv和json
"path": "acted_in.csv", //数据文件名称
"header": 0, //数据从第几行开始
"label": "ACTED_IN" //边的类型
}]
}
}
```

#### 2.2.10. Import Progress Query
This interface is used to query the execution progress of a import task

- **URI**: /import_progress
- **METHOD**: POST
- **REQUEST**:

| body parameter | parameter description | parameter type | necessary |
| ------- |-------------------------------------------|---------|----|
| taskId | task id returned by import_data interface | string ||

- **RESPONSE**:
If successful, the success field in the returned response message will be set to 00

| body parameter | parameter description | parameter type | necessary |
| ------- |--------------------------------------|----------------|-----------|
| success | whether import is successful | boolean | yes |
| reason | reason of the import failure | string | yes if success is false |
| progress | import progress at the current time | string | yes |

**Example request.**

```
{"taskId" : "$taskId"}
```
2 changes: 1 addition & 1 deletion docs/zh-CN/source/15.contacts.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

您有任何对产品的意见和建议,欢迎通过以下联系方式加入讨论,或提出建议。

官网: [www.tugraph.org](https://www.tugraph.org)
官网: [tugraph.tech](https://tugraph.tech)

Github Issue (错误反馈、功能讨论)
[Issue](https://github.com/TuGraph-db/tugraph-db/issues)
Expand Down
Loading

0 comments on commit 5eeaba6

Please sign in to comment.