CHEESE on-prem API and Python
How to call the CHEESE API on an on-prem installation — what each request does, what to send, and what comes back.
Use the HTTPS origin of your own V2 installation for both the browser and the API. In Bash, set it once, using your site's real hostname without a trailing slash.
export SITE_URL='https://cheese.example.org'Your ingress may require SSO or a site-issued credential. Ask your administrator for the approved API client configuration. The examples below use curl. If authentication is required, use the protected curl configuration file provided by your administrator with each call (for example, curl --config /private/path/site.curl …). Keep credentials on your workstation. The on-prem search service has no cloud credit balance.
1. Discover what is available
GET /api/v2/catalog
curl --fail --show-error --silent "$SITE_URL/api/v2/catalog" | python3 -m json.toolEach entry in libraries gives a database_id, release_id and available capabilities. Select an installed library that supports the operation you want. Set its ID once for the examples below. The search examples use jq to encode JSON.
read -r -p 'Installed database ID: ' DATABASE_ID
export DATABASE_IDConnect Python to your site
Install the deepmedchem client on the workstation or notebook server that can reach the same CHEESE HTTPS origin. Use the on-prem SDK wheel supplied with your delivery. For a disconnected site, install it with the accompanying wheelhouse, checksum manifest and locked requirements. The kit README identifies the matching Python and platform. The client sends your requests to the running CHEESE API.
For the Linux x86-64, CPython 3.11 wheelhouse, run the following in the directory containing the verified release's sdk/ folder. This creates a virtual environment on the workstation and installs only the locked wheels from the media.
WHEELS="$PWD/sdk/wheelhouse"
(cd "$WHEELS" && sha256sum --check --strict --quiet SHA256SUMS) &&
python3.11 -m venv cheese-sdk &&
source cheese-sdk/bin/activate &&
python -m pip install --no-index --require-hashes --find-links "$WHEELS" -r "$WHEELS/requirements.lock"With the environment variables above and your site's approved SDK authentication configured, repeat a Morgan search against an installed library:
import os
from deepmedchem import Client
with Client(on_prem=True, api_url=os.environ["SITE_URL"]) as cheese:
libraries = cheese.catalog()["libraries"]
print([(entry["database_id"], entry["release_id"]) for entry in libraries])
hits = cheese.search("CCO", database=os.environ["DATABASE_ID"], limit=3)
print(hits)On an SDK installation with the supplied CHEESE (on-prem) Jupyter kernel, the kernel configuration supplies the site origin. Use the site-specific example shipped with that kernel.
GET /api/v2/usage: Usage
What it does: shows the plan and the credit balance. On an on-prem installation it reports unlimited use.
Example:
curl --fail --show-error --silent "$SITE_URL/api/v2/usage"GET /health/live and GET /health/ready: Health checks
These backend probes are usually called inside the cluster. Your ingress determines whether they are exposed at the site URL. To verify the customer-facing site, check that the catalogue returns JSON with the expected libraries, then complete a search. Some ingress configurations serve the browser app with HTTP 200 on an unrecognised path.
GET /health/liveconfirms that the backend process is running.GET /health/readyconfirms that the backend has loaded its chemical spaces and can accept search requests.
2. Search
For a first cross-check, choose the same library and Morgan method in the browser, enter the SMILES CCO, and repeat the query with the similarity request below. Check that the response names the expected database and release and contains a ranked structure. For site acceptance use the query and expected result in your handoff.
POST /api/v2/search: Find ECFP4/Tanimoto neighbors
What it does: finds molecules similar to your query by ECFP4 fingerprint (Morgan), the search page's "morgan" method.
Request:
| Field | Meaning |
|---|---|
query_smiles* | The query molecule. |
database_id* | Where to search, from the catalogue. |
limit | How many hits to return. |
structure_query, property_constraints | Optional filters. |
include_synthons, include_properties, include_predicted_properties | Optional extra data. |
Example:
jq -n --arg db "$DATABASE_ID" '{"query_smiles":"CCO","database_id":$db,"limit":3}' | \
curl --fail --show-error --silent "$SITE_URL/api/v2/search" \
-H 'Content-Type: application/json' --data-binary @-What you get: results, each with rank, smiles, score (1 for the
query itself), metric, catalog_id and product_id. The response also says
which database_release and engine_version were used.
POST /api/v2/search_cheese: Shape or electrostatic reranking
What it does: reranks candidates by CHEESE shape or electrostatic similarity. It's the search page's "shape" and "electrostatic" methods.
Request: the same fields as /search, plus scorer* (shape or esp).
Example:
jq -n --arg db "$DATABASE_ID" '{"query_smiles":"CCO","database_id":$db,"limit":3,"scorer":"shape"}' | \
curl --fail --show-error --silent "$SITE_URL/api/v2/search_cheese" \
-H 'Content-Type: application/json' --data-binary @-POST /api/v2/search_substructure: Substructure search
What it does: finds molecules that contain a given substructure. It's the search page's substructure filter.
Request:
query: an object withformat(smiles) andvalue(the substructure).database_id*,limit, and optionalproperty_constraints,price,timeout_seconds,exclude_smiles.
Example:
jq -n --arg db "$DATABASE_ID" '{"query":{"format":"smiles","value":"c1ccccc1C(=O)N"},"database_id":$db,"limit":3}' | \
curl --fail --show-error --silent "$SITE_URL/api/v2/search_substructure" \
-H 'Content-Type: application/json' --data-binary @-What you get: results with smiles, plus matches showing which atoms
matched, metric ("exact catalogue substructure") and engine_version.
Note
A request without query.format fails with invalid_schema / "Field
required". That's the error to look for if a substructure search is refused.
POST /api/v2/substructure: Legacy substructure search
An older form of the substructure search: query_smiles* and database_id*,
with limit, include_synthons, timeout_seconds. The search page doesn't use
it; prefer /search_substructure.
POST /api/v2/sample: Sample molecules from one library
What it does: returns random molecules from one library. It's the search page's random-query button.
Request: database_id*, count (how many), optional seed (same seed,
same sample).
Example:
jq -n --arg db "$DATABASE_ID" '{"database_id":$db,"count":2}' | \
curl --fail --show-error --silent "$SITE_URL/api/v2/sample" \
-H 'Content-Type: application/json' --data-binary @-What you get: results, each with index, smiles and product_id, plus
the seed used, so the sample can be repeated.
POST /api/v2/structure_queries:validate: Check a structure query
Checks a reusable structure query before you use it in a search. The request
needs expression*, and may include schema_version and stereo. Useful for
testing a query definition on its own.
3. Multi-database and selection workflows
Availability depends on the installed API and catalogue capabilities. Consult your site's /api/v2/openapi.json before using these operations.
| Operation | What it does |
|---|---|
POST /api/v2/search_auto:plan | Shows which libraries an automatic search would use, before running it. |
POST /api/v2/search_auto | Searches every eligible library and merges the unique molecules. Partial results include the status of each source. |
POST /api/v2/search_auto:stream | The same search, streamed: each library's results arrive as it finishes. |
POST /api/v2/selections:validate | Checks a selection document (database, strategy, optional references, constraints, objectives). |
POST /api/v2/selections:estimate | Estimates the work a selection would take, before creating it. |
POST /api/v2/selections | Creates a selection (the same document as above). |
Their request fields include selection, substructure, scope,
availability, databases, timeout_seconds, include_catalogues and
max_synthesis_days (for the search_auto family) and the selection document
fields listed above. The full structure of these documents is in the schema.
4. Where to look next
On your installation:
- Full schema:
/api/v2/openapi.json - Installed libraries with their capabilities:
/api/v2/catalog - Backend's own documentation page:
/api/v2/docs
In these docs: