openbridge.articles.get(idOrHandle, blogHandle?)
openbridge.articles.get(idOrHandle).blog(blogHandle).select(fields)
Fetches a single article by handle or Shopify GID. Supports chaining .blog() and .select() to configure the query.
Parameters
| Param | Type | Required | Description |
|---|
idOrHandle | string | Yes | Article handle or Shopify GID |
blogHandle | string | No | Blog handle (required when fetching by article handle) |
When fetching by handle, you must either use .blog() or pass the blogHandle parameter.
Returns
ShopifyArticle | null
Examples
Get by handle
const article = await openbridge.articles.get('my-first-post', 'news')
if (article) {
console.log(article.title)
}
Get by handle with .blog()
const article = await openbridge.articles
.get('my-first-post')
.blog('news')
Get by Shopify GID
const article = await openbridge.articles.get(
'gid://shopify/Article/123456789'
)
With field selection
const article = await openbridge.articles
.get('gid://shopify/Article/123456789')
.select(['title', 'handle', 'content', 'image', 'author'])
Handle not found
const article = await openbridge.articles.get('non-existent', 'news')
if (!article) {
console.log('Article not found')
}