> This page is for Analytics API.

> For clean Markdown of any page, append .md to the page URL.
> For a complete documentation index, see https://documentation.babelstreet.com/llms.txt.
> For AI client integration (Claude Code, Cursor, etc.), connect to the MCP server at https://documentation.babelstreet.com/_mcp/server.

# Extract relationships from input

POST https://analytics.babelstreet.com/rest/v1/relationships
Content-Type: application/json

Returns the relationships between entities in the input text.  The response is a list of extracted relationships. A relationship contains  predicate - usually the main verb, property or action that is expressed by the text arg1 - usually the subject, agent or main actor of the relationship arg1Id \[optional] - the entity ID to link an entity to a knowledgebase  arg2 \[optional] - complements the predicate and is usually the object, theme or patient of the relationship arg2Id \[optional] - the entity ID to link an entity to a knowledgebase confidence - a measure of quality of relationship extraction, between 0 - 1

Reference: https://documentation.babelstreet.com/analytics/text-analytics/relationship-extractor/extract-relationships-from-input

## Authentication

- `X-BabelStreetAPI-Key` header (required) — API Key authentication via header
- `X-RosetteAPI-Key` header (required) — API Key authentication via header

## Servers

- `https://analytics.babelstreet.com/rest/v1` (https://analytics.babelstreet.com/rest/v1/, default)
- `https://api.rosette.com/rest/v1` (https://api.rosette.com/rest/v1/)

## Request

### Body (application/json)

This endpoint expects a DocumentRequest.

- `content` (string, optional)
- `contentUri` (string, optional)
- `language` (string, optional) — 3 letter code of language.

## Response

### 200

OK

- `relationships` (list of RelationshipResponse, optional)

## Types

### RelationshipResponse

- `arg1` (string, optional) — relationship arg1
- `arg1id` (string, optional) — relationship arg1 id
- `arg2` (string, optional) — relationship arg2
- `arg2id` (string, optional) — relationship arg2 id
- `confidence` (double, optional) — a measure of the quality of relationship extraction
- `predicate` (string, optional) — relationship type or predicate

## Examples

### JSON String

**Request**

```json
{
  "content": "FLIR Systems is headquartered in Oregon and produces thermal imaging, night vision, and infrared cameras and sensor systems.  According to the SEC’s order instituting a settled administrative proceeding, FLIR entered into a multi-million dollar contract to provide thermal binoculars to the Saudi government in November 2008.  Timms and Ramahi were the primary sales employees responsible for the contract, and also were involved in negotiations to sell FLIR’s security cameras to the same government officials.  At the time, Timms was the head of FLIR’s Middle East office in Dubai."
}
```

**Response**

```json
{
  "relationships": [
    {
      "arg1": "string",
      "arg1id": "string",
      "arg2": "string",
      "arg2id": "string",
      "confidence": 1.1,
      "predicate": "string"
    }
  ]
}
```

**SDK Code**

```python JSON String
import requests

url = "https://analytics.babelstreet.com/rest/v1/relationships"

payload = { "content": "FLIR Systems is headquartered in Oregon and produces thermal imaging, night vision, and infrared cameras and sensor systems.  According to the SEC’s order instituting a settled administrative proceeding, FLIR entered into a multi-million dollar contract to provide thermal binoculars to the Saudi government in November 2008.  Timms and Ramahi were the primary sales employees responsible for the contract, and also were involved in negotiations to sell FLIR’s security cameras to the same government officials.  At the time, Timms was the head of FLIR’s Middle East office in Dubai." }
headers = {
    "X-BabelStreetAPI-Key": "<apiKey>",
    "Content-Type": "application/json"
}

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

print(response.json())
```

```javascript JSON String
const url = 'https://analytics.babelstreet.com/rest/v1/relationships';
const options = {
  method: 'POST',
  headers: {'X-BabelStreetAPI-Key': '<apiKey>', 'Content-Type': 'application/json'},
  body: '{"content":"FLIR Systems is headquartered in Oregon and produces thermal imaging, night vision, and infrared cameras and sensor systems.  According to the SEC’s order instituting a settled administrative proceeding, FLIR entered into a multi-million dollar contract to provide thermal binoculars to the Saudi government in November 2008.  Timms and Ramahi were the primary sales employees responsible for the contract, and also were involved in negotiations to sell FLIR’s security cameras to the same government officials.  At the time, Timms was the head of FLIR’s Middle East office in Dubai."}'
};

try {
  const response = await fetch(url, options);
  const data = await response.json();
  console.log(data);
} catch (error) {
  console.error(error);
}
```

```go JSON String
package main

import (
	"fmt"
	"strings"
	"net/http"
	"io"
)

func main() {

	url := "https://analytics.babelstreet.com/rest/v1/relationships"

	payload := strings.NewReader("{\n  \"content\": \"FLIR Systems is headquartered in Oregon and produces thermal imaging, night vision, and infrared cameras and sensor systems.  According to the SEC’s order instituting a settled administrative proceeding, FLIR entered into a multi-million dollar contract to provide thermal binoculars to the Saudi government in November 2008.  Timms and Ramahi were the primary sales employees responsible for the contract, and also were involved in negotiations to sell FLIR’s security cameras to the same government officials.  At the time, Timms was the head of FLIR’s Middle East office in Dubai.\"\n}")

	req, _ := http.NewRequest("POST", url, payload)

	req.Header.Add("X-BabelStreetAPI-Key", "<apiKey>")
	req.Header.Add("Content-Type", "application/json")

	res, _ := http.DefaultClient.Do(req)

	defer res.Body.Close()
	body, _ := io.ReadAll(res.Body)

	fmt.Println(res)
	fmt.Println(string(body))

}
```

```ruby JSON String
require 'uri'
require 'net/http'

url = URI("https://analytics.babelstreet.com/rest/v1/relationships")

http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true

request = Net::HTTP::Post.new(url)
request["X-BabelStreetAPI-Key"] = '<apiKey>'
request["Content-Type"] = 'application/json'
request.body = "{\n  \"content\": \"FLIR Systems is headquartered in Oregon and produces thermal imaging, night vision, and infrared cameras and sensor systems.  According to the SEC’s order instituting a settled administrative proceeding, FLIR entered into a multi-million dollar contract to provide thermal binoculars to the Saudi government in November 2008.  Timms and Ramahi were the primary sales employees responsible for the contract, and also were involved in negotiations to sell FLIR’s security cameras to the same government officials.  At the time, Timms was the head of FLIR’s Middle East office in Dubai.\"\n}"

response = http.request(request)
puts response.read_body
```

```java JSON String
import com.mashape.unirest.http.HttpResponse;
import com.mashape.unirest.http.Unirest;

HttpResponse<String> response = Unirest.post("https://analytics.babelstreet.com/rest/v1/relationships")
  .header("X-BabelStreetAPI-Key", "<apiKey>")
  .header("Content-Type", "application/json")
  .body("{\n  \"content\": \"FLIR Systems is headquartered in Oregon and produces thermal imaging, night vision, and infrared cameras and sensor systems.  According to the SEC’s order instituting a settled administrative proceeding, FLIR entered into a multi-million dollar contract to provide thermal binoculars to the Saudi government in November 2008.  Timms and Ramahi were the primary sales employees responsible for the contract, and also were involved in negotiations to sell FLIR’s security cameras to the same government officials.  At the time, Timms was the head of FLIR’s Middle East office in Dubai.\"\n}")
  .asString();
```

```php JSON String
<?php
require_once('vendor/autoload.php');

$client = new \GuzzleHttp\Client();

$response = $client->request('POST', 'https://analytics.babelstreet.com/rest/v1/relationships', [
  'body' => '{
  "content": "FLIR Systems is headquartered in Oregon and produces thermal imaging, night vision, and infrared cameras and sensor systems.  According to the SEC’s order instituting a settled administrative proceeding, FLIR entered into a multi-million dollar contract to provide thermal binoculars to the Saudi government in November 2008.  Timms and Ramahi were the primary sales employees responsible for the contract, and also were involved in negotiations to sell FLIR’s security cameras to the same government officials.  At the time, Timms was the head of FLIR’s Middle East office in Dubai."
}',
  'headers' => [
    'Content-Type' => 'application/json',
    'X-BabelStreetAPI-Key' => '<apiKey>',
  ],
]);

echo $response->getBody();
```

```csharp JSON String
using RestSharp;

var client = new RestClient("https://analytics.babelstreet.com/rest/v1/relationships");
var request = new RestRequest(Method.POST);
request.AddHeader("X-BabelStreetAPI-Key", "<apiKey>");
request.AddHeader("Content-Type", "application/json");
request.AddParameter("application/json", "{\n  \"content\": \"FLIR Systems is headquartered in Oregon and produces thermal imaging, night vision, and infrared cameras and sensor systems.  According to the SEC’s order instituting a settled administrative proceeding, FLIR entered into a multi-million dollar contract to provide thermal binoculars to the Saudi government in November 2008.  Timms and Ramahi were the primary sales employees responsible for the contract, and also were involved in negotiations to sell FLIR’s security cameras to the same government officials.  At the time, Timms was the head of FLIR’s Middle East office in Dubai.\"\n}", ParameterType.RequestBody);
IRestResponse response = client.Execute(request);
```

```swift JSON String
import Foundation

let headers = [
  "X-BabelStreetAPI-Key": "<apiKey>",
  "Content-Type": "application/json"
]
let parameters = ["content": "FLIR Systems is headquartered in Oregon and produces thermal imaging, night vision, and infrared cameras and sensor systems.  According to the SEC’s order instituting a settled administrative proceeding, FLIR entered into a multi-million dollar contract to provide thermal binoculars to the Saudi government in November 2008.  Timms and Ramahi were the primary sales employees responsible for the contract, and also were involved in negotiations to sell FLIR’s security cameras to the same government officials.  At the time, Timms was the head of FLIR’s Middle East office in Dubai."] as [String : Any]

let postData = JSONSerialization.data(withJSONObject: parameters, options: [])

let request = NSMutableURLRequest(url: NSURL(string: "https://analytics.babelstreet.com/rest/v1/relationships")! as URL,
                                        cachePolicy: .useProtocolCachePolicy,
                                    timeoutInterval: 10.0)
request.httpMethod = "POST"
request.allHTTPHeaderFields = headers
request.httpBody = postData as Data

let session = URLSession.shared
let dataTask = session.dataTask(with: request as URLRequest, completionHandler: { (data, response, error) -> Void in
  if (error != nil) {
    print(error as Any)
  } else {
    let httpResponse = response as? HTTPURLResponse
    print(httpResponse)
  }
})

dataTask.resume()
```

### URI

**Request**

```json
{
  "contentUri": "https://www.sec.gov/News/PressRelease/Detail/PressRelease/1365171486708"
}
```

**Response**

```json
{
  "relationships": [
    {
      "arg1": "string",
      "arg1id": "string",
      "arg2": "string",
      "arg2id": "string",
      "confidence": 1.1,
      "predicate": "string"
    }
  ]
}
```

**SDK Code**

```python URI
import requests

url = "https://analytics.babelstreet.com/rest/v1/relationships"

payload = { "contentUri": "https://www.sec.gov/News/PressRelease/Detail/PressRelease/1365171486708" }
headers = {
    "X-BabelStreetAPI-Key": "<apiKey>",
    "Content-Type": "application/json"
}

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

print(response.json())
```

```javascript URI
const url = 'https://analytics.babelstreet.com/rest/v1/relationships';
const options = {
  method: 'POST',
  headers: {'X-BabelStreetAPI-Key': '<apiKey>', 'Content-Type': 'application/json'},
  body: '{"contentUri":"https://www.sec.gov/News/PressRelease/Detail/PressRelease/1365171486708"}'
};

try {
  const response = await fetch(url, options);
  const data = await response.json();
  console.log(data);
} catch (error) {
  console.error(error);
}
```

```go URI
package main

import (
	"fmt"
	"strings"
	"net/http"
	"io"
)

func main() {

	url := "https://analytics.babelstreet.com/rest/v1/relationships"

	payload := strings.NewReader("{\n  \"contentUri\": \"https://www.sec.gov/News/PressRelease/Detail/PressRelease/1365171486708\"\n}")

	req, _ := http.NewRequest("POST", url, payload)

	req.Header.Add("X-BabelStreetAPI-Key", "<apiKey>")
	req.Header.Add("Content-Type", "application/json")

	res, _ := http.DefaultClient.Do(req)

	defer res.Body.Close()
	body, _ := io.ReadAll(res.Body)

	fmt.Println(res)
	fmt.Println(string(body))

}
```

```ruby URI
require 'uri'
require 'net/http'

url = URI("https://analytics.babelstreet.com/rest/v1/relationships")

http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true

request = Net::HTTP::Post.new(url)
request["X-BabelStreetAPI-Key"] = '<apiKey>'
request["Content-Type"] = 'application/json'
request.body = "{\n  \"contentUri\": \"https://www.sec.gov/News/PressRelease/Detail/PressRelease/1365171486708\"\n}"

response = http.request(request)
puts response.read_body
```

```java URI
import com.mashape.unirest.http.HttpResponse;
import com.mashape.unirest.http.Unirest;

HttpResponse<String> response = Unirest.post("https://analytics.babelstreet.com/rest/v1/relationships")
  .header("X-BabelStreetAPI-Key", "<apiKey>")
  .header("Content-Type", "application/json")
  .body("{\n  \"contentUri\": \"https://www.sec.gov/News/PressRelease/Detail/PressRelease/1365171486708\"\n}")
  .asString();
```

```php URI
<?php
require_once('vendor/autoload.php');

$client = new \GuzzleHttp\Client();

$response = $client->request('POST', 'https://analytics.babelstreet.com/rest/v1/relationships', [
  'body' => '{
  "contentUri": "https://www.sec.gov/News/PressRelease/Detail/PressRelease/1365171486708"
}',
  'headers' => [
    'Content-Type' => 'application/json',
    'X-BabelStreetAPI-Key' => '<apiKey>',
  ],
]);

echo $response->getBody();
```

```csharp URI
using RestSharp;

var client = new RestClient("https://analytics.babelstreet.com/rest/v1/relationships");
var request = new RestRequest(Method.POST);
request.AddHeader("X-BabelStreetAPI-Key", "<apiKey>");
request.AddHeader("Content-Type", "application/json");
request.AddParameter("application/json", "{\n  \"contentUri\": \"https://www.sec.gov/News/PressRelease/Detail/PressRelease/1365171486708\"\n}", ParameterType.RequestBody);
IRestResponse response = client.Execute(request);
```

```swift URI
import Foundation

let headers = [
  "X-BabelStreetAPI-Key": "<apiKey>",
  "Content-Type": "application/json"
]
let parameters = ["contentUri": "https://www.sec.gov/News/PressRelease/Detail/PressRelease/1365171486708"] as [String : Any]

let postData = JSONSerialization.data(withJSONObject: parameters, options: [])

let request = NSMutableURLRequest(url: NSURL(string: "https://analytics.babelstreet.com/rest/v1/relationships")! as URL,
                                        cachePolicy: .useProtocolCachePolicy,
                                    timeoutInterval: 10.0)
request.httpMethod = "POST"
request.allHTTPHeaderFields = headers
request.httpBody = postData as Data

let session = URLSession.shared
let dataTask = session.dataTask(with: request as URLRequest, completionHandler: { (data, response, error) -> Void in
  if (error != nil) {
    print(error as Any)
  } else {
    let httpResponse = response as? HTTPURLResponse
    print(httpResponse)
  }
})

dataTask.resume()
```

### Optional - Specify Language

**Request**

```json
{
  "content": "FLIR Systems is headquartered in Oregon and produces thermal imaging, night vision, and infrared cameras and sensor systems.  According to the SEC’s order instituting a settled administrative proceeding, FLIR entered into a multi-million dollar contract to provide thermal binoculars to the Saudi government in November 2008.  Timms and Ramahi were the primary sales employees responsible for the contract, and also were involved in negotiations to sell FLIR’s security cameras to the same government officials.  At the time, Timms was the head of FLIR’s Middle East office in Dubai.",
  "language": "eng"
}
```

**Response**

```json
{
  "relationships": [
    {
      "arg1": "string",
      "arg1id": "string",
      "arg2": "string",
      "arg2id": "string",
      "confidence": 1.1,
      "predicate": "string"
    }
  ]
}
```

**SDK Code**

```python Optional - Specify Language
import requests

url = "https://analytics.babelstreet.com/rest/v1/relationships"

payload = {
    "content": "FLIR Systems is headquartered in Oregon and produces thermal imaging, night vision, and infrared cameras and sensor systems.  According to the SEC’s order instituting a settled administrative proceeding, FLIR entered into a multi-million dollar contract to provide thermal binoculars to the Saudi government in November 2008.  Timms and Ramahi were the primary sales employees responsible for the contract, and also were involved in negotiations to sell FLIR’s security cameras to the same government officials.  At the time, Timms was the head of FLIR’s Middle East office in Dubai.",
    "language": "eng"
}
headers = {
    "X-BabelStreetAPI-Key": "<apiKey>",
    "Content-Type": "application/json"
}

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

print(response.json())
```

```javascript Optional - Specify Language
const url = 'https://analytics.babelstreet.com/rest/v1/relationships';
const options = {
  method: 'POST',
  headers: {'X-BabelStreetAPI-Key': '<apiKey>', 'Content-Type': 'application/json'},
  body: '{"content":"FLIR Systems is headquartered in Oregon and produces thermal imaging, night vision, and infrared cameras and sensor systems.  According to the SEC’s order instituting a settled administrative proceeding, FLIR entered into a multi-million dollar contract to provide thermal binoculars to the Saudi government in November 2008.  Timms and Ramahi were the primary sales employees responsible for the contract, and also were involved in negotiations to sell FLIR’s security cameras to the same government officials.  At the time, Timms was the head of FLIR’s Middle East office in Dubai.","language":"eng"}'
};

try {
  const response = await fetch(url, options);
  const data = await response.json();
  console.log(data);
} catch (error) {
  console.error(error);
}
```

```go Optional - Specify Language
package main

import (
	"fmt"
	"strings"
	"net/http"
	"io"
)

func main() {

	url := "https://analytics.babelstreet.com/rest/v1/relationships"

	payload := strings.NewReader("{\n  \"content\": \"FLIR Systems is headquartered in Oregon and produces thermal imaging, night vision, and infrared cameras and sensor systems.  According to the SEC’s order instituting a settled administrative proceeding, FLIR entered into a multi-million dollar contract to provide thermal binoculars to the Saudi government in November 2008.  Timms and Ramahi were the primary sales employees responsible for the contract, and also were involved in negotiations to sell FLIR’s security cameras to the same government officials.  At the time, Timms was the head of FLIR’s Middle East office in Dubai.\",\n  \"language\": \"eng\"\n}")

	req, _ := http.NewRequest("POST", url, payload)

	req.Header.Add("X-BabelStreetAPI-Key", "<apiKey>")
	req.Header.Add("Content-Type", "application/json")

	res, _ := http.DefaultClient.Do(req)

	defer res.Body.Close()
	body, _ := io.ReadAll(res.Body)

	fmt.Println(res)
	fmt.Println(string(body))

}
```

```ruby Optional - Specify Language
require 'uri'
require 'net/http'

url = URI("https://analytics.babelstreet.com/rest/v1/relationships")

http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true

request = Net::HTTP::Post.new(url)
request["X-BabelStreetAPI-Key"] = '<apiKey>'
request["Content-Type"] = 'application/json'
request.body = "{\n  \"content\": \"FLIR Systems is headquartered in Oregon and produces thermal imaging, night vision, and infrared cameras and sensor systems.  According to the SEC’s order instituting a settled administrative proceeding, FLIR entered into a multi-million dollar contract to provide thermal binoculars to the Saudi government in November 2008.  Timms and Ramahi were the primary sales employees responsible for the contract, and also were involved in negotiations to sell FLIR’s security cameras to the same government officials.  At the time, Timms was the head of FLIR’s Middle East office in Dubai.\",\n  \"language\": \"eng\"\n}"

response = http.request(request)
puts response.read_body
```

```java Optional - Specify Language
import com.mashape.unirest.http.HttpResponse;
import com.mashape.unirest.http.Unirest;

HttpResponse<String> response = Unirest.post("https://analytics.babelstreet.com/rest/v1/relationships")
  .header("X-BabelStreetAPI-Key", "<apiKey>")
  .header("Content-Type", "application/json")
  .body("{\n  \"content\": \"FLIR Systems is headquartered in Oregon and produces thermal imaging, night vision, and infrared cameras and sensor systems.  According to the SEC’s order instituting a settled administrative proceeding, FLIR entered into a multi-million dollar contract to provide thermal binoculars to the Saudi government in November 2008.  Timms and Ramahi were the primary sales employees responsible for the contract, and also were involved in negotiations to sell FLIR’s security cameras to the same government officials.  At the time, Timms was the head of FLIR’s Middle East office in Dubai.\",\n  \"language\": \"eng\"\n}")
  .asString();
```

```php Optional - Specify Language
<?php
require_once('vendor/autoload.php');

$client = new \GuzzleHttp\Client();

$response = $client->request('POST', 'https://analytics.babelstreet.com/rest/v1/relationships', [
  'body' => '{
  "content": "FLIR Systems is headquartered in Oregon and produces thermal imaging, night vision, and infrared cameras and sensor systems.  According to the SEC’s order instituting a settled administrative proceeding, FLIR entered into a multi-million dollar contract to provide thermal binoculars to the Saudi government in November 2008.  Timms and Ramahi were the primary sales employees responsible for the contract, and also were involved in negotiations to sell FLIR’s security cameras to the same government officials.  At the time, Timms was the head of FLIR’s Middle East office in Dubai.",
  "language": "eng"
}',
  'headers' => [
    'Content-Type' => 'application/json',
    'X-BabelStreetAPI-Key' => '<apiKey>',
  ],
]);

echo $response->getBody();
```

```csharp Optional - Specify Language
using RestSharp;

var client = new RestClient("https://analytics.babelstreet.com/rest/v1/relationships");
var request = new RestRequest(Method.POST);
request.AddHeader("X-BabelStreetAPI-Key", "<apiKey>");
request.AddHeader("Content-Type", "application/json");
request.AddParameter("application/json", "{\n  \"content\": \"FLIR Systems is headquartered in Oregon and produces thermal imaging, night vision, and infrared cameras and sensor systems.  According to the SEC’s order instituting a settled administrative proceeding, FLIR entered into a multi-million dollar contract to provide thermal binoculars to the Saudi government in November 2008.  Timms and Ramahi were the primary sales employees responsible for the contract, and also were involved in negotiations to sell FLIR’s security cameras to the same government officials.  At the time, Timms was the head of FLIR’s Middle East office in Dubai.\",\n  \"language\": \"eng\"\n}", ParameterType.RequestBody);
IRestResponse response = client.Execute(request);
```

```swift Optional - Specify Language
import Foundation

let headers = [
  "X-BabelStreetAPI-Key": "<apiKey>",
  "Content-Type": "application/json"
]
let parameters = [
  "content": "FLIR Systems is headquartered in Oregon and produces thermal imaging, night vision, and infrared cameras and sensor systems.  According to the SEC’s order instituting a settled administrative proceeding, FLIR entered into a multi-million dollar contract to provide thermal binoculars to the Saudi government in November 2008.  Timms and Ramahi were the primary sales employees responsible for the contract, and also were involved in negotiations to sell FLIR’s security cameras to the same government officials.  At the time, Timms was the head of FLIR’s Middle East office in Dubai.",
  "language": "eng"
] as [String : Any]

let postData = JSONSerialization.data(withJSONObject: parameters, options: [])

let request = NSMutableURLRequest(url: NSURL(string: "https://analytics.babelstreet.com/rest/v1/relationships")! as URL,
                                        cachePolicy: .useProtocolCachePolicy,
                                    timeoutInterval: 10.0)
request.httpMethod = "POST"
request.allHTTPHeaderFields = headers
request.httpBody = postData as Data

let session = URLSession.shared
let dataTask = session.dataTask(with: request as URLRequest, completionHandler: { (data, response, error) -> Void in
  if (error != nil) {
    print(error as Any)
  } else {
    let httpResponse = response as? HTTPURLResponse
    print(httpResponse)
  }
})

dataTask.resume()
```