--- title: blog - GraphQL Admin description: Returns a `Blog` resource by ID. api_version: 2025-01 api_name: admin type: query api_type: graphql source_url: html: https://shopify.dev/docs/api/admin-graphql/2025-01/queries/Blog md: https://shopify.dev/docs/api/admin-graphql/2025-01/queries/Blog.md --- # blog query Returns a `Blog` resource by ID. ## Arguments * id [ID!](https://shopify.dev/docs/api/admin-graphql/2025-01/scalars/ID) required The ID of the `Blog` to return. *** ## Possible returns * Blog [Blog](https://shopify.dev/docs/api/admin-graphql/2025-01/objects/Blog) A blog for publishing articles in the online store. Stores can have multiple blogs to organize content by topic or purpose. Each blog contains articles with their associated comments, tags, and metadata. The comment policy controls whether readers can post comments and whether moderation is required. Blogs use customizable URL handles and can apply alternate templates for specialized layouts. *** ## Examples * ### Receive a single Blog #### Query ```graphql query BlogShow($id: ID!) { blog(id: $id) { id title handle } } ``` #### Variables ```json { "id": "gid://shopify/Blog/397675442" } ``` #### cURL ```bash curl -X POST \ https://your-development-store.myshopify.com/admin/api/2025-01/graphql.json \ -H 'Content-Type: application/json' \ -H 'X-Shopify-Access-Token: {access_token}' \ -d '{ "query": "query BlogShow($id: ID!) { blog(id: $id) { id title handle } }", "variables": { "id": "gid://shopify/Blog/397675442" } }' ``` #### React Router ```javascript import { authenticate } from "../shopify.server"; export const loader = async ({request}) => { const { admin } = await authenticate.admin(request); const response = await admin.graphql( `#graphql query BlogShow($id: ID!) { blog(id: $id) { id title handle } }`, { variables: { "id": "gid://shopify/Blog/397675442" }, }, ); const json = await response.json(); return json.data; } ``` #### Ruby ```ruby session = ShopifyAPI::Auth::Session.new( shop: "your-development-store.myshopify.com", access_token: access_token ) client = ShopifyAPI::Clients::Graphql::Admin.new( session: session ) query = <<~QUERY query BlogShow($id: ID!) { blog(id: $id) { id title handle } } QUERY variables = { "id": "gid://shopify/Blog/397675442" } response = client.query(query: query, variables: variables) ``` #### Node.js ```javascript const client = new shopify.clients.Graphql({session}); const data = await client.query({ data: { "query": `query BlogShow($id: ID!) { blog(id: $id) { id title handle } }`, "variables": { "id": "gid://shopify/Blog/397675442" }, }, }); ``` #### Response ```json { "blog": { "id": "gid://shopify/Blog/397675442", "title": "Yo Blog", "handle": "smallcheese-blog" } } ``` * ### Retrieves a count of all articles from a blog #### Query ```graphql query BlogArticleCount($id: ID!) { blog(id: $id) { articlesCount { count precision } } } ``` #### Variables ```json { "id": "gid://shopify/Blog/397675442" } ``` #### cURL ```bash curl -X POST \ https://your-development-store.myshopify.com/admin/api/2025-01/graphql.json \ -H 'Content-Type: application/json' \ -H 'X-Shopify-Access-Token: {access_token}' \ -d '{ "query": "query BlogArticleCount($id: ID!) { blog(id: $id) { articlesCount { count precision } } }", "variables": { "id": "gid://shopify/Blog/397675442" } }' ``` #### React Router ```javascript import { authenticate } from "../shopify.server"; export const loader = async ({request}) => { const { admin } = await authenticate.admin(request); const response = await admin.graphql( `#graphql query BlogArticleCount($id: ID!) { blog(id: $id) { articlesCount { count precision } } }`, { variables: { "id": "gid://shopify/Blog/397675442" }, }, ); const json = await response.json(); return json.data; } ``` #### Ruby ```ruby session = ShopifyAPI::Auth::Session.new( shop: "your-development-store.myshopify.com", access_token: access_token ) client = ShopifyAPI::Clients::Graphql::Admin.new( session: session ) query = <<~QUERY query BlogArticleCount($id: ID!) { blog(id: $id) { articlesCount { count precision } } } QUERY variables = { "id": "gid://shopify/Blog/397675442" } response = client.query(query: query, variables: variables) ``` #### Node.js ```javascript const client = new shopify.clients.Graphql({session}); const data = await client.query({ data: { "query": `query BlogArticleCount($id: ID!) { blog(id: $id) { articlesCount { count precision } } }`, "variables": { "id": "gid://shopify/Blog/397675442" }, }, }); ``` #### Response ```json { "blog": { "articlesCount": { "count": 1, "precision": "EXACT" } } } ``` * ### Retrieves a list of all articles from a blog #### Query ```graphql query BlogArticleList($id: ID!) { blog(id: $id) { id articles(first: 10) { nodes { id handle author { firstName lastName } body } } } } ``` #### Variables ```json { "id": "gid://shopify/Blog/397675442" } ``` #### cURL ```bash curl -X POST \ https://your-development-store.myshopify.com/admin/api/2025-01/graphql.json \ -H 'Content-Type: application/json' \ -H 'X-Shopify-Access-Token: {access_token}' \ -d '{ "query": "query BlogArticleList($id: ID!) { blog(id: $id) { id articles(first: 10) { nodes { id handle author { firstName lastName } body } } } }", "variables": { "id": "gid://shopify/Blog/397675442" } }' ``` #### React Router ```javascript import { authenticate } from "../shopify.server"; export const loader = async ({request}) => { const { admin } = await authenticate.admin(request); const response = await admin.graphql( `#graphql query BlogArticleList($id: ID!) { blog(id: $id) { id articles(first: 10) { nodes { id handle author { firstName lastName } body } } } }`, { variables: { "id": "gid://shopify/Blog/397675442" }, }, ); const json = await response.json(); return json.data; } ``` #### Ruby ```ruby session = ShopifyAPI::Auth::Session.new( shop: "your-development-store.myshopify.com", access_token: access_token ) client = ShopifyAPI::Clients::Graphql::Admin.new( session: session ) query = <<~QUERY query BlogArticleList($id: ID!) { blog(id: $id) { id articles(first: 10) { nodes { id handle author { firstName lastName } body } } } } QUERY variables = { "id": "gid://shopify/Blog/397675442" } response = client.query(query: query, variables: variables) ``` #### Node.js ```javascript const client = new shopify.clients.Graphql({session}); const data = await client.query({ data: { "query": `query BlogArticleList($id: ID!) { blog(id: $id) { id articles(first: 10) { nodes { id handle author { firstName lastName } body } } } }`, "variables": { "id": "gid://shopify/Blog/397675442" }, }, }); ``` #### Response ```json { "blog": { "id": "gid://shopify/Blog/397675442", "articles": { "nodes": [ { "id": "gid://shopify/Article/959752435", "handle": "you-should-buy-this", "author": { "firstName": "", "lastName": "" }, "body": "
Go for it, get three.
" } ] } } } ``` [Open in GraphiQL](http://localhost:3457/graphiql?query=query%20BlogShow\(%24id%3A%20ID!\)%20%7B%0A%20%20blog\(id%3A%20%24id\)%20%7B%0A%20%20%20%20id%0A%20%20%20%20title%0A%20%20%20%20handle%0A%20%20%7D%0A%7D\&variables=%7B%0A%20%20%22id%22%3A%20%22gid%3A%2F%2Fshopify%2FBlog%2F397675442%22%0A%7D) ##### GQL ```graphql query BlogShow($id: ID!) { blog(id: $id) { id title handle } } ``` ##### cURL ```bash curl -X POST \ https://your-development-store.myshopify.com/admin/api/2025-01/graphql.json \ -H 'Content-Type: application/json' \ -H 'X-Shopify-Access-Token: {access_token}' \ -d '{ "query": "query BlogShow($id: ID!) { blog(id: $id) { id title handle } }", "variables": { "id": "gid://shopify/Blog/397675442" } }' ``` ##### React Router ```javascript import { authenticate } from "../shopify.server"; export const loader = async ({request}) => { const { admin } = await authenticate.admin(request); const response = await admin.graphql( `#graphql query BlogShow($id: ID!) { blog(id: $id) { id title handle } }`, { variables: { "id": "gid://shopify/Blog/397675442" }, }, ); const json = await response.json(); return json.data; } ``` ##### Node.js ```javascript const client = new shopify.clients.Graphql({session}); const data = await client.query({ data: { "query": `query BlogShow($id: ID!) { blog(id: $id) { id title handle } }`, "variables": { "id": "gid://shopify/Blog/397675442" }, }, }); ``` ##### Ruby ```ruby session = ShopifyAPI::Auth::Session.new( shop: "your-development-store.myshopify.com", access_token: access_token ) client = ShopifyAPI::Clients::Graphql::Admin.new( session: session ) query = <<~QUERY query BlogShow($id: ID!) { blog(id: $id) { id title handle } } QUERY variables = { "id": "gid://shopify/Blog/397675442" } response = client.query(query: query, variables: variables) ``` ## Input variables JSON ```json { "id": "gid://shopify/Blog/397675442" } ``` ## Response JSON ```json { "blog": { "id": "gid://shopify/Blog/397675442", "title": "Yo Blog", "handle": "smallcheese-blog" } } ```