Favorite and unfavorite articles
Toggle an article's favorite state and verify that the updated count persists.
Favorite or unfavorite an article for the authenticated user. Both mutations return the updated article, including favorited and favoritesCount; a follow-up read confirms that the state persists.
Before you begin
You need a valid token and an article slug. The examples use https://api.realworld.show/api. Replace YOUR_TOKEN and ARTICLE_SLUG with your values. Read authentication and token usage for the Authorization: Token ... header.
Change the favorite state
Endpoint contracts
Favorites an article for the authenticated user and returns the updated article.
/articles/{slug}/favoriteToken header for the authenticated user.
Slug of the article to favorite.
curl --request POST \ --url https://api.realworld.show/api/articles/building-a-conduit-client/favorite \ --header 'Authorization: Token demo-jwt-token'
{ "article": { "slug": "building-a-conduit-client", "title": "Building a Conduit client", "description": "Patterns for calling the article API", "body": "Article body", "tagList": ["api"], "createdAt": "2026-09-25T09:00:00Z", "updatedAt": "2026-09-25T09:00:00Z", "favorited": true, "favoritesCount": 1, "author": { "username": "reader", "bio": null, "image": null, "following": false } } }Removes the authenticated user's favorite and returns the updated article.
/articles/{slug}/favoriteToken header for the authenticated user.
Slug of the article to unfavorite.
curl --request DELETE \ --url https://api.realworld.show/api/articles/building-a-conduit-client/favorite \ --header 'Authorization: Token demo-jwt-token'
{ "article": { "slug": "building-a-conduit-client", "title": "Building a Conduit client", "description": "Patterns for calling the article API", "body": "Article body", "tagList": ["api"], "createdAt": "2026-09-25T09:00:00Z", "updatedAt": "2026-09-25T09:00:00Z", "favorited": false, "favoritesCount": 0, "author": { "username": "reader", "bio": null, "image": null, "following": false } } }Send POST /articles/{slug}/favorite with the authenticated user's token.
curl --request POST \
--url "https://api.realworld.show/api/articles/ARTICLE_SLUG/favorite" \
--header "Authorization: Token YOUR_TOKEN"The API returns 200 OK and an article object. Its favorited field is true, and favoritesCount reflects the current total.
Read the article while using the same token.
curl --request GET \
--url "https://api.realworld.show/api/articles/ARTICLE_SLUG" \
--header "Authorization: Token YOUR_TOKEN"Confirm that article.favorited remains true and that article.favoritesCount is the count returned by the favorite request. The conformance suite checks both fields after the follow-up read.
Send DELETE /articles/{slug}/favorite with the same token.
curl --request DELETE \
--url "https://api.realworld.show/api/articles/ARTICLE_SLUG/favorite" \
--header "Authorization: Token YOUR_TOKEN"The API returns 200 OK with the updated article. Confirm that favorited is false and that favoritesCount reflects the removal.
Verify the result
favorited: true, the follow-up article read preserves that state, and the unfavorite response reports favorited: false with the updated favoritesCount.Both operations require authentication. A missing or invalid token returns 401 Unauthorized; an unknown article slug returns 404 Not Found. These responses use the standard error envelope. Do not infer the count from the local UI: use the favoritesCount value in the API response.
The favorite state is associated with the authenticated user. To find articles favorited by a user, use the favorited filter described in list and filter articles.
Troubleshooting
If either mutation returns 401 Unauthorized, inspect the request before changing the article: the header must use the Authorization: Token YOUR_TOKEN form, and the token must be valid. If the response is 404 Not Found, check ARTICLE_SLUG with read an article by slug; an unknown slug cannot be favorited or unfavorited. After correcting the token or slug, repeat the same operation and confirm the returned favorited value.
Next steps
To display the article before toggling its state, see read an article by slug. To build a complete article interaction flow, continue with connect a frontend to Conduit.