---
updatedAt: 2026-11-19T09:21:10.000Z
agentTools:
  projectIndex: https://docs.cancergenomicscloud.org/llms.txt
---

# Example query 6: Find TCGA cases with or without a prior diagnosis and related samples from a particular tissue source site and return the sample type code for each of these samples

<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 6: Find TCGA cases...

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]

# OpenAPI definition

```json
{
  "openapi": "3.1.0",
  "info": {
    "title": "api-settings",
    "version": "1.0"
  },
  "servers": [
    {
      "url": "https://cgc-api.sbgenomics.com/v2"
    }
  ],
  "security": [
    {}
  ],
  "paths": {
    "/datasets/tcga/v0/query": {
      "post": {
        "summary": "Example query 6: Find TCGA cases with or without a prior diagnosis and related samples from a particular tissue source site and return the sample type code for each of these samples",
        "description": "<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 6: Find TCGA cases...",
        "operationId": "example-query-6-find-tcga-cases-with-or-without-a-prior-diagnosis-and-related-samples-from-a-particular-tissue-source-site-and-return-the-sample-type-code-for-each-of-these-samples",
        "responses": {
          "200": {
            "description": "200",
            "content": {
              "application/json": {
                "examples": {
                  "Result": {
                    "value": "{}"
                  }
                },
                "schema": {
                  "type": "object",
                  "properties": {}
                }
              }
            }
          },
          "400": {
            "description": "400",
            "content": {
              "application/json": {
                "examples": {
                  "Result": {
                    "value": "{}"
                  }
                },
                "schema": {
                  "type": "object",
                  "properties": {}
                }
              }
            }
          }
        }
      }
    }
  },
  "x-readme": {
    "headers": [],
    "explorer-enabled": false,
    "proxy-enabled": false
  },
  "x-readme-fauxas": true
}
```