Programmatically query public single-cell study metadata from the Broad Institute Single Cell Portal REST API when you need to search and filter datasets by organism, tissue, disease, or cell type without an API key.
65
79%
Does it follow best practices?
Run evals on this skill
Adds up to 20 points to the overall score
View guide
Low
Low-risk findings worth noting
Fix and improve this skill with Tessl
tessl review fix ./scientific-skills/Data Analysis/singlecell-portal/SKILL.md/single_cell/api/v1/*)requests)requests==2.31.0import requests
BASE_URL = "https://singlecell.broadinstitute.org/single_cell/api/v1"
def scp_get(path: str, params=None, verify_ssl: bool = True, timeout: int = 30):
"""
Minimal helper for Single Cell Portal API calls.
Security note:
- Only call official endpoints under:
https://singlecell.broadinstitute.org/single_cell/api/v1/*
- If you encounter Windows certificate issues, set verify_ssl=False.
"""
url = f"{BASE_URL}{path}"
resp = requests.get(url, params=params or {}, timeout=timeout, verify=verify_ssl)
resp.raise_for_status()
return resp.json()
def search_studies(facets: str, size: int = 5):
return scp_get("/search", params={"facets": facets, "size": size})
def get_facets():
return scp_get("/search/facets")
def get_study(accession: str):
return scp_get(f"/studies/{accession}")
if __name__ == "__main__":
# 1) Search: human lung studies
results = search_studies("organism:human,tissue:lung", size=5)
studies = results.get("studies", [])
print("Top matches:")
for s in studies:
print(f"- {s.get('name')} | accession={s.get('accession')} | cells={s.get('cell_count')}")
# 2) Inspect available facet values (useful to build valid filters)
facet_info = get_facets()
print("\nFacet keys available:", ", ".join(sorted(facet_info.keys())))
# 3) Fetch details for the first returned study (if any)
if studies and studies[0].get("accession"):
acc = studies[0]["accession"]
detail = get_study(acc)
print(f"\nStudy detail for {acc}:")
print("Name:", detail.get("name"))
print("Description:", detail.get("description"))https://singlecell.broadinstitute.org/single_cell/api/v1/*GET /search: returns study search results (metadata)GET /search/facets: returns available facet keys/values for filteringGET /studies/{accession}: returns details for a specific studyfacets parameter):
key:value pairs, e.g. organism:human,tissue:lungorganism, tissue, disease, cell_typeT cell); pass them as-is in the string.size controls the number of returned studies (default behavior depends on the API; set explicitly for deterministic results).verify=False in requests.get(...).verify=True when possible; disabling verification reduces transport security.response.raise_for_status() to surface HTTP errors.dict.get) because response shapes may evolve.f5ef65b
If you maintain this skill, you can claim it as your own. Once claimed, you can manage eval scenarios, bundle related skills, attach documentation or rules, and ensure cross-agent compatibility.