Query content with GROQ
Content from Sanity is typically fetched as JSON from your hosted dataset using the GROQ query language.
Write your first GROQ query
Open Vision in your studio's navigation bar and paste this query into the Query pane.
*represents all documents in a dataset as an array.[_type == "post"]represents a filter to only return matching documents.{ _id, title, slug, publishedAt }represents a projection which defines the attributes from those documents that you want to include in the response.[0...10]represents a slice that limits the response to the first 10 documents.
*[_type == "post"]{
_id,
title,
slug,
publishedAt
}[0...10][
{
"_id": "6a3f9c21-8d4e-4b7a-9f10-2c5d8e1b4a73",
"title": "My first post",
"slug": {
"_type": "slug",
"current": "my-first-post"
},
"publishedAt": "2026-02-11T09:30:00.000Z"
}
]Run the query in Vision
Click Fetch to see the JSON output in Result. Vision returns the post document you published.
Vision queries the raw perspective by default, so results include draft documents. A draft's _id begins with the drafts. prefix. Unauthenticated requests, including most front-end queries, never return drafts.
For more query syntax, see GROQ introduction.
Was this page helpful?
Feedback submitted, thanks for helping us improve the docs. Have you tried these alternatives?