UltipaDocs
Try Playground
  • Introduction
  • RESTful API
    • Installation
    • Connection
      • Request Configuration
      • Querying Methods
      • UQL Execution
      • Graphset Management
      • Schema and Property Management
      • Data Insertion and Deletion
      • Query Acceleration
      • Algorithm Management
      • Downloads and Exports
      • Process and Task Management
      • Access Management
      • Others
    • Result Processing
    • Types Mapping
    • Installation
    • Connection
      • Request Configuration
      • Querying Methods
      • UQL Execution
      • Graphset Management
      • Schema and Property Management
      • Data Insertion and Deletion
      • Query Acceleration
      • Algorithm Management
      • Downloads and Exports
      • Process and Task Management
      • Access Management
      • Others
    • Result Processing
    • Types Mapping
    • Installation
    • Connection
      • Request Configuration
      • Querying Methods
      • UQL Execution
      • Graphset Management
      • Schema and Property Management
      • Data Insertion and Deletion
      • Query Acceleration
      • Algorithm Management
      • Downloads and Exports
      • Process and Task Management
      • Access Management
      • Others
    • Result Processing
    • Types Mapping
    • Installation
    • Connection
      • Request Configuration
      • Querying Methods
      • UQL Execution
      • Graphset Management
      • Schema and Property Management
      • Data Insertion and Deletion
      • Query Acceleration
      • Algorithm Management
      • Downloads and Exports
      • Process and Task Management
      • Access Management
      • Others
    • Result Processing
    • Types Mapping
    • Installation
    • Connection
      • Request Configuration
      • Querying Methods
      • UQL Execution
      • Graphset Management
      • Schema and Property Management
      • Data Insertion and Deletion
      • Query Acceleration
      • Algorithm Management
      • Downloads and Exports
      • Process and Task Management
      • Access Management
      • Others
    • Result Processing
    • Types Mapping
  1. Docs
  2. /
  3. Ultipa Drivers

RESTful API

NOTE

This article introduces the minimum procedure of using Ultipa RESTful API proxy.

Change Log (V4.0 to V4.2)

  • Use Go SDK v4.2
  • Abandon command line parameter -bodytype
  • Add interfaces /uql/stream, /update/nodes and /update/edges

Prerequisites

  • a command line terminal that is compatible with your operating system:
    • Linux or MacOS: bash, zsh, tcsh
    • Windows: PowerShell
  • a version of Ultipa Importer compatible with your operating system

Start API Service

  1. Show help

Bash
./ultipa_restful_api.exe --help
  1. Show current version

Bash
./ultipa_restful_api.exe --version
  1. Start API service
Command
./ultipa_restful_api.exe --hosts 192.168.1.85:61095,192.168.1.87:61095,192.168.1.88:61095 -u employee -p joaGsdf -w 3

Note: -hosts, -u and -p are equivalent to --hosts, --username and --password

Other Parameters:

Parameter
Description
Default Value
-l --listenThe network and initial port to listen0.0.0.0:7001
-w --workersThe number of backend workers (threads), e.g.: 5 works will be the default 7001-70050
-g --graphThe graphset name'default'
-b --boostUse SimpleCache(Do not use cache)
-c --consistencyUse leader to guarantee Consistency Read(Do not use leader)
-batch --batchThe batch size (number of records) of /insert/nodes and /insert/edges5000
-d --durationThe batch insert waiting time (milliseconds)1000
-hb --heartbeatThe heartbeat seconds for all instances5
-sd --schema_cache_durationThe heartbeat milliseconds when acquiring schema list during insert5000

API Basic Info

  • Request type: POST
  • Request URL:
    • Linux: the Ultipa server that the current API service connects, e.g. 'http://192.168.1.88'
    • Windows/MacOS: the local address of the current API service, 'http://127.0.0.1'
  • Request port: the valid ports set via -w and -l when starting the API service
  • Body parameter type: JSON, FORM

Login Ultipa Service

  • Request URL

Bash
.../login
  • Request Example
JSON
{
    "username": "employee",
    "password": "joaGsdf"
}
  • Response: the token value after login
NOTE

The rest of API interfaces should all have this token value carried in Cookie in the Headers, ultipa=<token_value>, with Content_Type application/json.

Send UQL

  • Request URL

Bash
.../uql
  • Request Parameter
ParameterTypeRequired
Description
uqlstringyesUQL statement
graphstringnoThe graphset name (default value: the graphset designated when starting the API service)
  • Request Example
