Does the data structure returned by the document detail interface change for different types of documents (such as articles and products)?

Calendar 👁️ 69

When using AnQiCMS to build a website, we often need to obtain detailed information of various documents through the API interface. Among them,archive/detailThe interface is the key to obtaining the details of a single document. Many developers and content operators may be curious about whether the data structure returned by this interface will be different for different types of documents, such as ordinary articles, news, or product information on e-commerce websites.The answer is: it has both unity and high flexibility.

First, AnQi CMS is designedarchive/detailWhen interfacing, a core and unified set of data fields is provided for all document types. Whether you request a regular article or a specific product detail, you will find the returneddataObjects such asid(Document ID),title(Title),seo_title(SEO title),description(Summary),url_token(URL alias),created_time(creation time) andupdated_time(Updated time) and other basic information. These fields constitute the basic framework of the document, ensuring consistency in core properties across different types of content, greatly facilitating the front-end data processing and display logic, allowing you to easily present the common properties of the document.

On this unified structure, AnQi CMS also integrates some fields designed directly for specific document types. A striking example isprice(price) andstock(Inventory quantity). When you get a product document, these fields will appear directly.dataIn the root level, providing you with the pricing and inventory status of the product.And for ordinary articles of this kind that do not require price and inventory attributes, these fields may be displayed as default values (such as 0) or not displayed at all, reflecting the system's direct support for common business scenarios and saving the trouble of redundant configuration in custom fields.

However, the real strength of Anqi CMS lies in its flexible "model" mechanism and its closely relatedextrafield. Each document belongs to a specific "document model" (viamodule_idIdentify), and each model can be configured with a series of custom fields. It is these custom fields that are the key to significant changes in the data structure of different document types. When you go througharchive/detailWhen retrieving the document details, all custom fields configured for the model of the document will be aggregated into the returned data.extrain the object. For example, a technical article may haveextraincludingauthor(Author),version(Version) etc. custom fields, while a product document may containextrainmaterial(Material),color(Color),size(Size) etc. more detailed product parameters.extraThe structure of the field iskey => itemin the form ofkeyIs the name of the custom field,itemthen containsname(field name),value(actual value) anddefault(default value). This means, by using theextraThe field explanation, you can completely present a rich and diverse content according to the needs of different document models, greatly expanding the expression form of the content.

This design pattern brings great convenience and scalability.It avoids hardcoding all possible fields in the core interface, thus maintaining the simplicity and efficiency of the API.As a user, when you start fromarchive/detailData can be obtained through an interface bymodule_idto determine the model of the current document (such asmodule_id1 usually represents an article, andmodule_idFor 2 may represent a product), and thus can be handled and displayed flexiblyextraField custom data. This enables Anqi CMS to easily handle various content management scenarios from simple blog articles to complex e-commerce products, without the need to design a separate API interface for each content type.

In summary, it is about AnQi CMS'sarchive/detailThe interface design takes into account both generality and specificity. It provides a set of stable basic data structures, and throughprice/stockfields and highly flexibleextraCustom field mechanism, which has realized dynamic adaptation to different types of document data structures. This means that when you are developing, you need to base on themodule_idandextraThe content of the field is analyzed and rendered on the page to make full use of the powerful content management capabilities of Anqi CMS.


Frequently Asked Questions (FAQ)

How can you judge whether a document is an article or a product type?You can use the data returned to find out the following.module_idField to judge the type of document. Anqi CMS assigns uniquemodule_idFor example,module_id1 usually represents the article model, andmodule_idIt may represent a product model. You canmodule/listget detailed information about all modules, including theiridandtitleto establish the corresponding mapping relationship.

2. If I add two custom fields 'Color' and 'Size' to the product model, how will they be reflected in thearchive/detailinterface return data?These custom fields will all be displayed indatathe object'sextrathe field. For example, you might see a structure similar to this:

"extra": {
  "color": {
    "name": "颜色",
    "value": "红色",
    "default": ""
  },
  "size": {
    "name": "尺寸",
    "value": "XL",
    "default": ""
  }
}

You need to access their values according to the customfield_name(that is, here in thecolorandsize)

