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
| Parameter | Type | Required | Description |
|---|---|---|---|
| id | string/number | Yes | Article ID or Slug |
Response Fields
| Field Name | Type | Description |
|---|---|---|
| id | number | Article ID |
| title | string | Article title |
| slug | string | URL-friendly identifier |
| content | string | Article content (Markdown format) |
| excerpt | string | Article excerpt |
| coverImage | string | Cover image URL |
| categoryId | number | Category ID |
| categoryName | string | Category name |
| authorId | number | Author ID |
| authorName | string | Author name |
| viewCount | number | View count |
| likeCount | number | Like count |
| status | string | Status: published/draft |
| createdAt | string | Creation time |
| updatedAt | string | Update time |
Request Examples
bash
# Using ID
curl http://localhost:3000/api/articles/1
# Using Slug
curl http://localhost:3000/api/articles/my-first-postResponse 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 Code | Description |
|---|---|
| 404 | Article does not exist |
| 500 | Server 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