In the daily operation of AnQi CMS, we often encounter such needs: we have a visible document detail page URL on a website, such ashttps://en.anqicms.com/anqicmsWe hope to quickly obtain the complete API details of this document through programming, including its title, content, SEO information, etc.The Anqi CMS provides a very convenient and intuitive interface to meet this need.

To achieve this goal, we mainly rely on the "Get Document Details Interface" provided by Anqi CMS (/api/archive/detail)。This interface is designed to be very flexible, it not only supports querying through the unique numeric ID of the document, but also cleverly supports querying through the "alias" in the URL of the document(filenameorurl_tokenSearch performed. It is this feature that makes it simple to extract API information from the known document detail URL.

The core idea is like this:

Firstly, you need to identify your security CMS websitedomain addressFor example, if your document detail page ishttps://www.yourdomain.com/your-article-alias, then your domain address ishttps://www.yourdomain.com.

Next, from the document detail URL you know, we need to extract the document's 'URL alias'. Forhttps://en.anqicms.com/anqicmsit is obvious that,anqicmsThis is the URL alias of the document. This alias is usually referred to in the document management of AnQi CMS.url_tokenorfilename.

With the domain address and document alias, we can construct API requests. The call address for the document detail interface is{域名地址}/api/archive/detailand it usesGETMethod. We will use the document alias extracted asfilenamepass the parameter to this API.

So, forhttps://en.anqicms.com/anqicmsthe corresponding API request for this URL will be:

GET https://en.anqicms.com/api/archive/detail?filename=anqicms

After you send this GET request, the backend of Anq CMS will handle this request and return a JSON formatted data packet.This package will contain all the details of the document.codeThe field indicates whether the request was successful,msgThe field provides message information, and all the document data we are concerned about will be encapsulated in,datain the field.

IndataThe field, where you can find the document's,id/title(Title),seo_title(SEO title),keywords(Keywords),description(Introduction), as well as the most importantdataobject, its internalcontentfields are the detailed content of the document. In addition, there are such ascategory(Categorization information),images(Group photos),logo(Document logo),thumb(Thumbnail) and rich data can help you fully understand and utilize the document information.

This method of obtaining document details through URL aliases provides great convenience for those who need to dynamically render content on the front end, build custom applications, or integrate data.You do not need to know the document's numeric ID in advance, just extract the key part from the friendly URL the user accesses.

It should be noted that in actual operation, please be sure to use the examples in{域名地址}Replace with your actual website domain to ensure that API requests are sent correctly to your Anqi CMS instance.


Frequently Asked Questions (FAQ)

1. Can I get the API details if I only have the numeric ID of the document and not the URL alias?

Of course you can. Anqi CMS' 'Get Document Details Interface' supports two methods of query: you can pass in the numeric ID of the document asidparameters, for examplehttps://en.anqicms.com/api/archive/detail?id=1, with the same effect as usingfilenameThe parameters are the same. Usually, if both are known, using ID is a bit more direct.

2. Where is the actual content of the document in the data returned by the API? I see many fields, but no text.

The actual text content of the document is usually nested indatain the child object of the field. Specifically, you need to finddata.data.contentthis path. For example, in the returned JSON, you will see something similar"data": { "id": 1, "content": "<p>欢迎使用AnqiCMS</p>" }such a structure, in which thecontentThe field is the main text of the document you are looking for.

3. If my document URL structure is complex, for examplehttps://en.anqicms.com/category/sub-category/my-article-nameHow can I extract,filename?

In most cases, Anqi CMS will place the document's URL alias (filenameorurl_token) at the end of the URL path. Forhttps://en.anqicms.com/category/sub-category/my-article-namesuch a structure, itsfilenameusually ismy-article-name. You can parse the URL path to get the last slash/The part to be retrieved later.If your website has enabled staticization and the rules are quite special, you may need to refer to your website's backend configuration to determine the actual location of the URL alias.