3.dataandextraWhat is the difference between the fields? Do they both contain content? datafield inarchive/detailThe core data returned by the interface mainly contains the main content of the document, that is,contentfield, is usually the detailed article or product description edited by the rich text editor. andextraThe field is used to store all the fields added to a specific document model through the "Model Management" feature of the AnQi CMS backendCustom fieldIn other words,data.contentis the main content block of the document,extraThe supplementary, structured data surrounding this main content block.

Related articles

How to ensure the uniqueness of document URL alias queries to avoid ambiguity?

When using AnQi CMS for content management, URL aliases (also known as URL Tokens) are a key component for building user-friendly and SEO-optimized websites.It not only makes your page address more readable, but also helps search engines better understand the content topic.However, it is particularly important to ensure the uniqueness of the document when querying through these URL aliases, otherwise it may cause the system to identify confusion, users to access incorrect pages, and even affect the SEO performance of the website.

2025-11-09

Does the document detail interface directly provide the detailed content of the document's category (`category.content`)?

When using AnQi CMS for website development or content integration, it is often necessary to obtain documents and their related information.One of the common questions is: When getting the details of a document, can we also get the detailed content of the category to which the document belongs, especially fields like `category.content`?According to the documents provided by AnQi CMS, we can clearly find the answer.To be direct, **yes, the AnQi CMS document detail interface (`/api/archive/detail`) indeed provides detailed content of the document's category

2025-11-09

What does it mean if an error code 1001 or 1002 occurs when getting the document details, and how to solve it?

When using AnQi CMS for website content management and development, we often use API interfaces to obtain various data, among which obtaining document details (`/api/archive/detail`) is very commonly used.When you call this interface, if you encounter system return codes 1001 or 1002, it usually indicates that the request was not successfully processed and a specific reason is given.Understanding the meaning and solutions of these error codes can help us more efficiently troubleshoot problems and ensure the normal display of website content.### Error Code 1001

2025-11-09

How to get the value of a specific custom field (such as "author") through the `extra` field?

In Anqi CMS, the custom fields of documents are a reflection of its powerful flexibility, allowing us to add various unique attributes to content, thereby enabling more precise management and display of information.But for many developers and operations personnel, how to accurately obtain the values of these custom fields through the API is often a clear issue.Don't worry, Anqi CMS provides clear paths in API design, through the `extra` field, you can easily handle these additional data.### Understand the `extra` field

2025-11-09

How to get the link and title of the 'previous' or 'next' document by using the `id` of the current document through other interfaces?

In content-based websites, users often want to be able to easily navigate from the current article to the previous or next article. This continuous reading experience is crucial for improving user satisfaction and the website's PV (page views).AnQiCMS (AnQiCMS) provided us with a simple and efficient API interface to implement this function, allowing developers to easily integrate "previous/next" navigation on the article detail page.### Subtly Utilize API, Build Article Navigation AnQi CMS provides a very intuitive interface for obtaining the previous and next articles

2025-11-09

How to use AnQi CMS API to check if a specific document has been paid before viewing?

When building and operating modern websites, especially when your platform involves high-quality content or exclusive resources, how to effectively manage content access permissions is a core issue.AnQiCMS (AnQiCMS) provides a powerful and flexible API interface that allows you to precisely control document viewing conditions, including determining whether a specific document requires payment and whether the user has completed the payment.We will discuss how to use the API provided by AnQiCMS to check if a specific document has been paid for before it can be viewed, ensuring that your paid content is properly protected.###

2025-11-09

How can I verify the password submitted through the API to obtain the document content if the document is protected by a password?

In Anqi CMS, content management not only covers the regular article publishing and display, but also provides flexible mechanisms to protect sensitive or exclusive content.When you need to allow users to access specific document content by entering a password, Anqicms provides a clear API interface to implement this function.This is very useful for building paid content, VIP areas, or internal material sharing scenarios.### Core Function: Document Password Verification API

2025-11-09

Does the `user_id` field in the document details indicate the document publisher or author ID?

When managing website content in AnQi CMS, we often encounter various data fields, among which the `user_id` field is a common and easily questionable identifier.When we retrieve document details from Anqi CMS, what does this `user_id` represent, the publisher or the author?To clearly understand this point, we need to analyze the data structure returned by the document interface.Firstly, from the `archiveDetail.md` document to get the API return parameters of the document details view

2025-11-09