API_USAGE.md

September 4, 2024 · View on GitHub

Introduction to API

gStore provides API services to users through http and Socket services, and its components are gRPC, ghttp and gServer.

Introduction to HTTP API

We now provide C++, Java, Python, PHP, and Node.js APIs for gRPC and ghttp. Please refer to the examples in api/http/cpp, api/http/java, api/http/python, api/http/php and api/http/nodejs. To use these examples, make sure you have generated the executable files of gRPC or ghttp. Next, please use the bin/grpc or bin/ghttp command to start the service. If you know of a running gRPC or ghttp server that's available for connection, you can also directly connect to it. Then, for the C++ and Java code, you need to compile the sample code in the directory api/http/cpp/example orapi/http/java/example.

HTTP API Framework

The gStore HTTP API is placed in the API/HTTP directory of the gStore root directory and contains the following:

  • gStore/api/http/
    • cpp/ (the C++ API)
      • example/ (Example program using the C++ API)
        • Benchmark.cpp
        • GET-example.cpp
        • POST-example.cpp
        • Transaction-example.cpp
        • Makefile (for compiling the sample code)
      • src/
        • GstoreConnector.cpp (C++ API's source code)
        • GstoreConnector.h
        • Makefile (for compiling the lib)
    • java/ (the Java API)
      • example/ (Example program using the Java API)
        • Benckmark.java
        • GETexample.java
        • POSTexample.java
        • Makefile
      • src/
        • jgsc/
          • GstoreConnector.java (Java API's source code)
        • Makefile
    • python/ (the Python API)
      • example/ (Example program using the Python API)
        • Benchmark.py
        • GET-example.py
        • POST-example.py
      • src/
        • GstoreConnector.py
    • nodejs/ (the Node.js API)
      • example/ (Example program using the Node.js API)
        • POST-example.js
        • GET-example.js
      • src
        • GstoreConnector.js (Node.js API's source code)
        • LICENSE
        • package.json
    • php/ (the PHP API)
      • example/ (Example program using the PHP API)
        • Benchmark.php
        • POST-example.php
        • GET-example.php
      • src/
        • GstoreConnector.php (the PHP API's source code)

For details on how to start and shut down gRPC or ghttp, please see [development documentation] - [Quick Start] - [HTTP API service].

After the API service is started, the gRPC access address is as follows:

http://serverip:port/grpc/

The ghttp access address is as follows:

http://serverip:port/

ServerIP is the IP address of the gStore server, and port is the port on which gRPC or ghttp is started.

Introduction to Socket API

We now provide C++ (Java, Python, PHP, and Node.js will be supported in future versions) API for gServer, the socket API service. Please see api/socket/cpp for the example code. To use these examples, make sure you have generated an executable file for gServer. Next, use the bin/gserver -s command to start the gserver service. If you know of a running gServer that's available for connection, you can also directly connect to it. Then, for the C++ code, you need to compile the sample code in the directory api/socket/cpp/example.

For details on how to start and shut down gServer, please see [development documentation] - [Quick Start] - [Socket API service].

After the Socket API is started, you can connect through the Socket. The default port of gServer is 9000.

Socket API Framework

gStore的Socket API放在gStore根目录的API/Socket目录中,其内容如下: The gStore Socket API is placed in the API/Socket directory of the gStore root directory and contains the following:

  • gStore/api/socket/

    • cpp/ (the C++ API)

      • example/ (Example program using the C++ API)
        • CppAPIExample.cpp
        • Makefile ((for compiling the sample code)
      • src/
        • Client.cpp (C++ API's source code)
        • Client.h
        • Makefile (for compiling the lib)

http API Instruction

ghttp Service Interconnection Mode

The ghttp interface adopts the HTTP protocol and supports multiple ways to access the interface. If the ghttp is started on the port 9000, the interface interconnection content is as follows API address:

http://ip:9000/

The interface supports both GET and POST requests, where GET requests place > > parameters in the URL and POST requests place parameters in the body request.

Note: GET request parameters contain special characters, such as? , @,& and other characters, you need to use urlencode encoding, especially the SPARQL parameter must be encoded

grpc Service Interconnection Mode

The grpc interface adopts the HTTP protocol and supports multiple ways to access the interface. If the grpc is started on the port 9000, the interface connection information is as follows.

API address:

http://ip:9000/grpc

The interface supports both GET and POST requests, where GET requests place parameters in the URL and POST requests place parameters in the body request or use form to express a request.

Post request method 1 (recommended) : the parameter is passed as JSON structure by raw in body in httprequest (Requires RequestHeader's parameter Content-Type to be application/json)

Post request method 2: the parameter is passed as a form (Requires RequestHeader's parameter Content-Type to be application/x-www-form-urlencoded)

Note: If the GET request parameters contain special characters, such as? , @, and &, you need to use the urlencode encoding, especially for the SPARQL parameter.

API List

The red font represents the latest version additions, while the blue font represents the latest version modifications

API nameDefinitionNote
Interface of system
 checkheartbeat signalDetect ghttp heartbeat signal
 loginlogin to databaseIt is used to authenticate user names and passwords
 testConnecttesting connectivityUsed to check whether GHTTP is connected
 getCoreVersionget gStore versionGet the gStore version number
 ipmanageblack/white list managementMaintains a blacklist and whitelist of IP addresses that access gStore
 uploadupload filessupport file types to upload are nt, ttl, n3, rdf, txt.
 downloaddownload filessupport to download files in gstore main directory and its sub directories.
 statquery system resourcesstatistics CPU, memory, disk available space information.
 shutdownclose ghttp
Interface of system operations
 showdisplay graph databaseDisplay a list of all databases
 loadload graph databaseLoad the database into memory
 unloadunload graph databaseUnload the database from memory
 monitormonitor graph databaseCount information about the specified database (such as the number of triples, etc.)
build(update)build graph databaseThe database file must be locally stored on the server
 dropdrop graph databaseLogical deletion and physical deletion can be performed
backup(update)backup databasebackup database information
 backuppathget the backup database pathReturns a list of all backup files in the default backup path.
restore(update)restore databaserestore database information
 queryquery databaseIncluding query, delete, and insert
 exportexport databaseExport database as NT file
batchInsert(update)batch insert dataBatch insert NT data
batchRemove(update)batch delete dataBatch delete NT data
 renamerename graph databasemodify graph database name.
checkOperationState(new)Query asynchronous operation statusQuery the asynchronous execution status of build, backup, restore, batch_insert, batch_remove
Interface of database transaction
 beginStart transactionTransaction starts and needs to be used in conjunction with TQuery
 tqueryQuerying the database (with transactions)Data queries with transaction mode (insert and DELETE only)
 commitcommit transactionsCommit the transaction after it completes
 rollbackrollback transactionRoll back the transaction to begin state
 checkpointwrite data to a diskAfter an INSERT or delete operation is performed on the database, manually checkpoint is required
Interface of user management
 showuserdisplay all user listDisplay a list of all users
 usermanageuser managementAdd, delete, or modify user information
 userprivilegemanageuser privilege managementAdd, delete, or modify user's privilege information
 userpasswordmodify user's passwordmodify user's password
Interface of custom function
 funqueryQuery operator functionGets a list of user-defined graph analysis functions
 funcudbManage operator functionAdds, modifies, deletes, or compiles operator function
 funreviewPreview operator functionView the latest generated graph analysis function source code
Interface of log
 txnlogObtain transaction log informationReturns transcation log information as JSON
 querylogdateGets the date list of query logsReturns the date list of existing query logs
 querylogGet query log informationReturns query log information as JSON
 accesslogdateGet the date of the API logReturns the date list of existing API logs
 accesslogGet API access logsReturns API access log information as JSON
Interface of reason engine(new)
 addReasonadd reason
 listReasonlist reason
 compileReasoncompile reason
 executeReasonexecute reason
 disableReasondisable reason
 showReasonshow reason
 removeReasonremove reason

API Specific Instruction

The input and output parameters of each interface are specified in this section. Assume that the IP address of the GHTTP server is 127.0.0.1 and the port is 9000 Interfaces of system

Interfaces of System

check

Brief description

  • Detect ghttp heartbeat signal

Request mode

  • GET/POST

Parameter transfer mode

  • GET request, the parameters are passed directly as the URL
  • POST request, raw in body in Httprequest, passed asJSON structure

Parameter

parameter nameMandatoryTypeNote
operationyesstringOperation name, fixed value is check

Return value

Parameter nameTpyeNote
StatusCodeintReturn value code value (refer to Appendix: Return value code table for details)
StatusMsgstringReturn specific information

Return sample

{
    "StatusCode": 0,
    "StatusMsg": "the ghttp server is running..."
}

login

Brief description

  • User login (verify username and password)
  • Updates in this version: the full path information of RootPath will be returned after successful login

Request mode

  • GET/POST

Parameter transfer mode

  • GET request, the parameters are passed directly as the URL
  • POST request, raw in body in httprequest , passed as JSON

Parameter

Parameter nameMandatoryTypeNote
operationyesstringOperation name, fixed value is login
usernameyesstringUser name
passwordyesstringPassword (plain text)
encryptionnostringIf the value is null, the password is in plain text. If the value is 1, the password is encrypted using md5

Return value

Parameter nameTypeNote
StatusCodeintReturn value code value (refer to Appendix: Return value code table for details)
StatusMsgstringReturn specific information
CoreVersionstringKernel version
licensetypestringCertificate type (Open Source or Enterprise)
RootPathstringFull path to the gStore root directory
typestringHTTP service type

Return sample

{
	"StatusCode": 0,
	"StatusMsg": "login successfully",
	"CoreVersion": "1.0.0",
	"licensetype": "opensource",
	"Rootpath": "/data/gstore",
	"type": "ghttp"
}
#### testConnect

Brief description

  • Test whether the server can connect (for Workbench)
  • Updates in this version: added HTTP service type in the return value

Request mode

  • GET/POST

Parameter transfer mode

  • GET request, the parameters are passed directly as the URL
  • POST request, raw in body in httprequest , passed as JSON

Parameter

Parameter nameMandatoryTypeNote
operationyesstringOperation name, fixed value is testConnect
usernameyesstringUser name
passwordyesstringPassword (plain text)
encryptionnostringIf the value is null, the password is in plain text. If the value is 1, the password is encrypted using md5

Return value

Parameter nameTypeNote
StatusCodeintReturn value code value (refer to Appendix: Return value code table for details)
StatusMsgstringReturn specific information
CoreVersionstringKernel version
licensetypestringCertificate type (Open Source or Enterprise)
typestringHTTP service type (fixed as ghttp)

Return sample

{
	"StatusCode": 0,
	"StatusMsg": "success",
	"CoreVersion": "1.0.0",
	"licensetype": "opensource",
	"type": "ghttp"
}

getCoreVersion

Brief description

  • Get the server version number (for Workbench)

Request mode

  • GET/POST

Parameter transfer mode

  • GET request, the parameters are passed directly as the URL
  • POST request, raw in body in httprequest , passed as JSON

Parameter

Parameter nameMandatoryTypeNote
operationyesstringOperation name, fixed value is getCoreVersion
usernameyesstringUser name
passwordyesstringPassword (plain text)
encryptionnostringIf the value is null, the password is in plain text. If the value is 1, the password is encrypted using md5

Return value

Parameter nameTypeNote
StatusCodeintReturn value code value (refer to Appendix: Return value code table for details)
StatusMsgstringReturn specific information
CoreVersionstringKernel version
typestringHTTP service type (fixed as ghttp)

Return sample

{
	"StatusCode": 0,
	"StatusMsg": "success",
	"CoreVersion": "1.0.0",
	"type": "ghttp"
}

ipmanage

Brief description

  • Blacklist and whitelist management

Request mode

  • GET/POST

Parameter transfer mode

  • GET request, the parameters are passed directly as the URL
  • POST request, raw in body in Httprequest, passed as JSON structure

Parameter

Querying the blacklist and whitelist:

Parameter nameMandatoryTypeNote
operationyesstringOperation name, fixed value is ipmanage
usernameyesstringUser name
passwordyesstringPassword (plain text)
encryptionnostringIf the value is null, the password is in plain text. If the value is 1, the password is encrypted using md5
typeyesstringOperation type, fixed value is 1

Saving the blacklist and whitelist:

Parameter nameMandatoryTypeNote
operationyesstringOperation name, fixed value is ipmanage
usernameyesstringuser name
passwordyesstringPassword (plain text)
encryptionnostringIf the value is null, the password is in plain text. If the value is 1, the password is encrypted using md5
typeyesstringOperation type, fixed value is 2
ip_typeyesstringList type, 1-Blacklist 2-Whitelist
ipsyesstringIP List (Multiple separated by , supporting range configuration, using - connections such as ip1-ip2)
//Post example
{
    "operation": "ipmanage",
    "username": "root",
    "password": "123456",
    "type": "2",
    "ip_type":"1",
    "ips": "192.168.1.111,192.168.1.120-192.168.1.129"
}

Return value

ParameterTypeNote
StatusCodeintReturn value code value (refer to Appendix: Return value code table for details)
StatusMsgstringReturn specific information
ResponseBodyObjectReturn data (only for queries)
  ip_typestringList type, 1-Blacklist 2-Whitelist
  ipsarrayIP List

Return sample

//result of querying the black list and white list
{
    "StatusCode": 0,
    "StatusMsg": "success",
    "ResponseBody": {
        "ip_type": "1",
        "ips": [
            "192.168.1.111",
            "192.168.1.120-192.168.1.129"
        ]
    }
}
// result of saving the black list and white list
{
    "StatusCode": 0,
    "StatusMsg": "success"
}

upload

Brief Description

  • Uploading files. Currently supported file formats include nt, ttl, and txt

Request URL

  • ghttp service:http://127.0.0.1:9000/file/upload (note that the address has changed)
  • grpc service: http://127.0.0.1:9000/grpc/file/upload(note that the address has changed)

Request method

  • POST

Parameter Transfer Methods

  • POST request, form-data in the body of httprequest(requires the RequestHeader parameter Content-Type: multipart/form-data

Parameters

Parameter nameRequiredTypeDescription
usernameYesstringUsername
passwordYesstringPassword (clear text)
encryptionNostringIf it is empty, the password is clear text. If it is 1, it means md5 encryption is used
fileYesboudaryBinary file stream of the file to be uploaded

Return Value

Parameter nameTypeDescription
StatusCodeintReturn value code value (please refer to the attached table: Return Value Code Table)
StatusMsgstringReturns specific information
filepathstringThe relative path address returned after successful upload

Return Sample:

{
    "StatusCode": 0,
    "StatusMsg": "success",
    "filepath": "./upload/test_20221101164622.nt"
}

download

Brief Description

  • Download files, currently supports downloading files from the gStore root directory.

Request URL

  • ghttp service:http://127.0.0.1:9000/file/download (Note that the address has changed)
  • grpc service: http://127.0.0.1:9000/grpc/file/upload(Note that the address has changed)

Request method

  • POST

Parameter Transfer Method

  • POST request: the parameters are passed in the form of Form data (requires the RequestHeader parameter Content-Type: application/x-www-form-urlencoded)

Parameters

Parameter nameRequiredTypeDescription
usernameYesstringUsername (the default username is system)
passwordYesstringPassword (clear text)
encryptionNostringIf it is empty, the password is clear text. If it is 1, it means md5 encryption is used
filepathYesstringThe path of the file to be downloaded (only supports downloading files from the main directory and subdirectories of gstore)

Return Value

  • Binary stream response

Return Sample:

Content-Range: bytes 0-389/389
Content-Type: application/octet-stream
Date: Tue, 01 Nov 2022 17:21:40 GMT
Content-Length: 389
Connection: Keep-Alive

state

Brief Description

  • Statistics on system resource information

Request URL

  • ghttp service: http://127.0.0.1:9000/ghttp/api
  • grpc service:http://127.0.0.1:9000/grpc/api

Request method

  • GET/POST

Parameter Transfer Method

  • GET request, the parameters are passed directly as the URL
  • POST request: the parameters are passed in the form of Form data (requires the RequestHeader parameter Content-Type: application/x-www-form-urlencoded)

Parameters

Parameter nameRequiredTypeDescription
operationyesstringOperation name, fixed value is stat
usernameYesstringUsername (the default username is system)
passwordYesstringPassword (plain text)
encryptionNostringIf it is empty, the password is clear text. If it is 1, it means md5 encryption is used

Return Value

Parameter nameTypeDescription
StatusCodeintReturn value code value (please refer to the attached table: Return Value Code Table)
StatusMsgstringReturns specific information
cup-usagestringCPU usage ratio
mem_usagestringMemory usage (in MB)
disk_availablestringAvailable disk space (in MB)

Return Sample:

{
    "StatusCode": 0,
    "StatusMsg": "success",
    "cpu_usage": "10.596026",
    "mem_usage": "2681.507812",
    "disk_available": "12270"
}

shutdown

Brief description

  • close ghttp

Request URL

  • ghttp service: http://127.0.0.1:9000/shutdown(Note that the address has changed)

  • grpc service: http://127.0.0.1:9000/grpc/shutdown(Note that the address has changed) Request mode

  • GET/POST

Parameter transfer mode

  • GET request, the parameters are passed directly as the URL
  • POST request, raw in body in Httprequest, passed asJSON structure

Parameter

Parameter nameMandatoryTypeNote
usernameyesstringuser name(default user name is system)
passwordyesstringPassword(This password need to be viewed in the server's system.db/password[port].txt file)

Return value

Parameter nameTypeNote
StatusCodeintReturn value code value (refer to Appendix: Return value code table for details)
StatusMsgstringReturn specific information

Return sample

{
    "StatusCode": 0,
    "StatusMsg": "Server stopped successfully."
}

Interfaces of System Operation

show

Brief description

  • Display all database list

Request mode

  • GET/POST

Parameter transfer mode

  • GET request, the parameters are passed directly as the URL
  • POST request, raw in body in Httprequest, passed asJSON structure

Parameter

Parameter nameMandatoryTypeNote
operationyesstringOperation name, fixed value is show
usernameyesstringuser name
passwordyesstringPassword (plain text)
encryptionNostringIf it is empty, the password is clear text. If it is 1, it means it is encrypted with md5.

Return value

Parameter nameTypeNote
StatusCodeintReturn value code value (refer to Appendix: Return value code table for details)
StatusMsgstringReturn specific information
ResponseBodyJSONArrayJSON arrays (each of which is a database information)
  databasestringdatabase name
  creatorstringcreator
  built_timestringcreate time
  statusstringdatabase status

Return sample

{
    "StatusCode": 0,
    "StatusMsg": "Get the database list successfully!",
    "ResponseBody": [
        {
            "database": "lubm",
            "creator": "root",
            "built_time": "2021-08-22 11:08:57",
            "status": "loaded"
        },
        {
            "database": "movie",
            "creator": "root",
            "built_time": "2021-08-27 20:56:56",
            "status": "unloaded"
        }
    ]
}

load

Brief description

  • Loading a database into memory is a prerequisite for many operations, such as query and monitor.

Request mode

  • GET/POST

Parameter transfer mode

  • GET request: the parameters are passed directly as the URL
  • POST request: raw in body in httprequest , passed as JSON

Parameter

Parameter nameMandatoryTypeNote
operationyesstringOperation name, fixed value is load
usernameyesstringUser name
encryptionnostringIf the value is null, the password is in plain text. If the value is 1, the password is encrypted using md5
passwordyesstringPassword (plain text)
db_nameyesstringDatabase name (.db is not required)
csrnostringWhether to load CSR resources, default is 0 (set to 1 when using advanced query functions)

Return value

Parameter nameTypeNote
StatusCodeintReturn value code value (refer to Appendix: Return value code table for details)
StatusMsgstringReturn specific information
csrstringWhether to load CSR resources

Return sample

{
	"StatusCode": 0,
	"StatusMsg": "Database loaded successfully.",
	"csr": "1"
}

unload

Brief description

  • Unload the database from memory (all changes are flushed back to hard disk)

Request mode

  • GET/POST

Parameter transfer mode

  • GET request, the parameters are passed directly as the URL
  • POST request, raw in body in Httprequest, passed asJSON structure

Parameter

Parameter nameMandatoryTypeNote
operationyesstringOperation name, fixed value is unload
db_nameyesstringDatabase name (.db is not required)
usernameyesstringuser name
passwordyesstringPassword (plain text)
encryptionnostringIf the value is null, the password is in plain text. If the value is 1, the password is encrypted using md5

Return value

Parameter nameTypeNote
StatusCodeintReturn value code value (refer to Appendix: Return value code table for details)
StatusMsgstringReturn specific information

Return sample

{
    "StatusCode": 0,
    "StatusMsg": "Database unloaded."
}

monitor

Brief description

  • Get database statistics (database needs to be loaded)

Request mode

  • GET/POST

Parameter transfer mode

  • GET request, the parameters are passed directly as the URL
  • POST request, raw in body in Httprequest, passed asJSON

Parameter

Parameter nameMandatoryTypeNote
operationyesstringOperation name, fixed value is monitor
usernameyesstringUser name
passwordyesstringPassword (plain text)
encryptionnostringIf the value is null, the password is in plain text. If the value is 1, the password is encrypted using md5
db_nameyesstringDatabase name (.db is not required)

Return value

Parameter nameTypeNote
StatusCodeintReturn value code value (refer to Appendix: Return value code table for details)
StatusMsgstringReturn specific information
databasestringdatabase name
creatorstringcreator
builtTimestringcreate time
tripleNumstringnumber of triples
entityNumintnumber of entities
literalNumintnumber of characters (attribute value)
subjectNumintnumber of subjects
predicateNumintnumber of objects
connectionNumintnumber of connections
diskUsedintdisk space(MB)
subjectListArrayEntity type statistics

Return sample

{
    "StatusCode": 0,
    "StatusMsg": "success",
    "database": "test_lubm",
    "creator": "root",
    "builtTime": "2021-08-27 21:29:46",
    "tripleNum": "99550",
    "entityNum": 28413,
    "literalNum": 0,
    "subjectNum": 14569,
    "predicateNum": 17,
    "connectionNum": 0,
    "diskUsed": 3024,
    "subjectList": [
        {
            "name": "ub:Lecturer",
            "value": 93
        },
        {
            "name": "ub:AssistantProfessor",
            "value": 146
        },
        {
            "name": "ub:University",
            "value": 1
        }
    ]
}

build(update in this version)

Brief description

  • Create a database based on existing NT files, or build an empty library (supported in version 1.2)
  • The file must exist on the gStore server
  • You can first upload data files to the gStore server through the upload interface

Request mode

  • GET/POST

Parameter transfer mode

  • GET request, the parameters are passed directly as the URL
  • POST request, raw in body in httprequest , passed as JSON

Parameter

Parameter nameMandatoryTypeNote
operationyesstringOperation name, fixed value is build
usernameyesstringUser name
passwordyesstringPassword (plain text)
encryptionnostringIf the value is null, the password is in plain text. If the value is 1, the password is encrypted using md5
db_nameyesstringdatabase name(no need .db)
db_pathnostringDatabase file path, supported file types are (can be absolute path or relative path, relative path is referenced from gStore installation root directory)
asyncnostringIf async is "true", immediately return the query opd_id, the server's asynchronous processing logic, and the client can call the checkOperationState interface through opd_id to view the operation status information
callbacknostringCallback interface, for example: http://127.0.0.1:8080/callback

Return value

Parameter nameTypeNote
StatusCodeintReturn value code value (refer to Appendix: Return value code table for details)
StatusMsgstringReturn specific information
failed_numintNumber of failed constructions
opt_idstringReturn the operation opd_id, the client can call the checkOperationState interface through opd_id to view the operation status information

Return sample(defult)

{
    "StatusCode": 0,
    "StatusMsg": "Import RDF file to database done.",
    "failed_num": 0,
    "opt_id": "XXXX-XXXX-XXXX-XXXX"
}

Return sample(async="true")

{
    "StatusCode": 0,
    "StatusMsg": "Operation Success.",
    "opt_id": "XXXX-XXXX-XXXX-XXXX"
}

Return sample(callback="http://127.0.0.1:8080/callback")

#push data to callback address
{
    "operation": "build",
    "StatusCode": 0,
    "StatusMsg": "Import RDF file to database done.",
    "failed_num": 0,
    "opt_id": "XXXX-XXXX-XXXX-XXXX"
}

drop

Brief description

  • Delete the database (either logically or physically)

Request mode

  • GET/POST

Parameter transfer mode

  • GET request, the parameters are passed directly as the URL
  • POST request, raw in body in Httprequest, passed asJSON structure

Parameter

Parameter nameMandatoryTypeNote
operationyesstringOperation name, fixed value is drop
db_nameyesstringDatabase name (.db is not required)
usernameyesstringuser name
passwordyesstringPassword (plain text)
encryptionnostringIf the value is null, the password is in plain text. If the value is 1, the password is encrypted using md5
is_backupnostringTrue: Logical deletion, false: represents physical deletion (default true),if it's logical deletion, change the file folder to .bak file foder, user can change the folder name to. db and add the folder to the system database by calling bin/ ginit-db database name

Return value

Parameter nameTypeNote
StatusCodeintReturn value code value (refer to Appendix: Return value code table for details)
StatusMsgstringReturn specific information

Return sample

{
    "StatusCode": 0,
    "StatusMsg": "Database test_lubm dropped."
}

backup(update in this version)

Brief description

  • Back up database

Request mode

  • GET/POST

Parameter transfer mode

  • GET request, the parameters are passed directly as the URL
  • POST request, raw in body in Httprequest, passed asJSON structure

Parameter

Parameter nameMandatoryTypeNote
operationyesstringOperation name, fixed value is backup
usernameyesstringuser name
passwordyesstringPassword (plain text)
encryptionnostringIf the value is null, the password is in plain text. If the value is 1, the password is encrypted using md5
db_nameyesstringdatabase that need operaions
backup_pathnostringThe backup file path can be relative or absolute. The relative path uses the gStore root directory as reference. The default path is the backup directory in the gStore root directory
asyncnostringIf async is "true", immediately return the query opd_id, the server's asynchronous processing logic, and the client can call the checkOperationState interface through opd_id to view the operation status information
callbacknostringCallback interface, for example: http://127.0.0.1:8080/callback

Return value

Parameter nameTypeNote
StatusCodeintReturn value code value (refer to Appendix: Return value code table for details)
StatusMsgstringReturn specific information
backupfilepathstringBackup file path (this value can be used as the input parameter value for restore)
opt_idstringReturn the operation opd_id, the client can call the checkOperationState interface through opd_id to view the operation status information

Return sample (defult)

{
    "StatusCode": 0,
    "StatusMsg": "Database backup successfully.",
    "backupfilepath": "./backups/lubm.db_210828211529",
    "opt_id": "XXXX-XXXX-XXXX-XXXX"
}

Return sample (async="true")

{
    "StatusCode": 0,
    "StatusMsg": "Operation Success.",
    "opt_id": "XXXX-XXXX-XXXX-XXXX"
}

Return sample (callback="http://127.0.0.1:8080/callback")

{
    "operation": "backup",
    "StatusCode": 0,
    "StatusMsg": "Database backup successfully.",
    "backupfilepath": "./backups/lubm.db_210828211529",
    "opt_id": "XXXX-XXXX-XXXX-XXXX"
}

backuppath

Brief description

  • Obtain all backup files of the database located under the default backup path.

Request Methods

  • GET/POST

Parameter Passing Methods

  • For GET requests, parameters are passed directly in the URL.
  • For POST requests, the raw field in the body of the httprequest is passed in JSON structure.

Parameters

Parameter NameRequiredTypeDescription
operationYesstringOperation name, fixed value is backuppath
usernameYesstringUsername
passwordYesstringPassword (plaintext)
encryptionNostringIf it is empty, the password is plaintext. If it is 1, it means encryption with MD5
db_nameYesstringDatabase name that needs to be queried

Return Values

Parameter NameTypeDescription
StatusCodeintegerReturn value code (please refer to the attached table for specific values).
StatusMsgstringSpecific return information.
pathsArrayBackup file paths (this value can be used as input for restore operation).

Return sample

{
    "StatusCode": 0,
    "StatusMsg": "success",
    "paths": [
        "./backups/lubm.db_220828211529",
        "./backups/lubm.db_221031094522"
    ]
}

restore(update in this version)

Brief description

  • Restore database

Request mode

  • GET/POST

Parameter transfer mode

  • GET request, the parameters are passed directly as the URL
  • POST request, raw in body in Httprequest, passed asJSON structure

Parameter

Parameter nameMandatoryTypeNote
operationyesstringOperation name, fixed value is restore
usernameyesstringUser name
passwordyesstringPassword (plain text)
encryptionnostringIf it is empty, the password is plaintext. If it is 1, it means encryption with MD5.
db_nameyesstringDatabase that need operations
backup_pathnostringThe full time-stamped path of the backup file (can be a relative path or an absolute path. The relative path is based on the gStore root directory). The default path is the backup directory in the gStore root directory
asyncnostringIf async is "true", immediately return the query opd_id, the server's asynchronous processing logic, and the client can call the checkOperationState interface through opd_id to view the operation status information
callbacknostringCallback interface, for example: http://127.0.0.1:8080/callback

Return value

Parameter nameTypeNote
StatusCodeintReturn value code value (refer to Appendix: Return value code table for details)
StatusMsgstringReturn specific information
opt_idstringReturn the operation opd_id, the client can call the checkOperationState interface through opd_id to view the operation status information

Return sample (defult)

{
    "StatusCode": 0,
    "StatusMsg": "Database lumb restore successfully.",
    "opt_id": "XXXX-XXXX-XXXX-XXXX"
}

Return sample (async="true")

{
    "StatusCode": 0,
    "StatusMsg": "Operation Success.",
    "opt_id": "XXXX-XXXX-XXXX-XXXX"
}

Return sample (callback=“http://127.0.0.1:8080/callback")

{
    "StatusCode": 0,
    "StatusMsg": "Database lumb restore successfully.",
    "opt_id": "XXXX-XXXX-XXXX-XXXX"
}

query

Brief description

  • query the database

Request mode

  • GET/POST

Parameter transfer mode

  • GET request, the parameters are passed directly as the URL
  • POST request, raw in body in Httprequest, passed asJSON structure

Parameter

Parameter nameMandatoryTypeNote
operationyesstringOperation name, fixed value is query
usernameyesstringuser name
passwordyesstringPassword (plain text)
encryptionnostringIf it is empty, the password is plaintext. If it is 1, it means encryption with MD5.
db_nameyesstringdatabase that need operations
formatnostringThe result set returns in json, HTML, and file format. The default is JSOn
sparqlyesstringSparql statement to execute (SPARQL requires URL encoding if it is a GET request)

Return value

Parameter nameTypeNote
StatusCodeintReturn value code value (refer to Appendix: Return value code table for details)
StatusMsgstringReturn specific information
headobjectHead information
  linkarray
  varsarray
resultsobjectResult information (please refer to the return example for details)
  bindingsarray
AnsNumintNumber of results
OutputLimitintMaximum number of return results (-1 for no limit)
ThreadIdstringQuery thread ID
QueryTimestringQuery time (milliseconds)

Return sample

{
    "head": {
        "link": [],
        "vars": [
            "x"
        ]
    },
    "results": {
        "bindings": [
            {
                "x": {
                    "type": "uri",
                    "value": "House of Flying Daggers"
                }
            },
            {
                "x": {
                    "type": "uri",
                    "value": "Blood Brothers"
                }
            },
            {
                "x": {
                    "type": "uri",
                    "value": "flower"
                }
            }
        ]
    },
    "StatusCode": 0,
    "StatusMsg": "success",
    "AnsNum": 15,
    "OutputLimit": -1,
    "ThreadId": "140595527862016",
    "QueryTime": "1"
}

export

Brief description

  • export database

Request mode

  • GET/POST

Parameter transfer mode

  • GET request, the parameters are passed directly as the URL
  • POST request, raw in body in Httprequest, passed asJSON structure

Parameter

Parameter nameMandatoryTypeNote
operationyesstringOperation name, fixed value is restore
usernameyesstringuser name
passwordyesstringPassword (plain text)
encryptionnostringIf it is empty, the password is plaintext. If it is 1, it means encryption with MD5.
db_nameyesstringdatabase that need operations
db_pathnostringExport path (gstore root by default)

Return value

Parameter nameTypeNote
StatusCodeintReturn value code value (refer to Appendix: Return value code table for details)
StatusMsgstringReturn specific information
filepathstringPath for exporting files

Return sample

{
    "StatusCode": 0,
    "StatusMsg": "Export the database successfully.",
    "filepath": "export/lubm_210828214603.nt"
}

batchInsert(update in this version)

Brief description

  • batch insert data

Request mode

  • GET/POST

Parameter transfer mode

  • GET request, the parameters are passed directly as the URL
  • POST request, raw in body in Httprequest, passed asJSON structure

Parameter

Parameter nameMandatoryTypeNote
operationyesstringOperation name, fixed value is batchInsert
usernameyesstringUser name
passwordyesstringPassword (plain text)
encryptionnostringIf it is empty, the password is plaintext. If it is 1, it means encryption with MD5.
db_nameyesstringDatabase name
filenostringThe data to be inserted in the nt file or zip package (which can be a relative path or an absolute path) cannot be empty at the same time as the dir parameter. When both have values, take the file parameter
dirnostringThe data to be inserted into the nt folder (which can be a relative path or an absolute path) cannot be empty at the same time as the file parameter. When both have values, take the file parameter
asyncnostringIf async is "true", immediately return the query opd_id, the server's asynchronous processing logic, and the client can call the checkOperationState interface through opd_id to view the operation status information
callbacknostringCallback interface, for example: http://127.0.0.1:8080/callback

Return value

Parameter nameTypeNote
StatusCodeintReturn value code value (refer to Appendix: Return value code table for details)
StatusMsgstringReturn specific information
success_numstringNumber of successful executions
failed_numsrtingNumber of failed executions
opt_idstringReturn the operation opd_id, the client can call the checkOperationState interface through opd_id to view the operation status information

Return Sample (defult)

{
    "StatusCode": 0,
    "StatusMsg": "Batch insert data successfully.",
    "success_num": 25,
    "failed_num": 0,
    "opt_id": "XXXX-XXXX-XXXX-XXXX"
}

Return Sample (async=“true”)

{
    "StatusCode": 0,
    "StatusMsg": "Operation Success.",
    "opt_id": "XXXX-XXXX-XXXX-XXXX"
}

Return Sample (callback=“http://127.0.0.1:8080/callback”)

#push data to callback address
{
    "operation": "batchInsert",
    "StatusCode": 0,
    "StatusMsg": "Batch insert data successfully.",
    "success_num": 25,
    "failed_num": 0,
    "opt_id": "XXXX-XXXX-XXXX-XXXX"
}

batchRemove(update in this version)

Brief description

  • batch remove data

Request mode

  • GET/POST

Parameter transfer mode

  • GET request, the parameters are passed directly as the URL
  • POST request, raw in body in Httprequest, passed asJSON structure

Parameter

Parameter nameMandatoryTypeNote
operationyesstringOperation name, fixed value is batchRemove
usernameyesstringUser name
passwordyesstringPassword (plain text)
encryptionnostringIf it is empty, the password is plaintext. If it is 1, it means encryption with MD5.
db_nameyesstringDatabase name
filenostringData NT files to be deleted (can be relative or absolute paths)
asyncnostringIf async is "true", immediately return the query opd_id, the server's asynchronous processing logic, and the client can call the checkOperationState interface through opd_id to view the operation status information
callbacknostringCallback interface, for example: http://127.0.0.1:8080/callback

Return value

Parameter nameTypeNote
StatusCodeintReturn value code value (refer to Appendix: Return value code table for details)
StatusMsgstringReturn specific information
success_numstringNumber of successful executions
opt_idstringReturn the operation opd_id, the client can call the checkOperationState interface through opd_id to view the operation status information

Return Sample (defult)

{
    "StatusCode": 0,
    "StatusMsg": "Batch remove data successfully.",
    "success_num": 25,
    "failed_num": 0,
    "opt_id": "XXXX-XXXX-XXXX-XXXX"
}

Return Sample (async=“true”)

{
    "StatusCode": 0,
    "StatusMsg": "Operation Success.",
    "opt_id": "XXXX-XXXX-XXXX-XXXX"
}

Return Sample (callback=“http://127.0.0.1:8080/callback”)

#push data to callback address
{
    "operation": "batchRemove",
    "StatusCode": 0,
    "StatusMsg": "Batch remove data successfully.",
    "success_num": 25,
    "opt_id": "XXXX-XXXX-XXXX-XXXX"
}

rename

Brief Description

  • Rename the database.

Request method

  • GET/POST

Parameter Transfer Method

  • For GET requests, parameters are passed directly in the URL.
  • For POST requests, the raw field in the body of the httprequest is used to pass parameters in JSON structure.

Parameters

Parameter nameRequiredTypeDescription
operationYesstringOperation name, the fixed value is rename
usernameYesstringUsername
passwordYesstringPassword (clear text)
encryptionNostringIf it is empty, the password is clear text. If it is 1, it means that md5 encryption is used.
db_nameYesstringDatabase name
new_nameYesstringNew name of the database

Return value

Parameter nameTypeDescription
StatusCodeintReturn value code value (please refer to the attached table: Return Value Code Table)
StatusMsgstringReturns specific information

Return Sample:

{
    "StatusCode": 0,
    "StatusMsg": "success"
}

checkOperationState

Brief description

  • Query asynchronous operation status (build, backup, restore, batchInsert, batchRemove)

Request mode

  • GET/POST

Parameter transfer mode

  • GET request, the parameters are passed directly as the URL
  • POST request, raw in body in Httprequest, passed asJSON structure

Parameter

Parameter nameMandatoryTypeNote
operationyesstringOperation name, fixed value is checkOperationState
usernameyesstringUser name
passwordyesstringPassword (plain text)
encryptionnostringIf it is empty, the password is plaintext. If it is 1, it means encryption with MD5.
opt_idyesstringOperation number

Return value

Parameter nameTypeNote
StatusCodeintReturn value code value (refer to Appendix: Return value code table for details)
StatusMsgstringReturn specific information
stateintexecution state(0 executing , -1 failed execution, 1 successfu execution)
success_numintNumber of successful executions
failed_numintNumber of failed executions

Return Sample

{
    "StatusCode": 0,
    "StatusMsg": "Batch insert data successfully.",
    "state": 1,
    "success_num": 100,
    "failed_num": 0
}

Interface of Database Transaction

begin

Brief description

  • start transaction

Request mode

  • GET/POST

Parameter transfer mode

  • GET request, the parameters are passed directly as the URL
  • POST request, raw in body in Httprequest, passed asJSON structure

Parameter

Parameter nameMandatoryTypeNote
operationyesstringOperation name, fixed value is begin
usernameyesstringUser name
passwordyesstringPassword (plain text)
encryptionnostringIf it is empty, the password is plaintext. If it is 1, it means encryption with MD5.
db_nameyesstringDatabase name
isolevelyesstringTransaction isolation level 1:RC(read committed) 2:SI(snapshot isolation) 3:SR(seriablizable)

Return value

Parameter nameTypeNote
StatusCodeintReturn value code value (refer to Appendix: Return value code table for details)
StatusMsgstringReturn specific information
TIDstringTransaction ID(this ID is important enough to take as a parameter

Return sample

{
    "StatusCode": 0,
    "StatusMsg": "transaction begin success",
    "TID": "1"
}

tquery

Brief description

  • query the transaction type

Request mode

  • GET/POST

Parameter transfer mode

  • GET request, the parameters are passed directly as the URL
  • POST request, raw in body in Httprequest, passed asJSON structure

Parameter

Parameter nameMandatoryTypeNote
operationyesstringOperation name, fixed value is tquery
usernameyesstringUser name
passwordyesstringPassword (plain text)
encryptionnostringIf it is empty, the password is plaintext. If it is 1, it means encryption with MD5.
db_nameyesstringDatabase name
tidyesstringTransaction ID
sparqlyesstringsparql statement

Return value

Parameter NameTypeDescription
StatusCodeintReturn value code (please refer to the attached table for specific values)
StatusMsgstringSpecific return information

Return sample

{
    "StatusCode": 0,
    "StatusMsg": "success"
}

commit

Brief description

  • submit transaction

Request mode

  • GET/POST

Parameter transfer mode

  • GET request, the parameters are passed directly as the URL
  • POST request, raw in body in Httprequest, passed asJSON structure

Parameter

Parameter nameMandatoryTypeNote
operationyesstringOperation name, fixed value is commit
usernameyesstringUser name
passwordyesstringPassword (plain text)
encryptionnostringIf it is empty, the password is plaintext. If it is 1, it means encryption with MD5.
db_nameyesstringDatabase name
tidyesstringTransaction ID

Return value

Parameter nameTypeNote
StatusCodeintReturn value code value (refer to Appendix: Return value code table for details)
StatusMsgstringReturn specific information

Return sample

{
    "StatusCode": 0,
    "StatusMsg": "transaction commit success. TID: 1"
}

rollback

Brief description

  • Rollback trasnsaction

Request mode

  • GET/POST

Parameter transfer mode

  • GET request, the parameters are passed directly as the URL
  • POST request, raw in body in Httprequest, passed asJSON structure

Parameter

Parameter nameMandatoryTypeNote
operationyesstringOperation name, fixed value is rollback
usernameyesstringUser name
passwordyesstringPassword (plain text)
encryptionnostringIf it is empty, the password is plaintext. If it is 1, it means encryption with MD5.
db_nameyesstringDatabase name
tidyesstringTransaction ID

Return value

Parameter nameTypeNote
StatusCodeintReturn value code value (refer to Appendix: Return value code table for details)
StatusMsgstringReturn specific information

Return sample

{
    "StatusCode": 0,
    "StatusMsg": "transaction rollback success. TID: 2"
}

checkpoint

Brief description

  • Received Flush data back to hard disk (to make data final)

Request mode

  • GET/POST

Parameter transfer mode

  • GET request, the parameters are passed directly as the URL
  • POST request, raw in body in Httprequest, passed asJSON structure

Parameter

Parameter nameMandatoryTypeNote
operationyesstringOperation name, fixed value is checkpoint
usernameyesstringUser name
passwordyesstringPassword (plain text)
encryptionnostringIf it is empty, the password is plaintext. If it is 1, it means encryption with MD5.
db_nameyesstringDatabase name

Return value

Parameter nameTypeNote
StatusCodeintReturn value code value (refer to Appendix: Return value code table for details)
StatusMsgstringReturn specific information

Return sample

{
    "StatusCode": 0,
    "StatusMsg": "Database saved successfully."
}

Interfaces of User Management

showuser

Brief description

  • Display all user information

Request mode

  • GET/POST

Parameter transfer mode

  • GET request, the parameters are passed directly as the URL
  • POST request, raw in body in Httprequest, passed asJSON structure

Parameter

Parameter nameMandatoryTypeNote
operationyesstringOperation name, fixed value is showuser
usernameyesstringuser name
passwordyesstringPassword (plain text)
encryptionNostringIf it is empty, the password is clear text. If it is 1, it means it is encrypted with md5.

Return value

Parameter nameTypeNote
StatusCodeintReturn value code value (refer to Appendix: Return value code table for details)
StatusMsgstringReturn specific information
ResponseBodyJsonArrayJSON object array
  usernamestringuser name
  passwordstringpassword
  query_privilegestringQuery permissions (database names separated by commas)
  update_privilegestringUpdate permissions (database names separated by commas)
  load_privilegestringLoad permissions (database names separated by commas)
  unload_privilegestringUnload permissions (database names separated by commas)
  backup_privilegestringBack up permissions (database names separated by commas)
  restore_privilegestringRestore permissions (database names separated by commas)
  export_privilegestringExport permissions (database names separated by commas)

Return sample

{
    "StatusCode": 0,
    "StatusMsg": "success",
    "ResponseBody": [
        {
            "username": "liwenjie",
            "password": "shuaige1982",
            "query_privilege": "",
            "update_privilege": "",
            "load_privilege": "",
            "unload_privilege": "",
            "backup_privilege": "",
            "restore_privilege": "",
            "export_privilege": ""
        },
        {
            "username": "root",
            "password": "123456",
            "query_privilege": "all",
            "update_privilege": "all",
            "load_privilege": "all",
            "unload_privilege": "all",
            "backup_privilege": "all",
            "restore_privilege": "all",
            "export_privilege": "all"
        }
    ]
}

usermanage

Brief description

  • Manage users (including adding, deleting, and changing users)

Request mode

  • GET/POST

Parameter transfer mode

  • GET request, the parameters are passed directly as the URL
  • POST request, raw in body in Httprequest, passed asJSON structure

Parameter

Parameter nameMandatoryTypeNote
operationyesstringOperation name, fixed value is usermanage
typeyesstringOperation Type(1:adduser ,2:deleteUser 3:alterUserPassword)
usernameyesstringUser name
passwordyesstringPassword (plain text)
encryptionNostringIf it is empty, the password is clear text. If it is 1, it means it is encrypted with md5.
op_usernameyesstringUser name for the operation
op_passwordyesstringPassword of the operation (if the password is to be changed, the password is the password to be changed) (If the operation contains special characters and the get request is adopted, the value must be urlencode-encoded)

Return value

Parameter nameTypeNote
StatusCodeintReturn value code value (refer to Appendix: Return value code table for details)
StatusMsgstringReturn specific information

Return sample

{
    "StatusCode": 1004,
    "StatusMsg": "username already existed, add user failed."
}

Notes

  • The default interface permissions for the new user are: login, check, testConnect, getCoreVersion, show, funquery, funcudb, funreview, userpassword.

  • Users with query rights also have the following interface rights: query, monitor.

  • Users with the update permission also have the following interface permissions: batchInsert, batchRemove, begin, tquery, commit, rollback.

  • Only the root user can invoke the interface rights that are not within the scope of authorization management, for example: build, drop, usermanage, showuser, userprivilege, manage, txnlog, checkpoint, shutdown, querylog, accesslog, ipmanage.

userprivilegemanage

Brief description

  • Manage user permissions (including adding, deleting, and changing users)

Request mode

  • GET/POST

Parameter transfer mode

  • GET request, the parameters are passed directly as the URL
  • POST request, raw in body in Httprequest, passed asJSON structure

Parameter

Parameter nameMandatoryTypeNote
operationyesstringOperation name, fixed value is userprivilegemanage
typeyesstringOperation type(1:add privilege,2:delete privilege 3:clear Privilege )
usernameyesstringuser name
passwordyesstringPassword (plain text)
encryptionNostringIf it is empty, the password is clear text. If it is 1, it means it is encrypted with md5.
op_usernameyesstringUser name for the operation
privilegesnostringPermissions to operate on (multiple permissions separated by commas) (can be null for clear Privilege)1:query,2:load,3:unload,4:update,5:backup,6:restore,7:export, you can set multi privileges by using , to split.
db_namenostringThe database to operate on (this can be empty if it is clearPrivilege

Return value

Parameter nameTypeNote
StatusCodeintReturn value code value (refer to Appendix: Return value code table for details)
StatusMsgstringReturn specific information

Return sample

{
    "StatusCode": 0,
    "StatusMsg": "add privilege query successfully. \r\nadd privilege load successfully. \r\nadd privilege unload successfully. \r\nadd privilege update successfully. \r\nadd privilege backup successfully. \r\n"
}

userpassword

Brief description

  • Modify the user password.

Request mode

  • GET/POST

Parameter transfer mode

  • GET request, the parameters are passed directly as the URL
  • POST request, raw in body in httprequest , passed as JSON

Parameter

Parameter nameMandatoryTypeNote
operationyesstringOperation name, fixed value is userpassword
usernameyesstringUser name
passwordyesstringPassword
encryptionnostringIf the value is null, the password is in plain text. If the value is 1, the password is encrypted using md5
op_passwordyesstringNew password (plain text)

Return value

Parameter nameTypeNote
StatusCodeintReturn value code value (refer to Appendix: Return value code table for details)
StatusMsgstringReturn specific information

Return sample

{
	"StatusCode":0,
	"StatusMsg": "change password done."
}

Interface of Custom Function

funquery

Brief description

  • Show user-defined graph analysis functions

Request mode

  • POST

Parameter transfer mode

  • POST request, raw in body in httprequest , passed as JSON

Parameter

Parameter nameMandatoryTypeNote
operationyesstringOperation name, fixed value is funquery
usernameyesstringUser name
passwordyesstringPassword (plain text)
encryptionnostringIf the value is null, the password is in plain text. If the value is 1, the password is encrypted using md5
funInfonoJSONObjectQuery parameters
  funNamenostringFunction name
  funStatusnostringStatus (1- to compile; 2- compiled; 3- exception)

Return value

Parameter nameTypeNote
StatusCodeintReturn value code value (refer to Appendix: Return value code table for details)
StatusMsgstringReturn specific information
listJSONArrayJSON array (if there is no data, no array is returned)
  funNamestringName
   funDescstringDescription
   funArgsstringParameter type (1- no K hop parameter; 2- with K hop parameter)
  funBodystringFunction content
   funSubsstringChild functions (can be called in funBody)
  funStatusstringStatus (1- to compile; 2- compiled; 3- exception)
  lastTimestringLast edit time (yyyy-MM-dd HH:mm:ss)

Return sample

{
	"StatusCode": 0,
	"StatusMsg": "success",
	"list": [
		{
			"funName": "demo",
			"funDesc": "this is demo",
			"funArgs": "2",
			"funBody": "{\nstd::cout<<\"uid=\<<uid<<endl;\nstd::cout<<\"vid=\<<vid<<endl;\nstd::cout<<\"k=\"<<k<<endl;\nreturn \"success\";\n}",
			"funSubs": "",
			"funStatus": "1",
			"lastTime": "2022-03-15 11:32:25"
		}
	]
}

funcudb

Brief description

  • User-defined graph analysis function management (add, modify, delete, compile)

Request mode

  • POST

Parameter transfer mode

  • POST request, raw in body in httprequest , passed as JSON

Parameter

Parameter nameMandatoryTypeNote
operationyesstringOperation name, fixed value is funcudb
usernameyesstringUser name
passwordyesstringPassword (plain text)
encryptionnostringIf the value is null, the password is in plain text. If the value is 1, the password is encrypted using md5
typeyesstring1: add, 2: modify, 3: delete, 4: compile
funInfoyesJSONObjectOperator function
  funNameyesstringFunction name
  funDescnostringDescription
  funArgsnostringParameter type (1- no K hop parameter; 2- with K hop parameter).
  funBodynostringFunction contents (wrapped in {}).
  funSubsnostringChild functions (can be called in funBody)
   funReturnnostringReturn type(decode is required)

Return value

Parameter nameTypeNote
StatusCodeintReturn value code value (refer to Appendix: Return value code table for details)
StatusMsgstringReturn specific information

Return sample

{
	"StatusCode": 0,
	"StatusMsg": "success"
}

funreview

Brief description

  • Preview the user-defined graph analysis function

Request mode

  • POST

Parameter transfer mode

  • POST request, raw in body in httprequest , passed as JSON

Parameter

Parameter nameMandatoryTypeNote
operationyesstringOperation name, fixed value is funreview
usernameyesstringUser name
passwordyesstringPassword (plain text)
encryptionnostringIf the value is null, the password is in plain text. If the value is 1, the password is encrypted using md5
funInfoyesJSONObjectOperator function
  funNameyesstringFunction name
  funDescnostringDescription
  funArgsyesstringParameter type (1- no K hop parameter; 2- with K hop parameter)
  funBodyyesstringFunction contents (contents wrapped in {})
  funSubsyesstringChild function (can be called in funBody)
  funReturnyesstringReturn type (path: the path class result; value: value class result)

Return value

Parameter nameTypeNote
StatusCodeintReturn value code value (refer to Appendix: Return value code table for details)
StatusMsgstringReturn specific information
resultstringFunction source code (decode is required)

Return sample

{
	"StatusCode": 0,
	"StatusMsg": "success",
    "Result":"%23include+%3Ciostream%3E%0A%23include+%22..%2F..%2FDatabase%2FCSRUtil.h%22%0A%0Ausing+..."
}

Interface of Log

txnlog

Brief description

  • Get transaction logs (this function is only available for the root user)
  • Updates in this version: added paging query parameters

Request mode

  • GET/POST

Parameter transfer mode

  • GET request, the parameters are passed directly as the URL
  • POST request, raw in body in httprequest , passed as JSON

Parameter

Parameter nameMandatoryTypeNote
operationyesstringOperation name, fixed value is txnlog
usernameyesstringUser name
passwordyesstringPassword (plain text)
encryptionnostringIf the value is null, the password is in plain text. If the value is 1, the password is encrypted using md5
pageNoyesintPage number, the value ranges from 1 to N, the default value is 1
pageSizeyesintThe number of entries per page, the value ranges from 1 to N, the default value is 10

Return value

Parameter nameTypeNote
StatusCodeintReturn value code value (refer to Appendix: Return value code table for details)
StatusMsgstringReturn specific information
totalSizeintTotal size
totalPageintThe total number of pages
pageNointThe current page number
pageSizeintThe number of entries per page
listJSONArrayLog array
  db_namestringDatabase name
   TIDstringTransaction ID
  userstringUser
  statestringState (COMMITED/RUNNING/ROLLBACK)
  begin_timestringStart time
  end_timestringEnd time

Return sample

{
	"StatusCode": 0,
	"StatusMsg": "Get Transaction log success",
	"totalSize": 2,
	"totalPage": 1,
	"pageNo": 1,
	"pageSize": 10,
	"list": [
		{
			"db_name": "lubm2",
			"TID": "1",
			"user": "root",
			"begin_time": "1630376221590",
			"state": "COMMITED",
			"end_time": "1630376277349"
		},
		{
			"db_name": "lubm2",
			"TID": "2",
			"user": "root",
			"begin_time": "1630376355226",
			"state": "ROLLBACK",
			"end_time": "1630376379508"
		}
	]
}

querylogdate

Brief description

  • Get the date of gStore's query log (for the date parameter of the query log interface)

Request mode

  • GET/POST

Parameter transfer mode

  • GET request, the parameters are passed directly as the URL
  • POST request, raw in body in Httprequest, passed as JSON

Parameter

Parameter nameMandatoryTypeNote
operationyesstringOperation name, fixed value is querylogdate
usernameyesstringUser name
passwordyesstringPassword (plain text)
encryptionnostringIf the value is null, the password is in plain text. If the value is 1, the password is encrypted using md5

Return value

ParameterTypeNote
StatusCodeintReturn value code value (refer to Appendix: Return value code table for details)
StatusMsgstringReturn specific information
listarrayThe list of dates

Return sample

{
	"StatusCode":0,
    "StatusMsg":"Get query log date success",
	"list":[
		"20220828",
        "20220826",
        "20220825",
        "20220820"
    ]
}

querylog

Brief description

  • Obtaining query Logs

Request mode

  • GET/POST

Parameter transfer mode

  • GET request, the parameters are passed directly as the URL
  • POST request, raw in body in Httprequest, passed asJSON structure

Parameter

Parameter nameMandatoryTypeNote
operationyesstringOperation name, fixed value is querylog
usernameyesstringUser name
passwordyesstringPassword (plain text)
encryptionnostringIf the value is null, the password is in plain text. If the value is 1, the password is encrypted using md5
dateyesstringDate format is yyyyMMdd
pageNoyesintPage number. The value ranges from 1 to N. The default value is 1
pageSizeyesintThe number of entries per page. The value ranges from 1 to N. The default value is 10

Return value

ParameterTypeNote
StatusCodeintReturn value code value (refer to Appendix: Return value code table for details)
StatusMsgstringReturn specific information
totalSizeintTotal number
totalPageintTotal page number
pageNointCurrent page number
pageSizeintThe number of entries per page
listArrayLog array
 QueryDateTimestringQuery date/time
 SparqlstringSPARQL statement
 FormatstringQuery return format
 RemoteIPstringRequest IP
 FileNamestringQuery result set files
 QueryTimeintTime (ms)
 AnsNumintResult number

Return sample

{
	"StatusCode":0,
    "StatusMsg":"Get query log success",
	"totalSize":64,
	"totalPage":13,
	"pageNo":2,
	"pageSize":5,
	"list":[
		{
			"QueryDateTime":"2021-11-16 14:55:52:90ms:467microseconds",
			"Sparql":"select ?name where { ?name <不喜欢> <Eve>. }",
			"Format":"json",
			"RemoteIP":"183.67.4.126",
			"FileName":"140163774674688_20211116145552_847890509.txt",
			"QueryTime":0,
			"AnsNum":2
		}
        ......
    ]
}

accesslogdate

Brief description

  • Get the date of gStore's access log (for the date parameter of the access log interface)

Request mode

  • GET/POST

Parameter transfer mode

  • GET request, the parameters are passed directly as the URL
  • POST request, raw in body in Httprequest, passed as JSON

Parameter

Parameter nameMandatoryTypeNote
operationyesstringOperation name, fixed value is querylogdate
usernameyesstringUser name
passwordyesstringPassword (plain text)
encryptionnostringIf the value is null, the password is in plain text. If the value is 1, the password is encrypted using md5

Return value

ParameterTypeNote
StatusCodeintReturn value code value (refer to Appendix: Return value code table for details)
StatusMsgstringReturn specific information
listarrayThe list of dates

Return sample

{
	"StatusCode":0,
    "StatusMsg":"Get access log date success",
	"list":[
		"20220913",
        "20220912",
        "20220911",
        "20220818",
        "20220731",
        "20220712",
        "20220620",
    ]
}

accesslog

Brief description

  • Get the access log of the API

Request mode

  • GET/POST

Parameter transfer mode

  • GET request, the parameters are passed directly as the URL
  • POST request, raw in body in Httprequest, passed as JSON

Parameter

Parameter nameMandatoryTypeNote
operationyesstringOperation name, fixed value is accesslog
usernameyesstringUser name
passwordyesstringPassword (plain text)
encryptionnostringIf the value is null, the password is in plain text. If the value is 1, the password is encrypted using md5
dateyesstringDate format is yyyyMMdd
pageNoyesintPage number. The value ranges from 1 to N. The default value is 1
pageSizeyesintThe number of entries per page. The value ranges from 1 to N. The default value is 10

Return value

ParameterTypeNote
StatusCodeintReturn value code value (refer to Appendix: Return value code table for details)
StatusMsgstringReturn specific information
totalSizeintTotal number
totalPageintTotal page number
pageNointCurrent page number
pageSizeintThe number of entries per page
listArrayLog array
 ipstringThe IP that makes the access
 operationstringThe type of operation performed
  createtimestringThe time of the operation
 codestringThe result of the operation (refer to Appendix: Return value code table for details)
 msgstringLog description

Return sample

{
	"StatusCode":0,
    "StatusMsg":"Get access log success",
	"totalSize":64,
	"totalPage":13,
	"pageNo":2,
	"pageSize":5,
	"list":[
		{
            "ip":"127.0.0.1",
            "operation":"StopServer",
            "createtime":"2021-12-14 09:55:16", 
            "code":0,
            "msg":"Server stopped successfully."
        }
        ......
    ]
}

Reason Engine

There are 7 types of operation to parameter type

  • 1:addReason
  • 2:listReason
  • 3:compileReason
  • 4:executeReason
  • 5:disableReason
  • 6.showReason
  • 7.deleteReason

addReason

Brief description

  • add reasoning rules

Request mode

  • POST

Parameter transfer mode

  • POST request, raw in body in Httprequest, passed as JSON

Parameter

Parameter nameMandatoryTypeNote
operationyesstringOperation name, fixed value is reasonManage
usernameyesstringUser name
passwordyesstringPassword (plain text)
encryptionnostringIf the value is null, the password is in plain text. If the value is 1, the password is encrypted using md5
db_nameyesstringDatabase name
typeyesstringOperation type is "1"
ruleinfoyesobjectRule information: "ruleinfo": {"rulename":"", ...},Rule details
  rulenameyesstringRule name(Same database ,unique rulename)
  descriptionnostringRule description
  isenableyesintWhether to enable, optional values: 1 enable ,0 disable
  typeyesintReason type:optional values:1 relational reason , 0 attribute reason
  logicyesintThe relationship between conditions and conditions,optional values:1 logical and , 0 logical or
  conditionsyesarrayRules set
    patternsyesarrayTriples set
      subjectyesstringSubject
      predicateyesstringPredicate
      objectyesstringObject
    filtersnoarrayFilter conditions
    count_infonoObjectAggregate function(undetermined)
  returnyesObjectReturn object
    sourceyesstringSource node
    targetnostringTerminal node
    labelstringpredicate(The system automatically adds the Rule: prefix)
    valuestringAttribute value

Return value

ParameterTypeNote
StatusCodeintReturn value code value (refer to Appendix: Return value code table for details)
StatusMsgstringReturn specific information

Relational reasoning rule sample

{
	"rulename": "uncle",
	"description": "The mother's male sibling was the uncle"
	"isenable": 1,
	"type": 1,
	"logic": 1,
	"conditions": [
		{
			"patterns": [
				{
					"subject": "?x ",
					"predicate": "<mother>",
					"object": "?y"
				},
				{
					"subject": "?y ",
					"predicate": "<father>",
					"object": "?z"
				},
				{
					"subject": "?k",
					"predicate": "<father>",
					"object": "?z"
				},
				{
					"subject": "?k",
					"predicate": "<gender>",
					"object": "\"male\"^^<http://www.w3.org/2001/XMLSchema#string>"
				}
			],
			"filters": [],
			"count_info": {}
		}
	],
	"return": {
		"source": "?x",
		"target": "?k",
		"label": "uncle"
	}
}

Attribute reasoning rule sample

{
	"rulename": "orphan",
	"description": "Both parents died and were orphaned",
	"isenable": 1,
	"type": 0,
	"logic": 1,
	"conditions": [
		{
			"patterns": [
				{
					"subject": "?x ",
					"predicate": "<father>",
					"object": "?y"
				},
				{
					"subject": "?x",
					"predicate": "<mother>",
					"object": "?z"
				},
				{
					"subject": "?y",
					"predicate": "<state>",
					"object": "\"died\"^^<http://www.w3.org/2001/XMLSchema#string>"
				},
				{
					"subject": "?z",
					"predicate": "<state>",
					"object": "\"died\"^^<http://www.w3.org/2001/XMLSchema#string>"
				}
			],
			"filters": [],
			"count_info": {}
		}
	],
	"return": {
		"source": "?x",
		"label": "died",
		"value": "\"orphan\"^^<http://www.w3.org/2001/XMLSchema#string>"
	}
}

Return sample

{
    "StatusCode": 0,
    "StatusMsg": "Save Successfully! the file path is ./dbhome/lubm.db/reason_rule_files/test.json"
}

listReason

Brief description

  • show rules list

Request mode

  • POST

Parameter transfer mode

  • POST request, raw in body in Httprequest, passed as JSON

Parameter

Parameter nameMandatoryTypeNote
operationyesstringOperation name, fixed value is reasonManage
usernameyesstringUsername
passwordyesstringPassword (plain text)
encryptionnostringIf the value is null, the password is in plain text. If the value is 1, the password is encrypted using md5
db_nameyesstringDatabase name
typeyesstringOperation type:“2”

Return value

Parameter nameTypeNote
StatusCodeintReturn value code value (refer to Appendix: Return value code table for details)
StatusMsgstringReturn specific information
numintRule number
listJSONArrayRule name list
 rulenamestringRule name(Same database,unique rule name)
 descriptionstringRule description
 isenableintWhether to enable, optional values: 1 enable ,0 disable
 typeintReason type:optional values:1 relational reason , 0 attribute reason
  logicintThe relationship between conditions and conditions,optional values:1 logical and , 0 logical or
 conditionsarrayRules set
  conditionarryRule
   patternsarrayTriples set
    subjectstringSubject
    predicatestringPredicate
    objectstringObject
   filtersarrayFilter rule
   count_infoObjectAggregate function(undetermined)
 returnObjectReturn object
  sourcestringSource node
  targetstringTerminal node
  labelstringpredicate(The system automatically adds the Rule: prefix)
  valuestringAttribute value
 statusstringstatus
 insert_sparqlstringinsert sparql
 delete_sparqlstringdelete sparql
 createtimestringcreate time

Return value

{
    "StatusCode": 0,
    "StatusMsg": "ok",
    "list": [
        {
            "ruleid": "002",
            "rulename": "orphan",
            "description": "Both parents died and were orphaned",
            "conditions": [
                {
                    "condition": {
                        "patterns": [
                            {
                                "subject": "?x ",
                                "predicate": "<father>",
                                "object": "?y"
                            },
                            {
                                "subject": "?x",
                                "predicate": "<mother>",
                                "object": "?z"
                            },
                            {
                                "subject": "?y",
                                "predicate": "<state>",
                                "object": "\"died\"^^<http://www.w3.org/2001/XMLSchema#string>"
                            },
                            {
                                "subject": "?z",
                                "predicate": "<state>",
                                "object": "\"died\"^^<http://www.w3.org/2001/XMLSchema#string>"
                            }
                        ],
                        "filters": [],
                        "count_info": {}
                    },
                    "logic": 1
                }
            ],
            "isenable": 1,
            "type": 0,
            "return": {
                "source": "?x",
                "label": "state",
                "value": "\"orphan\"^^<http://www.w3.org/2001/XMLSchema#string>"
            },
            "createtime": "2023-12-29 16:58:00",
            "status": "executed",
            "insert_sparql": "insert {?x <Rule:state> \"orphan\"^^<http://www.w3.org/2001/XMLSchema#string>. } where {  ?x  <father> ?y. ?x <mother> ?z. ?y <state> \"died\"^^<http://www.w3.org/2001/XMLSchema#string>. ?z <state> \"died\"^^<http://www.w3.org/2001/XMLSchema#string>. }",
            "delete_sparql": "delete where {?x <Rule:state> \"orphan\"^^<http://www.w3.org/2001/XMLSchema#string>.}"
        },
        {
            "ruleid": "001",
            "rulename": "uncle2",
            "description": "The mother's male sibling was the uncle",
            "conditions": [
                {
                    "condition": {
                        "patterns": [
                            {
                                "subject": "?x ",
                                "predicate": "<mother>",
                                "object": "?y"
                            },
                            {
                                "subject": "?y ",
                                "predicate": "<father>",
                                "object": "?z"
                            },
                            {
                                "subject": "?k",
                                "predicate": "<father>",
                                "object": "?z"
                            },
                            {
                                "subject": "?k",
                                "predicate": "<gender>",
                                "object": "\"male\"^^<http://www.w3.org/2001/XMLSchema#string>"
                            }
                        ],
                        "filters": [],
                        "count_info": {}
                    },
                    "logic": 1
                }
            ],
            "isenable": 1,
            "type": 1,
            "return": {
                "source": "?x",
                "target": "?k",
                "label": "uncle",
                "value": ""
            },
            "createtime": "2023-12-29 16:58:00",
            "status": "executed",
            "insert_sparql": "insert { ?x <Rule:uncle> ?k. } where {  ?x  <mother> ?y. ?y  <father> ?z. ?k <father> ?z. ?k <gender> \"male\"^^<http://www.w3.org/2001/XMLSchema#string>. }",
            "delete_sparql": "delete where {?x <Rule:unlce> ?y.}"
        }
    ],
    "num": 2
}

compileReason

Brief description

  • compile rules

Request mode

  • POST

Parameter transfer mode

  • POST request: raw in body in httprequest , passed as JSON

Parameter

parameter nameMandatoryTypeNote
operationyesstringOperation name.fixed reasonManage
usernameyesstringUser name
passwordyesstringPassword (plain text)
encryptionnostringIf the value is null, the password is in plain text. If the value is 1, the password is encrypted using md5
db_nameyesstringDatabase name
typeyesstringOperation type:“3”
rulenameyesstringRule name

Return value

parameter nameTypeNote
StatusCodeintReturn value code value (refer to Appendix: Return value code table for details)
StatusMsgstringReturn specific information
insert_sparqlstringinsert sparql
delete_sparqlstringdelete sparql

Return value

{
    "insert_sparql": "insert {?x <Rule:state> \"orphan\"^^<http://www.w3.org/2001/XMLSchema#string>. } where {  ?x  <father> ?y. ?x <mother> ?z. ?y <state> \"died\"^^<http://www.w3.org/2001/XMLSchema#string>. ?z <state> \"died\"^^<http://www.w3.org/2001/XMLSchema#string>. }",
    "delete_sparql": "delete where {?x <Rule:state> \"orphan\"^^<http://www.w3.org/2001/XMLSchema#string>.}",
    "StatusCode": 0,
    "StatusMsg": "ok"
}

executeReason

Brief description

  • execute rules

Request mode

  • POST

Parameter transfer mode

  • POST request, raw in body in Httprequest, passed asJSON

Parameter

parameterMandatoryTypeNote
operationyesstringOperation name, fixed value is reasonManage
usernameyesstringUser name
passwordyesstringPassword (plain text)
encryptionnostringIf the value is null, the password is in plain text. If the value is 1, the password is encrypted using md5
db_nameyesstringDatabase name
typeyesstringOperation type :“4”
rulenameyesstringRule name

Return value

parameter nameTypeNote
StatusCodeintReturn value code value (refer to Appendix: Return value code table for details)
StatusMsgstringReturn specific information
insert_sparqlstringinsert sparql
AnsNumintsuccessful answer number

return value

{
    "insert_sparql": "insert {?x <Rule:state> \"orphan\"^^<http://www.w3.org/2001/XMLSchema#string>. } where {  ?x  <father> ?y. ?x <mother> ?z. ?y <state> \"died\"^^<http://www.w3.org/2001/XMLSchema#string>. ?z <state> \"died\"^^<http://www.w3.org/2001/XMLSchema#string>. }",
    "AnsNum": 0, 
    "StatusCode": 0,
    "StatusMsg": "ok"
}

disableReason

Brief description

  • Invalidate the rule

Request mode

  • POST

Parameter transfer mode

  • POST request, raw in body in Httprequest, passed asJSON structure

Parameter

Parameter nameMandatoryTypeNote
operationyesstringOperation name, fixed reasonManage
usernameyesstringUser name
passwordyesstringPassword (plain text)
encryptionnostringIf the value is null, the password is in plain text. If the value is 1, the password is encrypted using md5
db_nameyesstringDatabase name
typeyesstringOperation type:“5”
rulenameyesstringRule name

Return value

Parameter nameTypeNote
StatusCodeintReturn value code value (refer to Appendix: Return value code table for details)
StatusMsgstringReturn specific information
delete_sparqlstringDelete sparql
AnsNumintsuccessful answer number

Return value

{
    "delete_sparql": "delete where {?x <Rule:state> \"orphan\"^^<http://www.w3.org/2001/XMLSchema#string>.}",
    "AnsNum": 1, 
    "StatusCode": 0,
    "StatusMsg": "ok"
}

showReason

Brief description

  • show rule details

Request mode

  • POST

Parameter transfer mode

  • POST request, raw in body in Httprequest, passed asJSON structure

Parameter

Parameter nameMandatoryTypeNote
operationyesstringOperation name, fixed value reasonManage
usernameyesstringUser name
passwordyesstringPassword(plain test)
encryptionnostringIf the value is null, the password is in plain text. If the value is 1, the password is encrypted using md5
db_nameyesstringDatabase name
typeyesstringOperation type:“6”
rulenameyesstringRule name

Return value

Parameter nameTypeNote
StatusCodeintReturn value code value (refer to Appendix: Return value code table for details)
StatusMsgstringReturn specific information
ruleinfoObjectObject
insert_sparqlstringinsert sparql
delete_sparqlstringdelete sparql
statusstringstatus
rulenamestringRule name(Same database,unique rule name)
descriptionstringRule description
isenableintWhether to enable
typeint1:relational reasoning 0:attribute reasoning
 logicintRelationship between conditions and conditions. Optional values:1: logical and ; 0 : logical or
createtimestringCreate time
conditionsJSONArrayRule conditions(Array)
 conditionObjectRule
  patternsarrayTriples set
   subjectstringSubject
   predicatestringPredicate
   objectstringObject
  filtersarrayFilter conditions
  count_infoObjectAggregate function (undermined)
returnObjectReturn object
 sourcestringSource node
 targetstringTerminal node
 labelstringpredicate(The system automatically adds the Rule: prefix)
 valuestringAttribute value

Return value

{
    "ruleid": "002",
    "rulename": "orphan",
    "description": "The person whose both parents died is orphan",
    "conditions": [
        {
            "condition": {
                "patterns": [
                    {
                        "subject": "?x ",
                        "predicate": "<father>",
                        "object": "?y"
                    },
                    {
                        "subject": "?x",
                        "predicate": "<mother>",
                        "object": "?z"
                    },
                    {
                        "subject": "?y",
                        "predicate": "<state>",
                        "object": "\"died\"^^<http://www.w3.org/2001/XMLSchema#string>"
                    },
                    {
                        "subject": "?z",
                        "predicate": "<state>",
                        "object": "\"died\"^^<http://www.w3.org/2001/XMLSchema#string>"
                    }
                ],
                "filters": [],
                "count_info": {}
            },
            "logic": 1
        }
    ],
    "isenable": 1,
    "type": 0,
    "return": {
        "source": "?x",
        "label": "state",
        "value": "\"orphan\"^^<http://www.w3.org/2001/XMLSchema#string>"
    },
    "createtime": "2023-12-29 16:58:00",
    "status": "disabled", 
    "insert_sparql": "insert {?x <Rule:state> \"orphan\"^^<http://www.w3.org/2001/XMLSchema#string>. } where {  ?x  <father> ?y. ?x <mother> ?z. ?y <state> \"died\"^^<http://www.w3.org/2001/XMLSchema#string>. ?z <state> \"died\"^^<http://www.w3.org/2001/XMLSchema#string>. }",
    "delete_sparql": "delete where {?x <Rule:state> \"orphan\"^^<http://www.w3.org/2001/XMLSchema#string>.}",
    "StatusCode": 0,
    "StatusMsg": "ok"
}

deleteReason

Brief description

  • Delete rule

Request mode

  • POST

Parameter transfer mode

  • POST request, raw in body in Httprequest, passed asJSON structure

Parameter

ParameterMandatoryTypeNote
operationyesstringOperation name, fixed value is reasonManage
usernameyesstringUser name
passwordyesstringPassword(plain test)
encryptionnostringIf the value is null, the password is in plain text. If the value is 1, the password is encrypted using md5
db_nameyesstringDatabase name
typeyesstringOperation type:“7”
rulenameyesstringRule name

Return value

Parameter nameTypeNote
StatusCodeintReturn value code value (refer to Appendix: Return value code table for details)
StatusMsgstringReturn specific information

Return value

{
    "StatusCode": 0,
    "StatusMsg": "the reason file has been remove successfully! file path:./dbhome/reason.db/reason_rule_files/orphan.json"
}

Appendix 1: Return value code table for details

CodeDetails
0Success
1000The method type is not support
1001Authentication Failed
1002Check Privilege Failed
1003Param is illegal
1004The operation conditions are not satisfied
1005Operation failed
1006Add privilege Failed
1007Loss of lock
1008Transcation manage Failed
1100The operation is not defined
1101IP Blocked

Socket API Instruction

API Interconnection Mode

The gServer interface uses the socket protocol and supports multiple ways to access the interface. If the port 9000 is started from the gServer in the Main directory, the contents of the interface interconnection are as follows:

API address:

http://ip:9000/

The API supports the input of a parameter list in JSON format, as shown below:

{"op": "[op_type]", "[paramname1]": "[paramvalue1]", "[paramname2]": "[paramvalue2]"……}

API List

API nameDefinitionNote
buildBuild graph databaseThe database file must be locally stored on the server
loadLoad graph databaseLoad the database into memory
unloadUnload graph databaseUnload the database from memory
dropDelete graph databaseLogical deletion and physical deletion can be performed
showDisplay graph databaseDisplay list of all databases
queryQuery graph databaseIncluding query, delete, and insert
stopClose serverOnly root user root can perform this operation
closeClose client server connectionProcess client connection closure requests
loginlogin to databaseauthenticate user names and password

API Specific Instruction

This section describes the input and output parameters of each interface. Assume that the IP address of the gserver is 127.0.0.1 and the port is 9000

(1) build- build database

Brief description

  • Create a database based on existing NT file
  • Files must exist on the gStore server

Request ip

  • 127.0.0.1

Request port number

  • 9000

Parameter transfer mode

  • Pass it as a JSON structure

Parameter

Parameter nameMandatoryTypeNote
opyesstringOperation name, fixed value is build
db_nameyesstringDatabase name (.db is not required)
db_pathyesstringDatabase file path (can be an absolute path or a relative path. The relative path uses the gStore installation root directory as a reference directory)

Return value

Parameter nameTypeNote
StatusCodeintReturn value code value (refer to Appendix: Return value code table for details)
StatusMsgstringReturn specific information

Return sample

{
    "StatusCode": 0,
    "StatusMsg": "Import RDF file to database done."
}

(2) load

Brief description

  • To load a database into memory, a load operation is a prerequisite for many operations, such as Query

Request ip

  • 127.0.0.1

Request port number

  • 9000

Parameter transfer mode

  • Pass it as a JSON structure

Parameter

Parameter nameMandatoryTypeNote
opyesstringOperation name, fixed value is load
db_nameyesstringDatabase name (.db is not required)

Return value

Parameter nameTypeNote
StatusCodeintReturn value code value (refer to Appendix: Return value code table for details)
StatusMsgstringReturn specific information

Return sample

{
    "StatusCode": 0,
    "StatusMsg": "Load database successfully."
}

(3) unload

Brief description

  • Unmount the database from memory (all changes are flushed back to hard disk)

Request ip

  • 127.0.0.1

Request port number

  • 9000

Parameter transfer mode

  • Pass it as a JSON structure

Parameter

Parameter nameMandatoryTypeNote
opyesstringOperation name, fixed value is unload
db_nameyesstringDatabase name (.db is not required)

Return value

Parameter nameTypeNote
StatusCodeintReturn value code value (refer to Appendix: Return value code table for details)
StatusMsgstringReturn specific information

Return sample

{
    "StatusCode": 0,
    "StatusMsg": "Unload database done."
}

(4) drop

Brief description

  • Delete the database

Request ip

  • 127.0.0.1

Request port number

  • 9000

Parameter transfer mode

  • Pass it as a JSON structure

Parameter

Parameter nameMandatoryTypeNote
opyesstringOperation name, fixed value is drop
db_nameyesstringDatabase name (.db is not required)

Return value

Parameter nameTypeNote
StatusCodeintReturn value code value (refer to Appendix: Return value code table for details)
StatusMsgstringReturn specific information

Return sample

{
    "StatusCode": 0,
    "StatusMsg": "Drop database done."
}

(5) show

Brief description

  • Display all database list

Request ip

  • 127.0.0.1

Request port number

  • 9000

Parameter transfer mode

  • Pass it as a JSON structure

Parameter

Parameter nameMandatoryTypeNote
opyesstringOperation name, fixed value is show

Return value

Parameter nameTypeNote
StatusCodeintReturn value code value (refer to Appendix: Return value code table for details)
StatusMsgstringReturn specific information
ResponseBodyJSONArrayJSON arrays (each of which is a database information0
-------- databasestringdatabase name
---------statusstringdatabase status

Return sample

{
    "StatusCode": 0,
    "StatusMsg": "success",
    "ResponseBody": [
           "lubm": "loaded",
           "lubm10K": "unloaded"
    ]
}

(6) query

Brief description

  • query database

Request ip

  • 127.0.0.1

Request port number

  • 9000

Parameter transfer mode

  • Pass it as a JSON structure

Parameter

Parameter nameMandatoryTypeNote
opyesstringOperation name, fixed value is query
db_nameyesstringdatabase that need operations
formatnostringThe result set return format is json by default
sparqlyesstringThe SPARQL statement to execute

Return value

Parameter nameTypeNote
StatusCodeintReturn value code value (refer to Appendix: Return value code table for details)
StatusMsgstringReturn specific information
headJSONHead information
resultsJSONResult information (see Return Sample for details)

Return sample

{
    "head": {
        "link": [],
        "vars": [
            "x"
        ]
    },
    "results": {
        "bindings": [
            {
                "x": {
                    "type": "uri",
                    "value": "十面埋伏"
                }
            },
            {
                "x": {
                    "type": "uri",
                    "value": "投名状"
                }
            },
            {
                "x": {
                    "type": "uri",
                    "value": "如花"
                }
            }
        ]
    },
    "StatusCode": 0,
    "StatusMsg": "success"
}

(7) login

Brief description

  • Login user (verify username and password)

Request ip

  • 127.0.0.1

Request port number

  • 9000

Parameter transfer mode

  • Pass it as a JSON structure

Parameter

Parameter nameMandatoryTypeNote
opyesstringOperation name, fixed value is login
usernameyesstringuser name
passwordyesstringPassword (plain text)

Return value

Parameter nameTypeNote
StatusCodeintReturn value code value (refer to Appendix: Return value code table for details)
StatusMsgstringReturn specific information

Return sample

{
    "StatusCode": 1001,
    "StatusMsg": "wrong password."
}

(8) stop

Brief description

  • Close server

Request ip

  • 127.0.0.1

Request port number

  • 9000

Parameter transfer mode

  • Pass it as a JSON structure

Parameter

Parameter nameMandatoryTypeNote
opyesstringOperation name, fixed value is stop

Return value

Parameter nameTypeNote
StatusCodeintReturn value code value (refer to Appendix: Return value code table for details)
StatusMsgstringReturn specific information

Return sample

{
    "StatusCode": 0,
    "StatusMsg": "Server stopped."
}
**(9) close**

Brief description

  • Close the connection to the client

Request ip

  • 127.0.0.1

Request port number

  • 9000

Parameter transfer mode

  • Pass it as a JSON structure

Parameter

Parameter nameMandatoryTypeNote
opyesstringOperation name, fixed value is close

Return value

Parameter nameTypeNote
StatusCodeintReturn value code value (refer to Appendix: Return value code table for details)
StatusMsgstringReturn specific information

Return sample

{
    "StatusCode": 0,
    "StatusMsg": "Connection disconnected."
}
**Appendix 1 return value code table**
Code valueDefinition
0Success
1000The method type is not support
1001Authentication Failed
1002Check Privilege Failed
1003Param is illegal
1004The operation conditions are not satisfied
1005Operation failed
1006Add privilege Failed
1007Loss of lock
1008Transcation manage Failed
1100The operation is not defined
1101IP Blocked

C++ HTTP API

To use the C++ API, put the phrase '#include "client.h" in your CPP code, as shown below:

Construct the initialization function

GstoreConnector(std::string serverIP, int serverPort, std::string httpType, std::string username, std::string password);
Function: Initialize
Parameter Definition:[Server IP], [HTTP port on the server], [HTTP service type], [Username], [password]
Example:GstoreConnector gc("127.0.0.1", 9000, "ghttp", "root", "123456");

Build database: build

std::string build(std::string db_name, std::string rdf_file_path, std::string request_type);
Function:Create a new database from an RDF file
Parameter Definition:[database name], [.nt file path], [request type "GET" and "POST ", if request type "GET" can be omitted]
Example:gc.build("lubm", "data/lubm/lubm.nt");

Load database: load

std::string load(std::string db_name, std::string request_type);
Function:Load the database you created
Parameter Definition:[database name], [request type "GET" and "POST ", if request type "GET" can be omitted]
Example:gc.load("lubm");

Stopping database loading: unload

std::string unload(std::string db_name, std::string request_type);
Function:Stopping database loading
Parameter Definition:[database name], [request type "GET" and "POST ", if request type "GET" can be omitted]
Example:gc.unload("lubm");

User management: user

std::string user(std::string type, std::string username2, std::string addition, std::string request_type);
Function:The root user can add, delete, or modify the user's permission only
1.Add or delete users:
Parameter Definition:["add_user" adds user, "delete_user" deletes user],[user name],[password],[request type "GET" and "POST ", if request type "GET" can be omitted]
Example:gc.user("add_user", "user1", "111111");
2.Modify user's privilege:
Parameter Definition:["Add_query" adds query permission, "delete_query" deletes query permission, "add_load" adds load permission, "delete_load" deletes load permission, "add_unload" adds no load permission, "delete_unload" deletes no load permission,  "Add_update" adds update permission, "delete_update" deletes update permission, "add_backup" adds backup permission, "delete_bakup" deletes backup permission, "add_restore" adds restore permission,  "Delete_restore" deletes restore permission,"add_export" adds export permission," delete_export" deletes export permission],[user name],[database name],[Request type "GET" and "POST ", if the request type is "GET", it can be omitted.]
Example:gc.user("add_query", "user1", "lubm");

Display user: showUser

std::string showUser(std::string request_type);
Function:Display all Users
Parameter Definition:[Request types "GET" and "POST" can be omitted if the request type is "GET"]
Example:gc.showUser();

Database query: query

std::string query(std::string db_name, std::string format, std::string sparql, std::string request_type);
Function:Query the database
Parameter Definition:[database name], [query result type JSON, HTML or text], [SPARQL statement], [Request type "GET" and "POST ", if the request type is "GET", it can be omitted]
Example:
std::string res = gc.query("lubm", "json", sparql);
std::cout << res << std::endl;  //output result

Deleting a Database: drop

std::string drop(std::string db_name, bool is_backup, std::string request_type);
Function:Delete the database directly or delete the database while leaving a backup
Parameter Definition:[database name], [false not backup, true backup], [request type "GET" and "POST ", if request type "GET" can be omitted]
Example:gc.drop("lubm", false);  //Delete the database without leaving a backup

Monitoring database: monitor

std::string monitor(std::string db_name, std::string request_type);Function:Displays information for a specific database.
Parameter Definition:[database name], [request type "GET" and "POST ", if request type "GET" can be omitted]Example:gc.monitor("lubm");

Save the database: checkpoint

std::string checkpoint(std::string db_name, std::string request_type);Function:If you change the database, save the databas Parameter Definition:[database name], [request type "GET" and "POST ", if request type "GET" can be omitted]Example:gc.checkpoint("lubm");

Show the database: show

std::string show(std::string request_type);Function:Displays all created databases Parameter Definition:[Request types "GET" and "POST" can be omitted if the request type is "GET"] Example:gc.show();

The kernel version information is displayed: getCoreVersion

std::string getCoreVersion(std::string request_type);Function:Get kernel version information Parameter Definition:[Request types "GET" and "POST" can be omitted if the request type is "GET"]
Example:gc.getCoreVersion();

The API version information is displaye: getAPIVersion

std::string getAPIVersion(std::string request_type);
Function:Get the API version information
Parameter Definition:[Request types "GET" and "POST" can be omitted if the request type is "GET"]
Example:gc.getAPIVersion();

Query the database and save the file: fquery

void fquery(std::string db_name, std::string format, std::string sparql, std::string filename, std::string request_type);
Function:Query the database and save the results to a file
Parameter Definition:[database name], [query result type JSON, HTML or text], [SPARQL statement], [file name], [request type "GET" and "POST ", if the request type is "GET", it can be omitted]
Example:gc.fquery("lubm", "json", sparql, "ans.txt");

Exporting the Database

std::string exportDB(std::string db_name, std::string dir_path, std::string request_type);
Function:Export the database to a folder
Parameter Definition:[database name], [path to database export folder], [request type "GET" and "POST ", if the request type is "GET", can be omitted]
Example:gc.exportDB("lubm", "/root/gStore/");

Java HTTP API

To use the Java API, please refer to the gStore/API/HTTP/Java/SRC/JGSC/GstoreConnector. Java. Specific use is as follows:

Construct the initialization function

public class GstoreConnector(String serverIP, int serverPort, String httpType,
String username, String password);
Function: Initialize
Parameter Definition:[Server IP], [HTTP port on the server], [HTTP service type], [Username], [password]
Example:GstoreConnector gc = new GstoreConnector("127.0.0.1", 9000, "ghttp",
"root", "123456");

Building a database: build

public String build(String db_name, String rdf_file_path, String request_type);
Function:Create a new database from an RDF file
Parameter Definition:[database name], [.nt file path], [request type "GET" and "POST ", if request type "GET" can be omitted]
Example:gc.build("lubm", "data/lubm/lubm.nt");

Loading a database: load

public String load(String db_name, String request_type);
Function:Load the database you created
Parameter Definition:[database name], [request type "GET" and "POST ", if request type "GET" can be omitted]
Example:gc.load("lubm");

Stopping database loading: unload

public String unload(String db_name, String request_type);
Function:Stopping database loading
Parameter Definition:[database name], [request type "GET" and "POST ", if request type "GET" can be omitted]
Example:gc.unload("lubm");

User management:user

public String user(String type, String username2, String addition, String request_type);
Function:The root user can add, delete, or modify the user's permission only.
1.Add or delete users:
Parameter Definition:["add_user" adds user, "delete_user" deletes user],[user name],[password],[request type "GET" and "POST ", if request type "GET" can be omitted]
Example:gc.user("add_user", "user1", "111111");
2.Modify user's privilege:
Parameter Definition:["Add_query" adds query permission, "delete_query" deletes query permission, "add_load" adds load permission, "delete_load" deletes load permission, "add_unload" adds no load permission, "delete_unload" deletes no load permission,  "Add_update" adds update permission, "delete_update" deletes update permission, "add_backup" adds backup permission, "delete_bakup" deletes backup permission, "add_restore" adds restore permission,  "Delete_restore" deletes restore permission,"add_export" adds export permission," delete_export" deletes export permission],[user name],[database name],[Request type "GET" and "POST ", if the request type is "GET", it can be omitted.]
Example:gc.user("add_query", "user1", "lubm");

Display user:showUser

public String showUser(String request_type);
Function:Display all users
Parameter Definition:[Request types "GET" and "POST" can be omitted if the request type is "GET"]
Example:gc.showUser();

Database query: query

public String query(String db_name, String format, String sparql, String request_type);
Function:query databse
Parameter Definition:[database name], [query result type JSON, HTML or text], [SPARQL statement], [Request type "GET" and "POST ", if the request type is "GET", it can be omitted]
Example:
String res = gc.query("lubm", "json", sparql);
System.out.println(res); //output result

Database deletion :drop

public String drop(String db_name, boolean is_backup, String request_type);
Function:Delete the database directly or delete the database while leaving a backup.
Parameter Definition:[database name], [false not backup, true backup], [request type "GET" and "POST ", if request type "GET" can be omitted]
Example:gc.drop("lubm", false);  //Delete the database without leaving a backup

Monitoring database: monitor

public String monitor(String db_name, String request_type);
Function:Displays information for a specific database
Parameter Definition:[database name], [request type "GET" and "POST ", if request type "GET" can be omitted]Example:gc.monitor("lubm");

Save the database: checkpoint

public String checkpoint(String db_name, String request_type);
Function:If you change the database, save the database 
Parameter Definition:[database name], [request type "GET" and "POST ", if request type "GET" can be omitted]Example:gc.checkpoint("lubm");

Show database:show

public String show(String request_type);Function:Displays all created databasesParameter Definition:[Request types "GET" and "POST" can be omitted if the request type is "GET"]Example:gc.show();

The kernel version information is displayed:getCoreVersion

public String getCoreVersion(String request_type);Function:Get kernel version information Parameter Definition:[Request types "GET" and "POST" can be omitted if the request type is "GET"]Example:gc.getCoreVersion();

Display API version:getAPIVersion

public String getAPIVersion(String request_type);Function:Get API version Parameter:[Request types "GET" and "POST" can be omitted if the request type is "GET"]Example:gc.getAPIVersion();

Query the database and save the file: fquery

public void fquery(String db_name, String format, String sparql, String filename, String request_type);Function:Query the database and save the result to a file Parameter definition:[database name], [query result type JSON, HTML or text], [SPARQL statement], [file name],[Request types "GET" and "POST" can be omitted if the request type is "GET"]Example:gc.fquery("lubm", "json", sparql, "ans.txt");

Export database

public String exportDB(String db_name, String dir_path, String request_type);Function:Export database to parameter definition under file folder:[database name], [database export folder path],[Request types "GET" and "POST" can be omitted if the request type is "GET"】Example:gc.exportDB("lubm", "/root/gStore/");

Python HTTP API

To use the Python API, please refer to the gStore/API/HTTP/Python/src/GstoreConnector. Py. Specific use is as follows:

Construct the initialization function

def __init__(self, ip, port, username, password, http_type='ghttp'):
Function: Initialize
Parameter Definition:[Server IP], [HTTP port on the server], [Username], [password],[HTTP service type]
Example:gc = GstoreConnector.GstoreConnector("127.0.0.1", 9000, "ghttp", "root",
"123456")

Build database: build

def build(self, db_name, rdf_file_path, request_type):
Function:Create a new database from an RDF file
Parameter definition:[Database name],[.nt文件路径],[Request types "GET" and "POST" can be omitted if the request type is "GET"】
Example:res = gc.build("lubm", "data/lubm/lubm.nt")

Load database: load

def load(self, db_name, request_type):
Function:load the database you have created
Parameter definition:[database name], [request type "GET" and "POST ", if request type "GET" can be omitted]
Example:res = gc.load("lubm")

Unload database: unload

def unload(self, db_name, request_type):
Function:Unload database
Parameter definition:[database name], [request type "GET" and "POST ", if request type "GET" can be omitted]
Example:res = gc.unload("lubm")

User management: user

def user(self, type, username2, addition, request_type):
Function:The root user can add, delete, or modify the user's permission only.
1.Add or delete users:
Parameter definition:["add_user" adds a user, "delete_user" deletes a user],  [username],[password],[Request types "GET" and "POST" can be omitted if the Request type is "GET"]
Example:res = gc.user("add_user", "user1", "111111")
2.Modify user's privilege:
Parameter definition:["Add_query" adds query permission, "delete_query" deletes query permission, "add_load" adds load permission, "delete_load" deletes load permission, "add_unload" adds no load permission, "delete_unload" deletes no load permission,  "Add_update" adds update permission, "delete_update" deletes update permission, "add_backup" adds backup permission, "delete_bakup" deletes backup permission, "add_restore" adds restore permission,  "Delete_restore" deletes restore permission,"add_export" adds export permission," delete_export" deletes export permission],  [user name],[database name],[Request types "GET" and "POST" can be omitted if the Request type is "GET"]
Example:res = gc.user("add_query", "user1", "lubm")

Display users: showUser

def showUser(self, request_type):
Function:Display all users
Parameter definition:[Request types "GET" and "POST" can be omitted if the request type is "GET"]
Example:res = gc.showUser()

Query Database: query

def query(self, db_name, format, sparql, request_type):
Function:Query the database
Parameter definition:[Database name],[Query result type JSON, HTML or text], [SPARQL statement], [Request types "GET" and "POST" can be omitted if the Request type is "GET"]
Example:
res = gc.query("lubm", "json", sparql)
print(res) //output result

Database deletion: drop

def drop(self, db_name, is_backup, request_type):
Function:Delete the database directly or delete the database while leaving a backup
Parameter definition:[database name], [false not backup, true backup],[Request types "GET" and "POST" can be omitted if the request type is "GET"]
Example:res = gc.drop("lubm", false)  //Delete the database without leaving a backup

Database Monitor :monitor

def monitor(self, db_name, request_type):    Function:Displays information for a specific database Parameter definition:[Database name],[Request types "GET" and "POST" can be omitted if the request type is "GET"] 
Example:res = gc.monitor("lubm")

Save database: checkpoint

def checkpoint(self, db_name, request_type):Function:If the database is changed, save the meaning of the database parameters:[database name], [request type "GET" and "POST ", if request type "GET" can be omitted] Example:res = gc.checkpoint("lubm")

Display database:show

def show(self, request_type):Function:Display the meanings of all created databases:[Request types "GET" and "POST" can be omitted if the request type is "GET"] 
Example:res = gc.show()

The kernel version information is displayed: getCoreVersion

def getCoreVersion(self, request_type):Function:Get the definition of kernel version parameter :[Request types "GET" and "POST" can be omitted if the request type is "GET"] 
Example:res = gc.getCoreVersion()

Display API version: getAPIVersion

def getAPIVersion(self, request_type):Function:Get the API version information parameter definition:[Request types "GET" and "POST" can be omitted if the request type is "GET"]
Example:res = gc.getAPIVersion()

Query the database and save the file: fquery

def fquery(self, db_name, format, sparql, filename, request_type):Function:Query the database and save the result to a file Parameter definition:[database name], [query result type JSON, HTML or text], [SPARQL statement], [file name],[Request types "GET" and "POST" can be omitted if the request type is "GET"]
Example:gc.fquery("lubm", "json", sparql, "ans.txt")

Export databse

def exportDB(self, db_name, dir_path, request_type): Function:parameter definition of exprotin database to folders:[database name], [database export folder path],[Request types "GET" and "POST" can be omitted if the request type is "GET"]
Example:res = gc.exportDB("lubm", "/root/gStore/")

Node.js HTTP API

Before using the Nodejs API, type NPM install Request and NPM Install request-promise to add the required modules under the Nodejs folder.

To use Nodejs API, please refer to the gStore/API/http/Nodejs/GstoreConnector.js. Specific use is as follows:

Construct the initialization function

class GstoreConnector(ip = '', port, httpType = 'ghttp', username = '', password
= '');
Function: Initialize
Parameter Definition:[Server IP], [HTTP port on the server], [HTTP service type], [Username], [password]
Example:gc = new GstoreConnector("127.0.0.1", 9000, "ghttp", "root", "123456");

Build database: build

async build(db_name = '', rdf_file_path = '', request_type);
Function:Create a new database from an RDF file
The defintion of parameters are as follows: [database name], [.nt file path],[Request types "GET" and "POST" can be omitted if the request type is "GET"]
Example:res = gc.build("lubm", "data/lubm/lubm.nt");

Load database:load

async load(db_name = '', request_type);
Function:Load the database you have created
Parameter definition:[database name], [request type "GET" and "POST ", if request type "GET" can be omitted]
Example:res = gc.load("lubm");

Unload databse:unload

async unload(db_name = '', request_type);
Function:Unload databse
Parameter definition:[database name], [request type "GET" and "POST ", if request type "GET" can be omitted]
Example:res = gc.unload("lubm");

User management:user

async user(type = '', username2 = '' , addition = '' , request_type);
Function:The root user can add, delete, or modify the user's permission only
1.Add or delete users:
Parameter definition:["add_user" adds a user, "delete_user" deletes a user],  [user name],[password],[Request types "GET" and "POST" can be omitted if the Request type is "GET"]
Example:res = gc.user("add_user", "user1", "111111");
2.Privilege to modify user:
Parameter definition:["Add_query" adds query permission, "delete_query" deletes query permission, "add_load" adds load permission, "delete_load" deletes load permission, "add_unload" adds no load permission, "delete_unload" deletes no load permission,  "Add_update" adds update permission, "delete_update" deletes update permission, "add_backup" adds backup permission, "delete_bakup" deletes backup permission, "add_restore" adds restore permission,  "Delete_restore" deletes restore permission,"add_export" adds export permission," delete_export" deletes export permission],  [user name],[database name],[Request types "GET" and "POST" can be omitted if the Request type is "GET"]]
Example:res = gc.user("add_query", "user1", "lubm");

Display user:showUser

async showUser(request_type);
Function:Display all users
Parameter definition: [Request types "GET" and "POST" can be omitted if the request type is "GET"]
Example:res = gc.showUser();

Query database:query

async query(db_name = '', format = '' , sparql = '' , request_type);
Function:Query database
Parameter definition:[Database name], [query result type JSON, HTML or text], [SPARQL statement], [Request types "GET" and "POST" can be omitted if the Request type is "GET"]
Example:
res = gc.query("lubm", "json", sparql);
console.log(JSON.stringify(res,",")); //output result

Database deletion:drop

async drop(db_name = '', is_backup , request_type);
Function:Delete the database directly or delete the database while leaving a backup
Parameter definition:[database name],[false no backup, true backup],[Request types "GET" and "POST" can be omitted if the request type is "GET"]
Example:res = gc.drop("lubm", false);  //Delete the database without leaving a backup

Database monitor: monitor

async monitor(db_name = '', request_type);     Function:Parameter definition for displaying information about a specific database:[database name], [request type "GET" and "POST ", if request type "GET" can be omitted]Example:res = gc.monitor("lubm");

Save database: checkpoint

async checkpoint(db_name = '', request_type);Function:If the database is changed, the parameter definition of saving database:[database name], [request type "GET" and "POST ", if request type "GET" can be omitted]Example:res = gc.checkpoint("lubm");

Display database: show

async show(request_type);Function:Displays all created databases Parameter definition: [Request types "GET" and "POST" can be omitted if the request type is "GET"]Example:res = gc.show();

Display kernel version information: getCoreVersion

async getCoreVersion(request_type);Function:Get kernel version information 
Parameter definition: [Request types "GET" and "POST" can be omitted if the request type is "GET"]Example:res = gc.getCoreVersion();

Display API version: getAPIVersion

async getAPIVersion(request_type);
Function:Get the API version information	
Parameter definition:[Request types "GET" and "POST" can be omitted if the request type is "GET"]
Example:res = gc.getAPIVersion();

Query the database and save the file: fquery

async fquery(db_name = '', format = '' , sparql = '' , filename = '' , request_type);
Function:Query the database and save the results to a file
Parameter definition:[database name], [query result type JSON, HTML or text], [SPARQL statement], [file name],  [Request types "GET" and "POST" can be omitted if the Request type is "GET"]
Example:gc.fquery("lubm", "json", sparql, "ans.txt");

Export database

async exportDB(db_name = '' , dir_path = '' , request_type); 
Function:export database to folders
parameter definition:[database name], [directory where the database is exported], [Request types "GET" and "POST" can be omitted if the Request type is "GET"]
Example:res = gc.exportDB("lubm", "/root/gStore/");

PHP HTTP API

To use the Php API, please refer to the gStore/API/HTTP/Php/SRC/GstoreConnector. Php. Specific use is as follows:

Construct the initialization function

class GstoreConnector($ip, $port, $httpType, $username, $password)
Function: Initialize
Parameter Definition:[Server IP], [HTTP port on the server], [HTTP service type], [Username], [password]
Example:$gc = new GstoreConnector("127.0.0.1", 9000, "ghttp", "root", "123456");

Build databse:build

function build($db_name, $rdf_file_path, $request_type)
Function:Create a new database from an RDF file
Parameter definition:[database name], [.nt file path],[Request types "GET" and "POST" can be omitted if the request type is "GET"]
Example:
$res = $gc->build("lubm", "data/lubm/lubm.nt");
echo $res . PHP_EOL;

Load database:load

function load($db_name, $request_type)
Function:Load the database you have created
Parameter definition:[database name], [request type "GET" and "POST ", if request type "GET" can be omitted]
Example:
$ret = $gc->load("test");
echo $ret . PHP_EOL;

Unload databse:unload

function unload($db_name, $request_type)
Function:Unload databse
Parameter definition:[database name],[Request types "GET" and "POST" can be omitted if the request type is "GET"]
Example:
$ret = $gc->unload("test");
echo $ret . PHP_EOL;

User management:user

function user($type, $username2, $addition, $request_type)
Function:Only the root user can add, delete, or modify the user's permission
1.Add or delete users:
Parameter definition:["add_user" adds a user, "delete_user" deletes a user],  [user name],[password],[Request types "GET" and "POST" can be omitted if the Request type is "GET"]
Example:
$res = $gc->user("add_user", "user1", "111111");
echo $res . PHP_EOL;
2.Privilege to modify user:
参数含义:["Add_query" adds query permission, "delete_query" deletes query permission, "add_load" adds load permission, "delete_load" deletes load permission, "add_unload" adds no load permission, "delete_unload" deletes no load permission,  "Add_update" adds update permission, "delete_update" deletes update permission, "add_backup" adds backup permission, "delete_bakup" deletes backup permission, "add_restore" adds restore permission,  "Delete_restore" deletes restore permission,"add_export" adds export permission," delete_export" deletes export permission],  [user name],[database name],[Request types "GET" and "POST" can be omitted if the Request type is "GET"]]
Example:
$res = $gc->user("add_user", "user1", "lubm");
echo $res . PHP_EOL;

Display user:showUser

function showUser($request_type)
Function:Display all users
Parameter definition:[Request types "GET" and "POST" can be omitted if the request type is "GET"]
Example:
$res = $gc->showUser();
echo $res. PHP_EOL;

Query database:query

function query($db_name, $format, $sparql, $request_type)
Parameter definition:[database name], [query result type JSON, HTML or text], [SPARQL statement],[Request types "GET" and "POST" can be omitted if the request type is "GET"]
Example:
$res = $gc->query("lubm", "json", $sparql);
echo $res. PHP_EOL; //output result

Database deletion:drop

function drop($db_name, $is_backup, $request_type)
Function:Delete the database directly or delete the database while leaving a backup
Parameter definition:[database name], [false not backup, true backup],[Request types "GET" and "POST" can be omitted if the request type is "GET"]
Example:
$res = $gc->drop("lubm", false); //Delete the database without leaving a backup
echo $res. PHP_EOL;             

Database monitor: monitor

function monitor($db_name, $request_type)Function:Displays information for a specific database 
Parameter definition:[database name], [request type "GET" and "POST ", if request type "GET" can be omitted]
Example:$res = $gc->monitor("lubm");echo $res. PHP_EOL;

Save database: checkpoint

function checkpoint($db_name, $request_type)Function:the Parameter definition of save database if it has been changed:[database name], [request type "GET" and "POST ", if request type "GET" can be omitted]Example:$res = $gc->checkpoint("lubm");echo $res. PHP_EOL;

Display database: show

function show($request_type)Function:Displays all created databases
Parameter definition:[Request types "GET" and "POST" can be omitted if the request type is "GET"]
Example:$res = $gc->show();echo $res. PHP_EOL;

Display kernel version information: getCoreVersion

function getCoreVersion($request_type)Function:get kernel version information
Parameter definition: [Request types "GET" and "POST" can be omitted if the request type is "GET"]
Example:$res = $gc->getCoreVersion();echo $res. PHP_EOL;

Display API version: getAPIVersion

function getAPIVersion($request_type)
Function:Get API version	
Parameter definition: [Request types "GET" and "POST" can be omitted if the request type is "GET"]
Example:
$res = $gc->getAPIVersion();
echo $res. PHP_EOL;

Query the database and save the file:fquery

function fquery($db_name, $format, $sparql, $filename, $request_type)
Function:Query the database and save the results to a file
Parameter definition:[database name], [query result type JSON, HTML or text], [SPARQL statement], [file name],[Request types "GET" and "POST" can be omitted if the request type is "GET"]
Example:$gc->fquery("lubm", "json", $sparql, "ans.txt");

Export database

function exportDB($db_name, $dir_path, $request_type)
Function:Export the database to a folder
Parameter definition:[database name], [database export folder path],[Request types "GET" and "POST" can be omitted if the request type is "GET"]
Example:$res = $gc->exportDB("lubm", "/root/gStore/");