In-depth analysis of AnQi CMSarchive/listInterface: default behavior and return content without parameters
When using AnQiCMS for website development or content management, we often need to retrieve various data through API interfaces.archive/listThe interface is one of the core interfaces for obtaining the document list of a website. Understanding its default behavior and return content when no parameters are passed is crucial for efficient data acquisition and initial debugging.
Interface address and calling method overview
first, archive/listThe calling address of the interface is{域名地址}/api/archive/listAnd thenGETThe method is used to make a request. When you make a request to this address without any parameters, Anqi CMS will process your request based on its internal preset logic.
The default behavior when no parameters are passed
When you callarchive/listWhen no request parameters are specified, the system will adopt a series of default strategies to determine what content to return and how to organize it.
First and foremost, the most critical point is, the interface'stypeThe parameter will be set tolistThis means that even if you do not explicitly request it, the system will return the document in list form rather than in paginated form. Due totypeDefault tolistother parameters related to pagination, such aspageandq(Search keyword), in this case it will not take effect.
Secondly, the system usually adopts the sorting method for documents.id descThis means that the documents are sorted in reverse order by document ID. This means you will get the latest document, with the documents with larger IDs appearing earlier.
In addition, regarding the classification of the document, if you have not passedcategoryIdspecify the parameter, the system will default to fetching all documents under all categories. At the same time,childThe default value of the parameter istrueThis means that even if you specify a category, the system will also include all the subcategory documents under that category. But if you do not specifycategoryIdUnder the premise, this default behavior is reflected in its covering all models and categories of documents on the website.
Finally, there is a default behavior that needs to be noted, but it is not explicitly mentioned in the documentationlimitof (displayed number). Although not specifiedlimitBut the API usually does not return all documents indefinitely.To ensure the response speed of the interface and the system resource usage, it is very likely that AnQi CMS will apply a default quantity limit internally, such as returning the most recent 10 or 20 documents.The exact number of documents returned may need to be confirmed through actual testing, but it is definitely not all the documents returned.
The structure and meaning of the default returned content
Whenarchive/listWhen the interface is executed successfully without any parameters, you will receive a standard JSON format response.
This response contains three main fields:
code: Represents the status code of the request. It is usually successful.0.msg: Provides a text description of the request result. It is an empty string when successful, and indicates the error cause when failed.dataThis is an array containing a series of document objects that meet the default conditions.
Each document object (dataan element of an arrayitemAll of them are very detailed, including almost all the core information of the document, such as:
id: The unique identifier of the document.title: The title of the document.seo_title: The SEO title of the document, used for search engine optimization.url_token: The document's URL alias, usually used to generate friendly URLs.keywordsanddescription: The document's keywords and summary, which are also very important for SEO.module_idandcategory_id: Represent the model and classification ID of the document.viewsandcomment_count: Document views and comment count.images,logo,thumb: Document-related image information, such as group images, Logo, and thumbnails.flag: Document recommendation attributes, such as headlines, recommendations, etc.created_timeandupdated_time: Document publishing and update timestamp.status: Document display status.user_id: User ID of the document publisher.priceandstockIf the document is a product, it will also include price and inventory information.extraAn object containing other custom field information of the document, these fields vary according to the model settings.
It is noteworthy that by default,typeWithlistthe successful response will include,Do not includetotalfieldyou cannot directly know the total number of documents that meet the conditions from this request.
the significance in real-world scenarios
Understandarchive/listThe default behavior of the interface when no parameters are passed, which is very useful for quickly previewing the website content and performing preliminary API connectivity tests.It allows you to immediately obtain the latest document list of the website without writing complex parameters, helping you understand the basic structure and content of the data.However, in practical applications, in order to obtain more accurate and business-specific data, it is usually necessary to pass the corresponding parameters according to specific circumstances, such as specifyingmoduleId/categoryId/order/type=pageas well aslimitEqual, in order to achieve precise data filtering and pagination display.
Frequently Asked Questions (FAQ)
Q: How can I retrieve all documents or perform pagination display?A: If you need to retrieve all documents or paginate through them, you need to explicitly set
typeparameters forpage. Whentype="page"when youpageandlimitparameters to specify the page number and the number of items per page, and the response will also return an extra onetotalThe field indicates the total number of documents.Q: Why can I return documents without specifying a category or model? Which documents are returned?A: This is because
archive/listThe interface does not specifycategoryIdormoduleIdWhen, it will default to fetching documents from all available document models and categories.The content returned is considered "latest" or "default" by the system, which is usually the document sorted in reverse order by ID and applied with the internal default quantity limit.Q: Why are the default returned data not showing
totalthe field to display the total number of documents?A: By default,archive/listinterface'stypeparameters forlistIn this mode, the API only returns a list of documents and does not provide the total number of documents. If you need to get the total number of documents, you must settypeThe parameter is explicitly set topage.