Skip to content

articles.get()

Retrieves a single article by its ID with complete article details, content, and metadata.

async get(articleId: number): Promise<ArticleResponseModel>
ParameterTypeRequiredDescription
articleIdnumberYesThe unique identifier of the article to retrieve

Returns a Promise<ArticleResponseModel> containing the complete article object with properties including:

PropertyTypeDescription
idnumberThe article’s unique identifier
titlestringThe article title
bodystringThe article content in HTML format
bodyMarkdownstringThe article content in Markdown format
scorenumberArticle score based on upvotes
typeArticleTypeThe type/category of the article
tagsstring[]Array of tags associated with the article
creationDateDateWhen the article was created
lastEditDateDate | nullWhen the article was last edited
lastActivityDateDate | nullWhen the article last had activity
ownerUserSummaryResponseModelInformation about the article author
lastEditorUserSummaryResponseModelInformation about who last edited the article
viewCountnumberNumber of times the article has been viewed
upvoteCountnumberNumber of upvotes the article has received
isBookmarkedbooleanWhether the logged-in user bookmarked the article
webUrlstring | nullDirect URL to the article
shareLinkstring | nullLink for sharing the article
permissionsArticlePermissionsRequestModelArticle permission settings
import { StackOverflowSDK } from 'so-teams-sdk';
const sdk = new StackOverflowSDK({
accessToken: 'your-access-token',
baseUrl: 'https://[your-site].stackenterprise.co/api/v3'
});
// Get a specific article
const article = await sdk.articles.get(123);
console.log(`Title: ${article.title}`);
console.log(`Score: ${article.score}`);
console.log(`Views: ${article.viewCount}`);
const article = await sdk.articles.get(123);
// Display article information
console.log(`Article: ${article.title}`);
console.log(`Author: ${article.owner?.displayName}`);
console.log(`Created: ${article.creationDate}`);
console.log(`Tags: ${article.tags.join(', ')}`);
// Access content in different formats
console.log('HTML content:', article.body);
console.log('Markdown content:', article.bodyMarkdown);
// Check engagement metrics
console.log(`${article.upvoteCount} upvotes, ${article.viewCount} views`);
const article = await sdk.articles.get(123);
// Check edit history
if (article.lastEditDate) {
console.log(`Last edited: ${article.lastEditDate}`);
console.log(`Edited by: ${article.lastEditor?.displayName}`);
} else {
console.log('Article has not been edited since creation');
}
// Check article type and permissions
console.log(`Article type: ${article.type}`);
console.log(`Permissions:`, article.permissions);
// User-specific information
if (article.isBookmarked) {
console.log('You have bookmarked this article');
}
// Using team context
const teamSDK = sdk.forTeam('team-123');
const teamArticle = await teamSDK.articles.get(123);
// Or with direct client initialization
import { ArticleClient } from 'so-teams-sdk';
const teamArticleClient = new ArticleClient(config, 'team-123');
const article = await teamArticleClient.get(123);
async function analyzeArticle(articleId: number) {
try {
const article = await sdk.articles.get(articleId);
const analysis = {
title: article.title,
author: article.owner?.displayName,
engagement: {
score: article.score,
upvotes: article.upvoteCount,
views: article.viewCount,
engagementRatio: article.upvoteCount / Math.max(article.viewCount, 1)
},
content: {
wordCount: article.bodyMarkdown?.split(' ').length || 0,
tagCount: article.tags.length,
tags: article.tags
},
history: {
created: article.creationDate,
lastEdited: article.lastEditDate,
hasBeenEdited: !!article.lastEditDate
}
};
return analysis;
} catch (error) {
console.error('Failed to analyze article:', error.message);
throw error;
}
}
const analysis = await analyzeArticle(123);
console.log('Article Analysis:', analysis);
async function getMultipleArticles(articleIds: number[]) {
const articles = [];
const errors = [];
for (const id of articleIds) {
try {
const article = await sdk.articles.get(id);
articles.push(article);
console.log(`✓ Loaded: ${article.title}`);
} catch (error) {
errors.push({ id, error: error.message });
console.error(`✗ Failed to load article ${id}:`, error.message);
}
}
return { articles, errors };
}
const result = await getMultipleArticles([123, 456, 789]);
console.log(`Successfully loaded ${result.articles.length} articles`);
console.log(`Failed to load ${result.errors.length} articles`);

This method can throw the following errors:

Error TypeStatus CodeDescription
AuthenticationError401Invalid or missing authentication token
TokenExpiredError401Authentication token has expired
ForbiddenError403Insufficient permissions to access the article
NotFoundError404Article with the specified ID does not exist
SDKErrorVariousOther API or network errors
import StackOverflowSDK, { NotFoundError, ForbiddenError } from 'so-teams-sdk';
const sdk = new StackOverflowSDK({
accessToken: 'your-access-token',
baseUrl: 'https://[your-site].stackenterprise.co/api/v3'
});
try {
const article = await sdk.articles.get(123);
console.log('Article retrieved:', article.title);
} catch (error) {
if (error instanceof NotFoundError) {
console.error('Article not found or has been deleted');
} else if (error instanceof ForbiddenError) {
console.error('Access denied - insufficient permissions to view this article');
} else {
console.error('Failed to retrieve article:', error.message);
}
}
async function safeGetArticle(articleId: number) {
try {
const article = await sdk.articles.get(articleId);
return {
success: true,
article,
message: 'Article retrieved successfully'
};
} catch (error) {
if (error instanceof NotFoundError) {
return {
success: false,
reason: 'not_found',
message: 'Article not found'
};
} else if (error instanceof ForbiddenError) {
return {
success: false,
reason: 'access_denied',
message: 'Access denied to this article'
};
}
return {
success: false,
reason: 'error',
message: error.message
};
}
}
const result = await safeGetArticle(123);
if (result.success) {
console.log('Article loaded:', result.article.title);
} else {
console.log('Could not load article:', result.message);
}
  • This method returns the complete article object with all available fields
  • Both HTML and Markdown versions of the content are available in the response
  • User-specific fields like isBookmarked reflect the state for the authenticated user
  • View counts may be updated when the article is accessed through the web interface
  • Articles may have different permission levels that affect who can view them
  • The permissions field contains the article’s access control settings
  • Deleted articles will result in a NotFoundError rather than returning deleted content
  • Article URLs can be used for direct browser navigation or sharing