How to extract the complete content of the document from the returned data of the document detail interface?

Calendar 👁️ 88

In website operation, we often need to dynamically retrieve and display the articles or product details of the site.AnQiCMS (AnQiCMS) provides a powerful and flexible API interface, making this process very convenient.Among them, the interface for obtaining document details is one of the core ones, which can not only return the basic information of the document but also allow you to easily obtain the complete content of the article.

This article will guide you on how to accurately extract the complete content of the document from the document detail interface of Anqi CMS.

Call the document detail interface to get data

To extract the full content of the document, we first need to send a request to the document detail interface of Anqi CMS. The address of this interface is{域名地址}/api/archive/detailand useGETmethod to call.

When initiating a request, you need to provide the unique identifier of the document. Typically, this will be the document'sID, or the document'sURL 别名(filename)Either one of these is okay. For example, if you know the ID of an article is1you can do something likeGET {域名地址}/api/archive/detail?id=1Make a request in this manner. Usually, these IDs or aliases can be obtained from the document list interface(/api/archive/list)or directly from the website's URL.

After you successfully initiate the request, the interface will return a JSON-formatted data. This data structure is clear, containing various detailed information of the document.

Locate the full content of the document from the returned data

After successfully obtaining the JSON response, the next step is to locate the full content of the document we are concerned about. The returned JSON data will containcode/msganddataThree top-level fields. Among them,datathe field is our focus, carrying all the details about the document.

Let's look at a typical successful return data example:

{
  "code": 0,
  "data": {
    "id": 1,
    "created_time": 1607308159,
    "updated_time": 1662717106,
    "title": "欢迎使用AnqiCMS",
    // ... 其他文档元数据 ...
    "category": {
      // ... 分类信息 ...
    },
    "data": { // 这个是关键!
      "id": 1,
      "content": "<p>欢迎使用AnqiCMS</p>" // 文档的完整内容就在这里
    },
    // ... 其他字段 ...
  },
  "msg": ""
}

From this structure, we can clearly see that the complete content of the document is hidden in onenesteddatafield. The specific path is: top-level responsedataobject underdatafield(yes, there are two}data), inside it is namedcontentfield.

So, if you are using a programming language to process this JSON response, you would typically access it like this:response.data.data.content.

ThiscontentThe field is typically an HTML string that includes the text, images, links, and other rich media information of the document.The Anqi CMS allows you to use rich text format when editing articles in the backend editor, so returning HTML is expected here and can be directly used for front-end page rendering.

Practical tips and注意事项 after extracting the content

After obtaining the complete content of the document, you can use it in various scenarios:

  • Front-end display:The most direct use is to render these HTML contents to your webpage, mini-program, or mobile application to display the full article details.Most modern frontend frameworks support rendering HTML strings directly.
  • Content cleaning and security:Although AnQi CMS performs some processing when generating content, as a matter of practice, when you directly render HTML content obtained from the API on the front-end page, it is recommended that you use an appropriate HTML sanitization library or method to prevent potential XSS (cross-site scripting) attacks or other security vulnerabilities.For example, in JavaScript, you can use libraries like DOMPurify for cleaning.
  • Combine with other information:At the top leveldataIn the field, in addition to the core content, you can also findtitle(Document Title),description(Document summary),keywords(Keywords),logo(Document logo) andextra(Custom field) and other information. These metadata should be combined with the completecontentto provide users with a richer and more comprehensive reading experience.
  • SEO optimization:Extracted title, description, and keywords information, which can be used to generate page content.<title>tags,metaDescription and keyword tags, helpful for improving search engine optimization.
  • In-site search or data analysis:If you need to build an in-site search function, you can extract the text content of thecontentfield as index data. Similarly, analyzing the document content can also provide valuable insights.

Through the document detail interface, Anqi CMS makes it simple and efficient to obtain the core content of the document.If you understand the data structure, you can flexibly use this information to build powerful and rich websites or applications.


Frequently Asked Questions (FAQ)

1. WhycontentThe field returns HTML format instead of plain text?The Anqi CMS backend editor supports rich text editing, allowing you to insert images, links, set styles, and more.Therefore, the interface will return the content in HTML format to fully present the style and structure of the document you created in the background.If you only need plain text, you need to parse and remove tags from the HTML string on the client side.

