# Connectivity Search

Find compounds and its sources by its InChI connectivity layers, i.e., formula, connections, H atoms and charge layers of the InChI.  Similar to the compound search, compounds to compare connectivity with can be looked up using InChI, InChI Key, a source compound ID or a Unique Compound ID (UCI)

{% code title="Query payload example" %}

```json
{
    "type": "inchi",
    "compound": "InChI=1S/C7H8N4O2.C2H7NO/c1-10-5-4(8-3-9-5)6(12)11(2)7(10)13;3-1-2-4/h3H,1-2H3,(H,8,9);4H,1-3H2",
    "searchComponents": true
}
```

{% endcode %}

#### Accepted parameters

* **type:** The kind of compound representation for the molecule to search.&#x20;
* **compound:** Compound representation to search. Must be the kind specified in the **type** parameter. Ignored when **type** is *sourceID*.
* **sourceID:** Unique identifier from the source database. It will only be consider when the type of search is *sourceID.*&#x20;
* **searchComponents:** Indicates wether to use the individual components of the given mixture (if it applies) and match connectivity on the mixtures and its components (true) or to match connectivity for the whole mixture.&#x20;

#### type

Kind of compound representation for the molecule to search. A compound can be searched by a given InChI, InChI Key, source compound ID or a Unique Compound ID (UCI). Can be configure using the following strings:

* uci
* inchi
* inchikey
* sourceID

#### Compound

The machine readable representation for the compound to search, ignored when using **type** *sourceID***.**

#### **sourceID**

Unique ID on the source database when using **type** *sourceID***.**&#x20;

#### **searchComponents**

When *true* the searched compound will be treated as mixture and break apart into its components; The connectivity layers of these components will be compared with the connectivity layers of the mixtures or single components, and the connectivity layers of all the components&#x20;

![Connectivity search when using searchComponents](/files/DgSwxZcnBrjIG5JmYwoY)

### Simple usage example

{% tabs %}
{% tab title="Curl" %}

```bash
curl --request POST \
  --url https://www.ebi.ac.uk/unichem/api/v1/connectivity \
  --header 'Content-Type: application/json' \
  --data '{
	"type": "inchi",
	"compound": "InChI=1S/C7H8N4O2.C2H7NO/c1-10-5-4(8-3-9-5)6(12)11(2)7(10)13;3-1-2-4/h3H,1-2H3,(H,8,9);4H,1-3H2",
	"searchComponents": true
}'
```

{% endtab %}

{% tab title="Python" %}

```python
import requests

url = "https://www.ebi.ac.uk/unichem/api/v1/connectivity"

payload = {
    "type": "inchi",
    "compound": "InChI=1S/C7H8N4O2.C2H7NO/c1-10-5-4(8-3-9-5)6(12)11(2)7(10)13;3-1-2-4/h3H,1-2H3,(H,8,9);4H,1-3H2",
    "searchComponents": True
}
headers = {"Content-Type": "application/json"}

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

print(response.text)
```

{% endtab %}
{% endtabs %}

### Response

We have greatly simplify the response payload making easier to parse and read, as well as eliminating redundant information making it lighter.

A list of compounds will be included with the response, a compound will have information about its unique identifier inside UniChEM's database, its InChI representation, standard InChI key and a list of sources where that compound can be found.&#x20;

#### Sources

Each source record contains the Unique ID in the source database, the short and long name of the source database,  the URL to the source database website where the compound information can be found, and the unique ID of the source in UniChEM's database.


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://chembl.gitbook.io/unichem/api/connectivity-search.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
