# 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](https://1911127213-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-LswQ6nYY3FF-U9wayJ5%2Fuploads%2FVsNA1duYkImawFsALPsh%2FConnectivity%20Search.drawio.png?alt=media\&token=b238eac3-ecf7-49eb-86fc-37f864c839d8)

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