skills/gen3-peregrine/SKILL.md
Gen3 Peregrine: GraphQL query and metadata traversal operations.
npx skillsauth add alan-walsh/gen3-cli skills/gen3-peregrineInstall this skill globally with one command. Works with Claude Code, Cursor, and Windsurf.
3 of 9 scanners reported clean
Some scanners were skipped, did not run, or reported a non-clean status. Review each row below.
Execute Gen3 Peregrine operations: $ARGUMENTS
../gen3-shared/SKILL.md first for shared auth and environment guidance.gen3 peregrine <resource> <method> [flags]
Peregrine is Gen3's GraphQL read-only query service. It provides graph-oriented access to submitted metadata stored in PostgreSQL, schema introspection, per-project node counts, and core metadata lookup for data objects. It is the primary interface for discovering and traversing metadata in a Gen3 commons.
In a standard Gen3 deployment, Peregrine is behind the reverse proxy at /api/. The submission blueprint is mounted at /v0/submission/:
{api_endpoint}/api/v0/submission/graphql ← GraphQL query endpoint
{api_endpoint}/api/v0/submission/getschema ← Data dictionary schema
{api_endpoint}/api/datasets ← Dataset node counts
{api_endpoint}/api/datasets/projects ← Project listing
{api_endpoint}/api/{object_id} ← Core metadata lookup
{api_endpoint}/api/_status ← Health check
{api_endpoint}/api/_version ← Version info
Read queries for projects with availability_type == "Open" are publicly accessible. All other metadata queries require a Bearer token:
Authorization: Bearer <access_token>
Obtain the access token by exchanging the stored API key:
POST {api_endpoint}/user/credentials/api/access_token
{ "api_key": "<profile.api_key>" }
| CLI verb | HTTP | Path | Auth required |
|---|---|---|---|
| graphql query | POST | /api/v0/submission/graphql | Bearer (for protected projects) |
| graphql introspect | POST | /api/v0/submission/graphql | Bearer (for protected projects) |
| graphql schema | GET | /api/v0/submission/getschema | — |
POST /api/v0/submission/graphql — run a GraphQL queryRequest body (application/json):
{
"query": "{ project(first: 10) { project_id } }",
"variables": null,
"operationName": null
}
Response:
{ "data": { "project": [ { "project_id": "program-project" } ] } }
Common query examples:
# List all projects
{ project(first: 100) { project_id } }
# Count cases per project
{ project { project_id _case_count } }
# Get cases in a project with filters
{
case(project_id: "MyProgram-MyProject", first: 20) {
submitter_id
disease_type
primary_site
}
}
# Count files by data type
{ datanode(first: 0) { _count } }
Variables must be passed as a JSON-encoded string if used.
GET /api/v0/submission/getschema — get data dictionary schemaReturns the full JSON schema for the data dictionary, including all node types, fields, and relationships. Useful for building queries and understanding the data model.
graphql introspect — introspect the GraphQL schemaRuns a standard GraphQL introspection query to list all queryable types and their fields. Useful for discovering available nodes before writing queries.
| CLI verb | HTTP | Path | Auth required |
|---|---|---|---|
| datasets list | GET | /api/datasets/projects | Bearer |
| datasets counts | GET | /api/datasets | Bearer |
GET /api/datasets/projects — list all projectsReturns high-level information for all projects the user has access to.
Response fields per project: name, code, dbgap_accession_number, description, image_url.
GET /api/datasets — get node counts per projectQuery params (optional): nodes — comma-delimited list of node types to count (e.g. case,aliquot,file).
Response: { "project_A": { "case": 12, "aliquot": 45 }, "project_B": { ... } }
| CLI verb | HTTP | Path | Auth required |
|---|---|---|---|
| metadata get | GET | /api/{object_id} | Bearer |
GET /api/{object_id} — get core metadata for an objectReturns core metadata for the given object_id (GUID). The Accept header controls the response format.
Supported formats:
json (default) — standard JSON objectschema-org — Schema.org JSON-LD (application/vnd.schemaorg.ld+json)bibtex — BibTeX citation string (x-bibtex)Response fields (JSON): object_id, file_name, data_format, file_size.
| CLI verb | HTTP | Path | Auth required |
|---|---|---|---|
| system status | GET | /api/_status | — |
| system version | GET | /api/_version | — |
Use system status for health checks; 200 means Peregrine is healthy and connected to PostgreSQL.
system version returns commit, version, and dictionary (commit + version of the data dictionary).
| Code | Meaning |
|---|---|
| 200 | Success |
| 400 | Bad request / invalid GraphQL query |
| 401 | Unauthorized — token missing or expired |
| 403 | Forbidden — insufficient permissions (returned in GraphQL errors field) |
| 404 | Object not found (core metadata) |
| 500 | Internal server error |
Note: GraphQL errors are returned inside the errors field of a 200 response body, not as HTTP error codes.
~/.gen3/config; read api_endpoint, api_key.api_key → access_token via POST {api_endpoint}/user/credentials/api/access_token.graphql introspect or graphql schema.graphql query --query "{ ... }", attaching Authorization: Bearer <access_token>.errors array in the response body (HTTP status is still 200).case, sample, aliquot, submitted_unaligned_reads).first: N to paginate; add offset: N or filter by project_id to narrow results._case_count, _file_count, and _<node>_count virtual fields are available on project nodes for quick counts.graphql schema returns the full data dictionary; graphql introspect returns the live GraphQL type system.metadata get) uses the same GUID as Indexd but returns a richer citation-ready payload.tools
Gen3 Workspace Token Service: Workspace credential and access-token operations.
data-ai
Gen3 Sheepdog: Data submission and dictionary operations.
tools
Gen3 shared guidance for auth, environment, and cross-service execution.
tools
Gen3 Requestor: Access request and approval workflow operations.