--- 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) 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. * articles [Article​Connection!](https://shopify.dev/docs/api/admin-graphql/unstable/connections/ArticleConnection) non-null List of the blog's articles. * first [Int](https://shopify.dev/docs/api/admin-graphql/unstable/scalars/Int) ### Arguments The first `n` elements from the [paginated list](https://shopify.dev/api/usage/pagination-graphql). * after [String](https://shopify.dev/docs/api/admin-graphql/unstable/scalars/String) The elements that come after the specified [cursor](https://shopify.dev/api/usage/pagination-graphql). * last [Int](https://shopify.dev/docs/api/admin-graphql/unstable/scalars/Int) The last `n` elements from the [paginated list](https://shopify.dev/api/usage/pagination-graphql). * before [String](https://shopify.dev/docs/api/admin-graphql/unstable/scalars/String) The elements that come before the specified [cursor](https://shopify.dev/api/usage/pagination-graphql). * reverse [Boolean](https://shopify.dev/docs/api/admin-graphql/unstable/scalars/Boolean) Default:false Reverse the order of the underlying list. *** * articles​Count [Count](https://shopify.dev/docs/api/admin-graphql/unstable/objects/Count) Count of articles. Limited to a maximum of 10000 by default. * limit [Int](https://shopify.dev/docs/api/admin-graphql/unstable/scalars/Int) Default:10000 ### Arguments The upper bound on count value before returning a result. Use `null` to have no limit. *** * comment​Policy [Comment​Policy!](https://shopify.dev/docs/api/admin-graphql/unstable/enums/CommentPolicy) non-null Indicates whether readers can post comments to the blog and if comments are moderated or not. * created​At [Date​Time!](https://shopify.dev/docs/api/admin-graphql/unstable/scalars/DateTime) non-null The date and time when the blog was created. * events [Event​Connection!](https://shopify.dev/docs/api/admin-graphql/unstable/connections/EventConnection) non-null The paginated list of events associated with the host subject. * first [Int](https://shopify.dev/docs/api/admin-graphql/unstable/scalars/Int) ### Arguments The first `n` elements from the [paginated list](https://shopify.dev/api/usage/pagination-graphql). * after [String](https://shopify.dev/docs/api/admin-graphql/unstable/scalars/String) The elements that come after the specified [cursor](https://shopify.dev/api/usage/pagination-graphql). * last [Int](https://shopify.dev/docs/api/admin-graphql/unstable/scalars/Int) The last `n` elements from the [paginated list](https://shopify.dev/api/usage/pagination-graphql). * before [String](https://shopify.dev/docs/api/admin-graphql/unstable/scalars/String) The elements that come before the specified [cursor](https://shopify.dev/api/usage/pagination-graphql). * reverse [Boolean](https://shopify.dev/docs/api/admin-graphql/unstable/scalars/Boolean) Default:false Reverse the order of the underlying list. * sort​Key [Event​Sort​Keys](https://shopify.dev/docs/api/admin-graphql/unstable/enums/EventSortKeys) Default:ID Sort the underlying list using a key. If your query is slow or returns an error, then [try specifying a sort key that matches the field used in the search](https://shopify.dev/api/usage/pagination-graphql#search-performance-considerations). * query [String](https://shopify.dev/docs/api/admin-graphql/unstable/scalars/String) A filter made up of terms, connectives, modifiers, and comparators. You can apply one or more filters to a query. Learn more about [Shopify API search syntax](https://shopify.dev/api/usage/search-syntax). * * action string * comments boolean * created\_at time * id id * subject\_type string - The action that occured. - Example: * `action:create` Whether or not to include [comment-events](https://shopify.dev/api/admin-graphql/latest/objects/CommentEvent) in your search, passing `false` will exclude comment-events, any other value will include comment-events. - Example: * `false` * `true` Filter by the date and time when the event happened. - Example: * `created_at:>2020-10-21` * `created_at:=1234` * `id:<=1234` The resource type affected by this event. See [EventSubjectType](https://shopify.dev/api/admin-graphql/latest/enums/EventSubjectType) for possible values. Example: * `PRODUCT_VARIANT` * `PRODUCT` * `COLLECTION` *** * feed [Blog​Feed](https://shopify.dev/docs/api/admin-graphql/unstable/objects/BlogFeed) FeedBurner provider details. Any blogs that aren't already integrated with FeedBurner can't use the service. * handle [String!](https://shopify.dev/docs/api/admin-graphql/unstable/scalars/String) non-null A unique, human-friendly string for the blog. If no handle is specified, a handle will be generated automatically from the blog title. The handle is customizable and is used by the Liquid templating language to refer to the blog. * id [ID!](https://shopify.dev/docs/api/admin-graphql/unstable/scalars/ID) non-null A globally-unique ID. * metafield [Metafield](https://shopify.dev/docs/api/admin-graphql/unstable/objects/Metafield) A [custom field](https://shopify.dev/docs/apps/build/custom-data), including its `namespace` and `key`, that's associated with a Shopify resource for the purposes of adding and storing additional information. * namespace [String](https://shopify.dev/docs/api/admin-graphql/unstable/scalars/String) ### Arguments The container the metafield belongs to. If omitted, the app-reserved namespace will be used. * key [String!](https://shopify.dev/docs/api/admin-graphql/unstable/scalars/String) required The key for the metafield. *** * metafields [Metafield​Connection!](https://shopify.dev/docs/api/admin-graphql/unstable/connections/MetafieldConnection) non-null A list of [custom fields](https://shopify.dev/docs/apps/build/custom-data) that a merchant associates with a Shopify resource. * namespace [String](https://shopify.dev/docs/api/admin-graphql/unstable/scalars/String) ### Arguments The metafield namespace to filter by. If omitted, the app-reserved namespace will be used. * keys [\[String!\]](https://shopify.dev/docs/api/admin-graphql/unstable/scalars/String) List of keys of metafields in the format `namespace.key`, will be returned in the same format. * first [Int](https://shopify.dev/docs/api/admin-graphql/unstable/scalars/Int) The first `n` elements from the [paginated list](https://shopify.dev/api/usage/pagination-graphql). * after [String](https://shopify.dev/docs/api/admin-graphql/unstable/scalars/String) The elements that come after the specified [cursor](https://shopify.dev/api/usage/pagination-graphql). * last [Int](https://shopify.dev/docs/api/admin-graphql/unstable/scalars/Int) The last `n` elements from the [paginated list](https://shopify.dev/api/usage/pagination-graphql). * before [String](https://shopify.dev/docs/api/admin-graphql/unstable/scalars/String) The elements that come before the specified [cursor](https://shopify.dev/api/usage/pagination-graphql). * reverse [Boolean](https://shopify.dev/docs/api/admin-graphql/unstable/scalars/Boolean) Default:false Reverse the order of the underlying list. *** * metafields​By​Identifiers [\[Metafield\]!](https://shopify.dev/docs/api/admin-graphql/unstable/objects/Metafield) non-null The metafields associated with the resource matching the supplied list of namespaces and keys. * identifiers [\[Has​Metafields​Identifier!\]!](https://shopify.dev/docs/api/admin-graphql/unstable/input-objects/HasMetafieldsIdentifier) required ### Arguments The list of metafields to retrieve by namespace and key. *** * tags [\[String!\]!](https://shopify.dev/docs/api/admin-graphql/unstable/scalars/String) non-null A list of tags associated with the 200 most recent blog articles. * template​Suffix [String](https://shopify.dev/docs/api/admin-graphql/unstable/scalars/String) The name of the template a blog is using if it's using an alternate template. Returns `null` if a blog is using the default blog.liquid template. * title [String!](https://shopify.dev/docs/api/admin-graphql/unstable/scalars/String) non-null The title of the blog. * translations [\[Translation!\]!](https://shopify.dev/docs/api/admin-graphql/unstable/objects/Translation) non-null The published translations associated with the resource. * locale [String!](https://shopify.dev/docs/api/admin-graphql/unstable/scalars/String) required ### Arguments Filters translations locale. * market​Id [ID](https://shopify.dev/docs/api/admin-graphql/unstable/scalars/ID) Filters translations by market ID. Use this argument to retrieve content specific to a market. *** * updated​At [Date​Time](https://shopify.dev/docs/api/admin-graphql/unstable/scalars/DateTime) The date and time when the blog was update. * metafield​Definitions [Metafield​Definition​Connection!](https://shopify.dev/docs/api/admin-graphql/unstable/connections/MetafieldDefinitionConnection) non-nullDeprecated * namespace [String](https://shopify.dev/docs/api/admin-graphql/unstable/scalars/String) ### Arguments Filter metafield definitions by namespace. * pinned​Status [Metafield​Definition​Pinned​Status](https://shopify.dev/docs/api/admin-graphql/unstable/enums/MetafieldDefinitionPinnedStatus) Default:ANY Filter by the definition's pinned status. * first [Int](https://shopify.dev/docs/api/admin-graphql/unstable/scalars/Int) The first `n` elements from the [paginated list](https://shopify.dev/api/usage/pagination-graphql). * after [String](https://shopify.dev/docs/api/admin-graphql/unstable/scalars/String) The elements that come after the specified [cursor](https://shopify.dev/api/usage/pagination-graphql). * last [Int](https://shopify.dev/docs/api/admin-graphql/unstable/scalars/Int) The last `n` elements from the [paginated list](https://shopify.dev/api/usage/pagination-graphql). * before [String](https://shopify.dev/docs/api/admin-graphql/unstable/scalars/String) The elements that come before the specified [cursor](https://shopify.dev/api/usage/pagination-graphql). * reverse [Boolean](https://shopify.dev/docs/api/admin-graphql/unstable/scalars/Boolean) Default:false Reverse the order of the underlying list. * sort​Key [Metafield​Definition​Sort​Keys](https://shopify.dev/docs/api/admin-graphql/unstable/enums/MetafieldDefinitionSortKeys) Default:ID Sort the underlying list using a key. If your query is slow or returns an error, then [try specifying a sort key that matches the field used in the search](https://shopify.dev/api/usage/pagination-graphql#search-performance-considerations). * query [String](https://shopify.dev/docs/api/admin-graphql/unstable/scalars/String) A filter made up of terms, connectives, modifiers, and comparators. You can apply one or more filters to a query. Learn more about [Shopify API search syntax](https://shopify.dev/api/usage/search-syntax). * * default string * created\_at time * id id * key string * namespace string * owner\_type string * type string * updated\_at time - Filter by a case-insensitive search of multiple fields in a document. - Example: * `query=Bob Norman` * `query=title:green hoodie` Filter by the date and time when the metafield definition was created. - Example: * `created_at:>2020-10-21T23:39:20Z` * `created_at:=1234` * `id:<=1234` Filter by the metafield definition [`key`](https://shopify.dev/docs/api/admin-graphql/latest/objects/MetafieldDefinition#field-key) field. - Example: * `key:some-key` Filter by the metafield definition [`namespace`](https://shopify.dev/docs/api/admin-graphql/latest/objects/MetafieldDefinition#field-namespace) field. - Example: * `namespace:some-namespace` Filter by the metafield definition [`ownerType`](https://shopify.dev/docs/api/admin-graphql/latest/objects/MetafieldDefinition#field-ownertype) field. - Example: * `owner_type:PRODUCT` Filter by the metafield definition [`type`](https://shopify.dev/docs/api/admin-graphql/latest/objects/MetafieldDefinition#field-type) field. - Example: * `type:single_line_text_field` Filter by the date and time when the metafield definition was last updated. Example: * `updated_at:>2020-10-21T23:39:20Z` * `updated_at: { 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) ##### 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/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; } ``` ##### 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" } } ```