Base URL

All API requests are made to the following base URL:

https://api.unize.org

Unize AI 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:

Step 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.

Step 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!

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 /api/graph/ 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/api/graph/"

payload = {
    "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
        }
    ]
}
headers = {
    "Content-Type": "application/json"
}

response = requests.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 export it as Cypher or JSON.

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 /api/graph/ 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 /api/graph/data/ endpoint. The request requires the following parameters: api_key and execution_id.

The cypher_query parameter is optional. If set to FALSE, the API will return JSON, and if set to TRUE, the API will return Cypher.

Here is an example of how to export a graph using Python:

import requests

url = "https://api.unize.org/api/graph/data/"

payload = {
    "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)

The sample request above will return the nodes and relationships of the generated graph. Here is an example of the response:

{
  "graph": {
    "nodes": [
      {
        "node_label": "Person",
        "node_name": "Joanne",
        "node_var": "person_joanne",
        "node_properties": "{name: 'Joanne'}",
        "snippet": "Joanne is an employee of Unize."
      },
      {
        "node_label": "Company",
        "node_name": "Unize",
        "node_var": "company_unize",
        "node_properties": "{name: 'Unize'}",
        "snippet": "Joanne is an employee of Unize."
      }
    ],
    "relationships": [
      {
        "rel_type": "EMPLOYEE_OF",
        "start_node": "person_joanne",
        "end_node": "company_unize",
        "rel_properties": "{execution_id: '3c90c3cc-0d44-4b50-8888-8dd25736052a', timestamp: '2023-11-07T05:31:56Z'}"
      }
    ]
  },
  "latest_graph_merge_data": {
    "status": "completed",
    "timestamp": "2023-11-07T05:31:56Z",
    "completed_at": "2023-11-07T05:31:56Z"
  }
}

Visualizing the Generated Knowledge Graph

If you set the cypher_query parameter when calling the POST api/graph/data/ endpoint to TRUE, the Unize API will return the Cypher generated from processing your text. One way to visualize the graph is by using Neo4j’s AuraDB service. Copy the Cypher 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.