Programmatic access to FAIR-TPs compound and transformation data.
Search compounds, read full compound records, follow the transformations recorded for a compound, find the shortest pathway between two compounds and run SMARTS substructure searches. Every endpoint is a plain GET request that returns JSON or XML.
Returns the full record for one compound, including synonyms, SMILES, InChI, exact and monoisotopic mass, molecular weight and XLogP.
Parameters
inchikeyRequired
A standard InChIKey. Letter case does not matter. A malformed key returns 422 and an unknown key returns 404.Example MXWJVTOOROXGIU-UHFFFAOYSA-NPart of the path
Lists the recorded transformation reactions that involve a compound. Each entry names the substrate and the product in the direction of the reaction, with biosystems, enzymes, the dataset reference and the change in mass and XLogP.
mass_diff and xlogp_diff are product minus substrate. A value of 0 is a measured result, while null means no value is available.
Parameters
inchikeyRequired
InChIKey of the compound.Example MXWJVTOOROXGIU-UHFFFAOYSA-NPart of the path
directionOptional
outgoing lists reactions where the compound is the substrate, incoming lists reactions where it is the product, and both lists all of them.Default bothExample outgoing
datasetOptional
Keeps reactions from one dataset. The value must match a dataset_reference exactly.
biosystemOptional
Keeps reactions recorded for one biosystem. Matching ignores letter case.Example Human
enzymeOptional
Keeps reactions recorded for one enzyme. Matching ignores letter case.Example CYP3A4
pageOptional
Page number, starting at 1.Default 1Example 2
page_sizeOptional
Results per page, from 1 to 100.Default 20Example 50
Finds the shortest chain of transformation reactions from one compound to another. Both compounds are identified by InChIKey.
When no forward chain exists, the reverse direction is searched and traversal says which one answered. If nothing connects the two compounds, the response is still 200 with found set to false. Up to 25 equally short pathways are returned.
Parameters
sourceRequired
InChIKey of the starting compound.Example MXWJVTOOROXGIU-UHFFFAOYSA-N
targetRequired
InChIKey of the compound to reach. It must differ from source.Example DFWFIQKMSFGDCQ-UHFFFAOYSA-N
max_depthOptional
Longest pathway to search for, counted in reactions, from 1 to 20. A smaller value makes the search faster.Default 20Example 3
Finds compounds whose structure contains a SMARTS pattern. Matching uses RDKit, and every candidate is checked before results are paged, so count is complete.
A valid pattern that matches nothing returns 200 with a count of 0. A pattern RDKit cannot parse returns 422. URL encode the pattern when you build the request.
Parameters
smartsRequired
One SMARTS pattern, up to 512 characters.Example c1ncncn1
datasetOptional
Limits the search to compounds from one dataset reference, matched exactly.
biosystemOptional
Limits the search to compounds recorded for one biosystem. Matching ignores letter case.
pageOptional
Page number, starting at 1.Default 1Example 2
page_sizeOptional
Results per page, from 1 to 100.Default 20Example 50
Searches with several SMARTS patterns at once and returns compounds that match any of them, ranked by how many of the patterns each compound matches.
Repeat the smarts parameter once per pattern. If any pattern is invalid, the whole request returns 422, so a partial result is never mistaken for a complete one.
Parameters
smartsRequired
A SMARTS pattern. Repeat the parameter for each pattern, up to 12 in one request.Example c1ncncn1Can be repeated
datasetOptional
Limits the search to compounds from one dataset reference, matched exactly.
biosystemOptional
Limits the search to compounds recorded for one biosystem. Matching ignores letter case.
pageOptional
Page number, starting at 1.Default 1Example 2
page_sizeOptional
Results per page, from 1 to 100.Default 20Example 50
Errors are returned as problem documents (RFC 9457) in the format you asked for. Branch on the code field, which stays stable, rather than on the readable title or detail.
404
The compound or the path does not exist.
not_found
406
The Accept header asks for a format the API does not provide. Use JSON or XML.
not_acceptable
414
The request URL is too long, usually because of long SMARTS patterns. Send fewer or shorter patterns.
uri_too_long
422
The request was understood, but a parameter is missing or invalid. For most validation errors the errors list names the parameter.
validation_errortoo_many_patterns
429
Too many requests arrived in a short period. Wait and retry later.
rate_limited
503
The service cannot complete the request right now. If a search ran out of time, narrow it instead of repeating it unchanged.
{
"type": "/api/v1/problems/validation_error",
"title": "Validation error",
"status": 422,
"detail": "One or more request parameters were invalid.",
"code": "validation_error",
"instance": "/api/v1/compounds",
"errors": [
{
"field": "query.page_size",
"code": "less_than_equal",
"message": "Input should be less than or equal to 100"
}
]
}
Examples
Three short tasks that cover most first integrations.
Look up a compound by name
1
Search for atrazine and note the inchikey of the result you want.
// Node.js 18 or later, run as an ES module
const BASE_URL = "https://fairtps.lcsb.uni.lu/api/v1";
const search = await fetch(`${BASE_URL}/compounds?q=atrazine&page_size=5`);
if (!search.ok) throw new Error(`Search failed with status ${search.status}`);
const { data } = await search.json();
if (data.length > 0) {
const detail = await fetch(`${BASE_URL}/compounds/${data[0].inchikey}`);
const compound = await detail.json();
console.log(compound.name, compound.molecular_formula);
}
Version and fair use
API version
v1
The version is part of every route, so fields in v1 keep their names and meaning. New fields may be added, and a breaking change would be released as v2.
Responsible use
The API applies request and resource controls so the service stays available for everyone. Substructure, batch and pathway searches do the most work, so avoid repeating identical requests and cache results that rarely change.
Successful responses carry an ETag. Send it back in an If-None-Match header and the API answers 304 Not Modified without a body when nothing has changed. After a 429, wait before retrying and honour Retry-After when it is present.