JSON
{
    "uql": "find().nodes({name == \"abc\"}) return count(nodes)",
    "graph": "test_text"
}
  • Success Response
JSON
{
    "Data": [
        {
            "Name": "count(nodes)",
            "PropertyType": 4,
            "Rows": [
                2
            ]
        }
    ],
    "Graph": "test_text",
    "Statistic": {
        "NodeAffected": 0,
        "EdgeAffected": 0,
        "TotalCost": 0,
        "EngineCost": 0
    },
    "Status": {
        "Message": "",
        "Code": 0
    }
}

Send UQL and limit returns

  • Request URL

Bash
.../uql/stream
  • Request Parameter
ParameterTypeRequired
Description
uqlstringyesUQL statement
graphstringnoThe graphset name (default value: the graphset designated when starting the API service)
package_numintnoThe number of packages to return (default value: 0, query but do not return)
  • Request Example
JSON
{
    "uql": "find().nodes({name == \"abc\"}) return nodes",
    "graph": "test_text",
    "package_num": 1
}
  • Success Response

Insert Nodes

  • Request URL

Bash
.../insert/nodes
  • Request Parameter
ParameterTypeRequired
Description
nodes[{},{},...] (JSON), map (FORM)yesNode properties, must include all custom properties, do not support _uuid; in tools such as Postman, set multiple nodes with type {} as FORM parameter
schemastringyesNode schema
graphstringnoThe graphset name (default value: the graphset designated when starting the API service)
syncboolnoIf return the status of request (default value: false). A 'true' value will induce batch waiting time (-d, --duration) when the data volume is less than batch size (-b, --batch), which will affect the insert performance
  • Request Example
JSON
{
    "nodes": [{"name":"Jason","_id":"USER001"},{"name":"Alice"}],
    "schema": "default",
    "graph": "test_text",
    "sync": true
}
  • Success Response
JSON
{
    "Msg": "Insert Nodes Success: [{\"_id\":\"USER001\",\"name\":\"Jason\"},{\"name\":\"Alice\"}]"
}

Insert Edges

  • Request URL

Bash
.../insert/edges
  • Request Parameter
ParameterTypeRequired
Description
edges[{},{},...] (JSON), map (FORM)yesEdge properties, must carry _from&_to and all custom properties, do not support _uuid, _from_uuid or _to_uuid; in tools such as Postman, set multiple edges with type {} as FORM parameter
schemastringyesEdge schema
graphstringnoThe graphset name (default value: the graphset designated when starting the API service)
syncboolnoIf return the status of request (default value: false). A 'true' value will induce batch waiting time (-d, --duration) when the data volume is less than batch size (-b, --batch), which will affect the insert performance
  • Request Example
JSON
{
    "edges": [{"year":"1998", "_from":"USER001", "_to":"USER002"}],
    "schema": "default",
    "graph": "test_text",
    "sync": true
}
  • Success Response
JSON
{
    "Msg": "Insert Edges Success: [{\"_from\":\"USER001\",\"_to\":\"USER002\",\"year\":\"1998\"}]"
}

Update Nodes

Update nodes based on _id or _uuid.

  • Request URL

Bash
.../update/nodes
  • Request Parameter
ParameterTypeRequired
Description
nodes[{},{},...] (JSON), map (FORM)yesNode properties, must include _id or _uuid, if both are included then ignore _uuid; in tools such as Postman, set multiple nodes with type {} as FORM parameter
graphstringnoThe graphset name (default value: the graphset designated when starting the API service)
  • Request Example
JSON
{
    "nodes": [{"age":"35", "_id":"USER001"}, {"name":"John", "_id": "USER002"}],
    "graph": "test_text"
}
  • Success Response
JSON
{
    "Msg": "Update nodes on test_text",
    "SuccessCount": 2
}

Update Edges

Update edges based on _from&_to or _uuid.

  • Request URL

Bash
.../update/edges
  • Request Parameter
ParameterTypeRequired
Description
edges[{},{},...] (JSON), map (FORM)yesEdge properties, must carry _from&_to or _uuid, if both are included then ignore _uuid; in tools such as Postman, set multiple edges with type {} as FORM parameter
graphstringnoThe graphset name (default value: the graphset designated when starting the API service)
  • Request Example
JSON
{
    "edges": [{"_uuid":"1","_from_uuid":"2", "age":"55"}],
    "graph": "test_text"
}
  • Success Response
JSON
{
    "Msg": "Update edges on test_text",
    "SuccessCount": 1
}