Articles module
This module provides access to articles. You can list either retrieve lists of articles or a single article. Multiple methods are supported.
In case a content piece is protected by a paywall, you can include a Visitor token to request a full version of the article.
URL Format
You can use GET or POST variables in your requests.
baseUrl/articles.php?action=ACTION¶ms...
When the visitor token is required, add
&token=TOKEN_HERE
Reference
Some responses may return defined objects inside the JSON that refer to existing classes.
See related:
Acceptable output types
Single article requests return a full-sized version of an article object. It can be output in two formats:
- json: JSON
- amp: JSON, but with HTML optimized for AMP
- msn: MSN News
Article lists are somewhat more compact, and can be output in more formats, compatible with standard readers:
- json: JSON
- rss: RSS Feed
- atom: Atom Feed
- fbcatalog: Facebook Catalog
- msn: MSN News
We will only define the JSON output in this documentation. Other outputs are either standard or can be consulted from the third-party owner's documentation.
List of actions
The parameter "action" determines the action you would like to match. See below list.
list
List articles by search filters. This is your go-to command.
In here, you will use object signatures, which are made of the class name, followed by a colon, followed by the ID of the object. For example, Category:1 means Category ID 1.
You will also see the type parameter. The followed types are available by default: stream, contents. "stream" is used for the infinite stream functionality, and the "contents" is the issue-category linking functionality. Additional types can be created from the backend in the dynamic sections of a Page.
Parameters:
- signature: string, can be a string or an array of strings (encoded as a JSON string)
- page: int (optional, page number)
- limit: int (required, number of results per page)
- type: comma-separated string (some objects like Issue support a type field which links to the key name configured for the dynamic section in the Issue you would like.) Example: featured,selections
- date_from: string (optional yyyy-mm-dd date from)
- date_to: string (optional)
- text: 0/1/2 (whether to include article texts, 0: no, 1: yes with summary in body, 2: with summary separated). Recommended value: 2
- format: json, rss, atom, fbcatalog, msn
- options: string (JSON string of options to filter by) eg: for Premium articles, set options={"premium":"1"}
- category: if type contains "contents", then you can filter by a specific category ID
Response:
In case of format=json, response will be:
{
error: true/false,
data: [ Object, ... ],
total: int (total results count),
htmlPrepend: string,
htmlAppend: string
}
In case of other formats, they will be returned in their standard specification.
Some examples
If you would like to get the latest 20 articles in Category ID 1, you would perform this request:
/cmsapi/articles.php?key=KEY&action=list&signature=["Category:1"]&limit=20&text=0&page=1
If you would like to get all featured articles on Page ID 1, you would perform this request:
/cmsapi/articles.php?key=KEY&action=list&signature=["Page:1"]&type=featured&limit=20&text=0&page=1
If you would like to get all featured articles on Page ID 1, followed by the top 20 articles in Category ID 1, you would perform this request:
/cmsapi/articles.php?key=KEY&action=list&signature=["Page:1","Category:1"]&type=featured&limit=20&text=0&page=1
search
Search for articles via a user-provided query.
Parameters:
- page: int (optional, page number)
- limit: int (required, number of results per page)
- category: string (either the ID of the category to search in, or a JSON-encoded array of category IDs)
- date_from: string (optional yyyy-mm-dd date from)
- date_to: string (optional)
- keyword: string (keyword to search for)
- text: 0/1/2 (whether to include article texts, 0: no, 1: yes with summary in body, 2: with summary separated). Recommended value: 2
- author: string (optional name of author)
- format: json, msn, indesign
- options: string (JSON string of options to filter by) eg: for Premium articles, set options={"premium":"1"}
Response:
In case of format=json, response will be:
{
error: true/false,
data: [ Object, ... ],
total: int (total results count),
htmlPrepend: string,
htmlAppend: string
}
view
Get one article by ID.
Parameters:
- articleId: Article ID
- format: one of acceptable format types
- text: Whether to include article texts, htmlPrepend, and htmlAppend in output
- access_groups: Comma-separated list of the product subscription groups applicable to this interface. Example: basic,premium. See e-commerce subscriptions groups configured for more details.
Return:
{
data: [{
Article object
}],
htmlPrepend: Optional HTML to be prepended when displayed
htmlAppend: Optional HTML to be appended when displayed (deprecated)
}
preview
Get a draft version of an article.
Parameters:
- articleId: Article ID
- versionId: Version ID to preview (usually supplied via backoffice hyperlink)
- text: Whether to include article texts, htmlPrepend, and htmlAppend in output
Return: see view request
mostread
Get the most-read articles automatically generated every 15 minutes at most. You can filter by various optional filters.
Parameters:
- limit: Number of articles to return, default: 5
- typeId: ID of the Category Type collection (typically, divides your content into main groups)
- type: Type of most read listing. See below.
- format: msn, json
- text: Whether to include article texts, htmlPrepend, and htmlAppend in output
Available types:
- periodic_summarized: 24-hour lookback on most viewed content
- now: 1-hour lookback for realtime trends of most viewed content
- past7: 7-day lookback on most viewed content
- past30: 30-day lookback
Return:
{
data: [{ Article object}]
htmlPrepend: string,
htmlAppend: string,
}
add
Add an article. For internal use at the moment. You may need this if your frontend allows visitors to submit articles for review.
add_comment
Add a comment on an article.
Parameters:
- article_id: Article ID
- set_as_approved: 0/1, Whether to post as an approved comment or not (WARNING: This means comments can approval moderation here).
- file: Multi-party file named "file". Do not send as base64. This a multipart/form-data request if you're adding a file.
- comment: Text of the comment to add
- token (optional): a visitor's valid token. If not specified, the comment is anonymous.
Supported file extensions: Videos (mp4, m4v, avi, mov), Images (jpg, jpeg, png), Audio (mp3, m4a).
Return:
No additional return parameters. Only error=true in case of a failure.
list_comments
List approved comments for an article.
Parameters:
- article_id: Article ID
- limit: Maximum number of comments to return (default: 10, possible values: 0-infinity where 0 means all comments)
- page: Default is page 1.
Return:
data: [ { Comment object } ]