Python SDK Reference¶
The Interactive Python SDK Reference is a comprehensive guide designed to assist developers in integrating the Interactive service into their Python applications. This SDK allows users to seamlessly connect to Interactive and harness its powerful features for graph management, stored procedure management, and query execution.
Requirements.¶
Python 3.7+
Installation & Usage¶
pip install¶
pip3 install interactive-sdk
Then import the package:
import interactive_sdk
Setuptools¶
Install via Setuptools.
python setup.py install --user
(or sudo python setup.py install
to install the package for all users)
Then import the package:
import interactive_sdk
Tests¶
Execute pytest
to run the tests.
Getting Started¶
First, install and start the interactive service via Interactive Getting Started, and you will get the endpoint for the Interactive service.
Interactive Service is listening at ${INTERACTIVE_ENDPOINT}.
Then, connect to the interactive endpoint, and try to run a simple query with following code.
from interactive_sdk.client.driver import Driver
# replace endpoint with the actual interactive endpoint, this is mock server just for testing.
interactive_endpoint='https://virtserver.swaggerhub.com/GRAPHSCOPE/interactive/1.0.0/'
driver = Driver(endpoint=interactive_endpoint)
# Interactive will initially start on a builtin modern graph. You can run a simple cypher query
with driver.getNeo4jSession() as session:
resp = session.run('MATCH(n) RETURN COUNT(n);')
for record in resp:
print('record: ', record)
# record: <Record $f0=6>
For a more detailed example, please refer to Python SDK Example.
Documentation for Service APIs¶
All URIs are relative to ${INTERACTIVE_ENDPOINT}
Class |
Method |
HTTP request |
Description |
---|---|---|---|
AdminServiceGraphManagementApi |
POST /v1/graph/{graph_id}/dataloading |
||
AdminServiceGraphManagementApi |
POST /v1/graph |
||
AdminServiceGraphManagementApi |
DELETE /v1/graph/{graph_id} |
||
AdminServiceGraphManagementApi |
GET /v1/graph/{graph_id} |
||
AdminServiceGraphManagementApi |
GET /v1/graph/{graph_id}/schema |
||
AdminServiceGraphManagementApi |
GET /v1/graph |
||
AdminServiceJobManagementApi |
DELETE /v1/job/{job_id} |
||
AdminServiceJobManagementApi |
GET /v1/job/{job_id} |
||
AdminServiceJobManagementApi |
GET /v1/job |
||
AdminServiceProcedureManagementApi |
POST /v1/graph/{graph_id}/procedure |
||
AdminServiceProcedureManagementApi |
DELETE /v1/graph/{graph_id}/procedure/{procedure_id} |
||
AdminServiceProcedureManagementApi |
GET /v1/graph/{graph_id}/procedure/{procedure_id} |
||
AdminServiceProcedureManagementApi |
GET /v1/graph/{graph_id}/procedure |
||
AdminServiceProcedureManagementApi |
PUT /v1/graph/{graph_id}/procedure/{procedure_id} |
||
AdminServiceServiceManagementApi |
GET /v1/service/status |
||
AdminServiceServiceManagementApi |
POST /v1/service/restart |
||
AdminServiceServiceManagementApi |
POST /v1/service/start |
||
AdminServiceServiceManagementApi |
POST /v1/service/stop |
||
GraphServiceEdgeManagementApi |
POST /v1/graph/{graph_id}/edge |
Add edge to the graph |
|
GraphServiceEdgeManagementApi |
DELETE /v1/graph/{graph_id}/edge |
Remove edge from the graph |
|
GraphServiceEdgeManagementApi |
GET /v1/graph/{graph_id}/edge |
Get the edge’s properties with src and dst vertex primary keys. |
|
GraphServiceEdgeManagementApi |
PUT /v1/graph/{graph_id}/edge |
Update edge’s property |
|
GraphServiceVertexManagementApi |
POST /v1/graph/{graph_id}/vertex |
Add vertex to the graph |
|
GraphServiceVertexManagementApi |
DELETE /v1/graph/{graph_id}/vertex |
Remove vertex from the graph |
|
GraphServiceVertexManagementApi |
GET /v1/graph/{graph_id}/vertex |
Get the vertex’s properties with vertex primary key. |
|
GraphServiceVertexManagementApi |
PUT /v1/graph/{graph_id}/vertex |
Update vertex’s property |
|
QueryServiceApi |
POST /v1/graph/{graph_id}/query |
run queries on graph |