Query content collections

In Sitecore Content Hub, you can group content items into collections, and then publish those collections to your channels using Experience Edge. When the content collection is in the final state of the lifecycle workflow, it is automatically published. You can then query the content collections using the APIs.

After authenticating with a valid key, you can fetch details about the content collections by sending a request to the Delivery API at the following endpoint:

RequestResponse
https://edge.sitecorecloud.io/api/graphql/v1
Important

If you generate an API key from a content collection details page, the key is scoped to that content collection. This means that GraphQL queries executed using that API key must start from the content collection itself. You cannot query content directly.

Get the names and IDs of content collections you can access

This sample query returns the names and IDs of every content collection you are permitted to access.

RequestResponse
{
 allM_ContentCollection {
  results {
   contentCollectionName
   id
  }
 }
}
Note

If the API key is scoped to a collection, this query will only return the name and ID of that collection.

Get a content collection using its ID

This sample query returns details about a content collection with a specific ID, including who created the collection, when it was created, and its description.

RequestResponse
{
 m_ContentCollection (id: "ContentCollectionId") { 
  createdBy
  createdOn
  contentCollectionDescription
 }
}
Note

If the API key is scoped to a collection, the specified id must match the ID of that collection; otherwise, no details are returned.

Get content included in a content collection

This sample query returns several details about every content collection you are permitted to access. It also uses the contentCollectionToContent relation to include the names of the content in those collections.

RequestResponse
{
 allM_ContentCollection {
  results {
  contentCollectionName
  contentCollectionToContent {
   results {
    content_Name
   }
  }
  createdBy
  createdOn
  contentCollectionDescription
 }
 }
}

Get content of a specific content type included in a content collection

This sample query returns the name of every content collection you are permitted to access. It also returns several details about any content in those collections that has the M_Content_Advertisement type. Using the contentCollectionToContent relation, this query links M_ContentCollection to M_Content. An inline fragment is used to treat M_Content as M_Content_Advertisement, which enables it to interface with CMP and fetch data that is specific to advertisement content.

RequestResponse
{
 allM_ContentCollection {
  results {
   contentCollectionName
   contentCollectionToContent {
    results {
     ... on M_Content_Advertisement {
      id
      advertisement_Title
      createdBy
     }
    }
   }
  }
 }
}

Do you have some feedback for us?

If you have suggestions for improving this article,