Base URL

All API requests are made to the following base URL:
https://api.unize.org

Unize API Key

The Unize API uses API keys for authenticating requests. Here is a step-by-step guide on how to generate an API Key:
1

Create an account

To begin accessing Unize AI, you have to create an API account first. You can sign up for an account here. After signing up, you must verify your account by following the verification link in your email. You will be asked to create a password for your account.
2

Generate an API Key

To use the Unize API, you need an API key. You can generate an API key by navigating to the API Keys page and clicking on the “Create New Secret Key” button. You will be asked to provide a name for your API key. After providing a name, click on the “Create” button.
Keep a copy of your API key in a secure place. Do not share it with anyone!
How to generate an API keyHow to generate an API key

Generating a Knowledge Graph

Once you have your API key and a positive credit balance, you can start generating knowledge graphs. When generating a knowledge graph by providing input text, you need to make a POST request to the /v1/storage/generate/ endpoint. The request requires the following parameters: api_key, documents.text, and documents.source_title. Here is an example of how to create a knowledge graph from text using Python:
import requests

url = "https://api.unize.org/v1/storage/generate/"

payload = {
    "execution_id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
    "api_key": "enter-your-api-key-here", # Replace with your API key
    "documents": [
        {
            "text": "Joanne is an employee of Unize.", # Text to convert to a graph
            "source_title": "Diary of Joanne" # Title for the text source
        }
    ],
    "system": "st_0_75",
    "extraction_mode": "detailed"
}
headers = {"Content-Type": "application/json"}

response = requests.request("POST", url, json=payload, headers=headers)

print(response.text)
The response will contain an execution_id which you can use to visualize the graph or review the generated nodes and relationships.
The execution_id is a unique identifier for the generated graph. If you want to update an existing graph with new data, you can use the generated execution_id for that existing graph the next time you make a request to the /v1/storage/generate/ endpoint.
{
  "execution_id": "3c90c3cc-0d44-4b50-8888-8dd25736052a"
}

Exporting a Knowledge Graph

Once you have the execution_id of the generated graph, you can export the graph by making a POST request to the /v1/storage/export/ endpoint. The request requires the following parameters: api_key and execution_id. The cypher_query parameter is optional and defaults to false. When false, the API returns a JSON object with arrays of nodes and relationships. If set to true, the response will be a JSON object containing a Cypher Query string instead. Check out the tabs below to see how to call the /v1/storage/export endpoint and how the responses would look like depending on the value passed to cypher_query parameter.

Request

import requests

url = "https://api.unize.org/v1/storage/export/"

payload = {
    "cypher_query": False,
    "api_key": "enter-your-api-key-here", # Replace with your API key
    "execution_id": "3c90c3cc-0d44-4b50-8888-8dd25736052a" # This is a sample execution_id; replace with your execution_id
}
headers = {
    "Content-Type": "application/json"
}

response = requests.post(url, json=payload, headers=headers)

print(response.text)

Response

The sample request above will return a graph object that contain the nodes and relationships of the generated graph. Here is a sample response:
{
  "graph": {
    "nodes": [
      {
        "node_label": "Person",
        "node_name": "Joanne",
        "node_var": "4:3c90c3cc-0d44-4b50-8888-8dd25736052a:5585",
        "node_properties": {
          "snippet": "Joanne is a Unize employee.",
          "execution_id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
          "name": "Tracy"
        },
        "snippet": null
      },
      {
        "node_label": "Company",
        "node_name": "Unize",
        "node_var": "4:3c90c3cc-0d44-4b50-8888-8dd25736052a:5586",
        "node_properties": {
          "snippet": "Joanne is a Unize employee.",
          "execution_id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
          "name": "Unize"
        },
        "snippet": null
      }
    ],
    "relationships": [
      {
        "rel_type": "EMPLOYEE_OF",
        "start_node": "4:3c90c3cc-0d44-4b50-8888-8dd25736052a:5585",
        "end_node": "4:3c90c3cc-0d44-4b50-8888-8dd25736052a:5586",
        "rel_properties": {
          "execution_id": "3c90c3cc-0d44-4b50-8888-8dd25736052a"
        }
      }
    ]
  },
  "latest_graph_merge_data": {
    "extraction_criteria": "null",
    "status": "completed",
    "timestamp": "2023-11-07T05:31:56Z",
    "completed_at": "2023-11-07T05:31:56Z",
    "sysytem": "st_0_75",
    "extraction_mode": "detailed"
  }
}

Visualizing the Generated Knowledge Graph

If you set the cypher_query parameter to True when calling the POST /v1/storage/export/ endpoint, Unize API will return the Cypher Query generated from processing your text. One way to visualize the graph is by using Neo4j’s AuraDB service. Copy the Cypher Query and paste it into your AuraDB instance to visualize the graph.
If you don’t have a Neo4j AuraDB instance, you can create one by following the steps outlined on the Neo4j AuraDB page.