Skip to content

Get Article Detail

Get detailed information of a single article by ID or Slug.

Interface Information

  • Endpoint: GET /api/articles/:id
  • Authentication: Not required (public interface)
  • Content-Type: application/json

Path Parameters

ParameterTypeRequiredDescription
idstring/numberYesArticle ID or Slug

Response Fields

Field NameTypeDescription
idnumberArticle ID
titlestringArticle title
slugstringURL-friendly identifier
contentstringArticle content (Markdown format)
excerptstringArticle excerpt
coverImagestringCover image URL
categoryIdnumberCategory ID
categoryNamestringCategory name
authorIdnumberAuthor ID
authorNamestringAuthor name
viewCountnumberView count
likeCountnumberLike count
statusstringStatus: published/draft
createdAtstringCreation time
updatedAtstringUpdate time

Request Examples

bash
# Using ID
curl http://localhost:3000/api/articles/1

# Using Slug
curl http://localhost:3000/api/articles/my-first-post

Response Example

json
{
  "success": true,
  "data": {
    "id": 1,
    "title": "My First Article",
    "slug": "my-first-post",
    "content": "# Article Content\n\nHere is the main content of the article...",
    "excerpt": "Article excerpt",
    "coverImage": "https://example.com/cover.jpg",
    "categoryId": 1,
    "categoryName": "Technical Sharing",
    "authorId": 1,
    "authorName": "Administrator",
    "viewCount": 128,
    "likeCount": 32,
    "status": "published",
    "createdAt": "2024-01-15T10:00:00.000Z",
    "updatedAt": "2024-01-15T12:00:00.000Z"
  }
}

Error Responses

HTTP Status CodeDescription
404Article does not exist
500Server error

Slug Generation Rules

  • Automatically generated when article is created
  • Based on lowercase title
  • Spaces and special characters replaced with hyphens
  • Leading and trailing hyphens removed
  • Multiple hyphens merged into one