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

# Example query 1: Find samples connected to a case

<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 1: Find samples...

If you want to filter all samples that are connected to a TCGA case with case ID '0004D251-3F70-4395-B175-C94C2F5B1B81,' you can use the following query:

[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": "Find samples connected to a case"
    }
  ]
}
[/block]

[block:code]
{
  "codes": [
    {
      "code": "{\n    \"entity\": \"samples\",\n    \"hasCase\": \"0004D251-12C3-45D6-B175-C94C2F5B1B81\"\n}",
      "language": "json",
      "name": "Request body"
    }
  ]
}
[/block]

This request returns the response below. Note that it contains two `sample` objects: one for each sample matching the query above.

[block:code]
{
  "codes": [
    {
      "code": "{\n  \"count\": 2,\n  \"_embedded\": {\n    \"samples\": [\n      {\n        \"id\": \"9259E9EE-12A3-456B-8512-509CB705029C\",\n        \"label\": \"9259E9EE-12A3-456B-8512-509CB705029C\",\n        \"_links\": {\n          \"self\": {\n            \"href\": \"cgc-datasets-api.sbgenomics.com/datasets/tcga/v0/samples/9259E9EE-12A3-456B-8512-509CB705029C\"\n          }\n        }\n      },\n      {\n        \"id\": \"9EA47C2E-78C9-456D-99F0-F9B50A4729A6\",\n        \"label\": \"9EA47C2E-78C9-456D-99F0-F9B50A4729A6\",\n        \"_links\": {\n          \"self\": {\n            \"href\": \"cgc-datasets-api.sbgenomics.com/datasets/tcga/v0/samples/9EA47C2E-78C9-456D-99F0-F9B50A4729A6\"\n          }\n        }\n      }\n    ]\n  }\n}",
      "language": "json",
      "name": "Response body"
    }
  ]
}
[/block]

For each sample returned, the response lists:

* Its `href`: this is a path that can be used to obtain full information about the sample. The response returned when issuing a `GET` request to this path is reproduced below.
* Its TCGA `id`
* Its TCGA `label`

<div align="right"><a href="#top">top</a></div>

\##Secondary request
Issuing a `GET` request to the href path will return the following data:

[block:code]
{
  "codes": [
    {
      "code": "{\n  \"_links\": {\n    \"hasCase\": {\n      \"href\": \"https://cgc-datasets-api.sbgenomics.com/datasets/tcga/v0/samples/9EA47C2E-78C9-456D-99F0-F9B50A4729A6/cases\"\n    },\n    \"hasFile\": {\n      \"href\": \"https://cgc-datasets-api.sbgenomics.com/datasets/tcga/v0/samples/9EA47C2E-78C9-456D-99F0-F9B50A4729A6/files\"\n    },\n    \"hasPortion\": {\n      \"href\": \"https://cgc-datasets-api.sbgenomics.com/datasets/tcga/v0/samples/9EA47C2E-78C9-456D-99F0-F9B50A4729A6/portions\"\n    },\n    \"self\": {\n      \"href\": \"https://cgc-datasets-api.sbgenomics.com/datasets/tcga/v0/samples/9EA47C2E-78C9-456D-99F0-F9B50A4729A6\"\n    }\n  },\n  \"hasTissueSourceSite\": \"Mayo Clinic - Rochester\",\n  \"hasID\": \"TCGA-DD-AAVP-10A\",\n  \"hasDaysToCollection\": 2467,\n  \"hasOctEmbedded\": \"false\",\n  \"id\": \"9EA47C2E-78C9-456D-99F0-F9B50A4729A6\",\n  \"hasSampleType\": \"Blood Derived Normal\",\n  \"label\": \"9EA47C2E-78C9-456D-99F0-F9B50A4729A6\",\n  \"hasIsFFPE\": \"NO\",\n  \"hasCountryOfSampleProcurement\": \"Korea South\",\n  \"hasTissueSourceSiteCode\": \"DD\",\n  \"hasSampleTypeCode\": \"10\"\n}",
      "language": "json"
    }
  ]
}
[/block]