---
agentTools:
  projectIndex: https://docs.cancergenomicscloud.org/llms.txt
---

# Example query 3: Find cases with given age at diagnosis

<a href="query-datasets" style="color:#132c56">QUERY DATASETS</a> > <a href="about-the-datasets-api" style="color:#132c56">About the Datasets API</a> > <a href="query-via-the-datasets-api" style="color:#132c56">Query via the Datasets API</a> > Example query 3: find cases with...

Use the following query to see all cases for which the age at diagnosis is between 10 and 50.

[block:code]
{
  "codes": [
    {
      "code": "POST /datasets/tcga/v0/query HTTP/1.1\nHost: cgc-datasets-api.sbgenomics.com\nX-SBG-Auth-Token: 3210a98c1db9304ea9d9273156740f74",
      "language": "http",
      "name": "Request"
    }
  ]
}
[/block]

[block:code]
{
  "codes": [
    {
      "code": "{\n   \"entity\":\"cases\",\n   \"hasAgeAtDiagnosis\": {\n       \"filter\": {\n           \"gt\": 10,\n           \"lt\": 50\n       }\n   }\n}",
      "language": "json",
      "name": "Request body"
    }
  ]
}
[/block]

Note that the value of the metadata field `hasAgeAtDiagnosis` is a dictionary containing the key `filter`, whose value is a further dictionary with keys `gt` (greater than) and `lt` (less than) for the upper and lower bounds to filter by.

[block:callout]
{
  "type": "success",
  "body": "You can use either integers or strings (like `\"10\"`) as the upper and lower bounds in `filter`, in the query above."
}
[/block]

\##Response body
The response shows the matching cases.

[block:code]
{
  "codes": [
    {
      "code": "{\n  \"count\": 100,\n  \"_embedded\": {\n    \"cases\": [\n      {\n        \"_links\": {\n          \"self\": {\n            \"href\": \"https://cgc-datasets-api.sbgenomics.com/datasets/tcga/v0/cases/029CE789-123A-45B6-8596-CD94300E7EF5\"\n          }\n        },\n        \"id\": \"029CE789-123A-45B6-8596-CD94300E7EF5\",\n        \"label\": \"029CE789-123A-45B6-8596-CD94300E7EF5\"\n      },\n      {\n        \"_links\": {\n          \"self\": {\n            \"href\": \"https://cgc-datasets-api.sbgenomics.com/datasets/tcga/v0/cases/02B5012E-45B6-4423-7890-0B2F5E50926E\"\n          }\n        },\n        \"id\": \"02B5012E-45B6-4423-7890-0B2F5E50926E\",\n        \"label\": \"02B5012E-45B6-4423-7890-0B2F5E50926E\"\n      },\n  \n        <snip>\n  \n    ]\n  }\n}",
      "language": "json"
    }
  ]
}
[/block]

[block:callout]
{
  "type": "success",
  "body": "For brevity, we have omitted part some of the returned cases."
}
[/block]

For each case matching the query, the following information is listed:

* Its `href`: this is a path that can be used to obtain full information about the sample. To see all information, issue a `GET` request to this path. See [Example query 1: Find samples connected to a case](https://docs.cancergenomicscloud.org/docs/example-query-1-find-samples-connected-to-a-case) for details.
* Its TCGA `id`
* Its TCGA `label`