--- title: blog - GraphQL Admin description: Returns a `Blog` resource by ID. api_version: unstable api_name: admin source_url: html: https://shopify.dev/docs/api/admin-graphql/unstable/queries/blog md: https://shopify.dev/docs/api/admin-graphql/unstable/queries/blog.md --- # blog query Returns a `Blog` resource by ID. ## Arguments * id [ID!](https://shopify.dev/docs/api/admin-graphql/unstable/scalars/ID) required The ID of the `Blog` to return. *** ## Possible returns * Blog [Blog](https://shopify.dev/docs/api/admin-graphql/unstable/objects/Blog) Shopify stores come with a built-in blogging engine, allowing a shop to have one or more blogs. Blogs are meant to be used as a type of magazine or newsletter for the shop, with content that changes over time. *** ## 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/unstable/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/unstable/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/unstable/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) ```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; } ``` ##### GQL ``` query BlogShow($id: ID!) { blog(id: $id) { id title handle } } ``` ##### cURL ``` curl -X POST \ https://your-development-store.myshopify.com/admin/api/unstable/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 ``` 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 ``` 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 ``` 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" } } ```