2. BesidescontentWhat useful information can the document detail interface provide?In addition to the core content, what top-level information does the interface return?dataThe object also includes the document'sid/title/seo_title/keywords/description/views(Views),comment_count(Comments),images(Group photos),logo(thumbnail),created_time(Publication time) and rich information. Moreover, if your model has set custom fields, their contents will also be displayed inextraReturn within the object.

3. If the document is paid or password-protected, can I still get it directly?content?For paid documents, you need to go through/api/archive/order/checkThe interface checks if the user has paid; for password-protected documents, it is necessary to pass through/api/archive/password/checkAPI verification password. Only after verification is passed will the returned data of these APIs contain the complete content of the documents, or allow you to continue callingarchiveDetailAPI to retrieve complete content. Call directlyarchiveDetailInterfaces usually do not return paid or password-protected documents.contentfield.

Related articles

What HTTP request methods does the AnQi CMS document detail interface support?

When building websites or developing various applications, we often need to obtain detailed information about articles or documents from a content management system (CMS).AnQiCMS (AnQiCMS) is a powerful content management platform and naturally provides such an interface, allowing developers to flexibly obtain various document content on the website.So, when we want to get the specific article through the document detail interface of Anqi CMS, which HTTP request method should we use?

2025-11-09

What error message will the interface return if the document does not exist when getting the document details?

In the daily operation and development of Anqi CMS, we often need to retrieve website content through API interfaces, among which the 'Get Document Detail Interface' (`/api/archive/detail`) is undoubtedly one of the most frequently used ones.This interface allows us to retrieve the details of a specific article or product by document ID or URL alias (filename).However, during use, we are bound to encounter such situations: When the requested document does not exist in the system, what kind of error message will the interface return?This is for front-end page display

2025-11-09

If both `id` and `filename` parameters are provided, which one will the AnQi CMS document detail interface prioritize?

In AnQi CMS, getting document details is a very frequent operation in our daily operation.We usually request document data through the unique numeric identifier `id` or the user-friendly URL alias `filename`.

2025-11-09

How to get the details of a document through the document URL alias (`filename`)?

In AnQi CMS, the document URL alias (`filename`) is a very practical feature, which not only makes your website URL more friendly and improves search engine optimization (SEO) effect, but also provides great convenience in content acquisition.When you need to obtain detailed information about a specific document through programming, AnQiCMS provides a simple and intuitive API interface.### Core Feature Revelation: Get Details Using Document URL Alias To get all details of the document through its URL alias

2025-11-09

What are the common meanings of the `code` and `msg` fields in the document details interface?

When using AnQiCMS for website development or integration, we often deal with API interfaces.When handling the return results of these interfaces, the `code` and `msg` fields are almost indispensable parts of all response data.They play the role of 'traffic lights' and 'instruction manuals', helping us quickly understand the processing results of the request, whether successful or not.### `code` field: Quickly judge the status code of the request result The `code` field is an integer value

2025-11-09

How to get the SEO title (`seo_title`), keywords (`keywords`), and description (`description`) of a document?

In website operation, setting clear and targeted SEO titles (`seo_title`), keywords (`keywords`), and descriptions (`description`) is a key step in improving search engine rankings.AnQiCMS (AnQiCMS) provides a convenient way to manage and obtain these important SEO metadata.Whether you need to dynamically set this information for a single page or process a large amount of content in bulk, it can be easily achieved through the provided API interface.

2025-11-09

What role does the `url_token` field play in the document details, and how is it associated with the `filename` parameter?

In the daily use of Anqi CMS, we often encounter the `url_token` field, especially when dealing with document details and URL structures.It is closely related to the `filename` parameter in the API interface. Understanding the relationship between the two is crucial for better management of website content, optimizing user experience, and improving search engine performance.### `url_token`:The "friendly" identity tag of content `url_token` is simply the term used in the AnQi CMS system for various types of content (such as documents

2025-11-09

What do the `module_id` and `category_id` fields represent in the document details, and can you further query model or category details through them?

## Unveiling the details of Anqi CMS document `module_id` and `category_id`: What do they mean?When using AnQi CMS for content management and website operation, we often obtain various data through API interfaces, among which the document detail interface (`/api/archive/detail`) is the key to obtaining the core information of a single article.In the returned data of this interface, you may notice the `module_id` and `category_id` fields.

2025-11-09