Table of contents
  1. Rest API List
  2. Common response
  3. API details
    1. Fetch a content
    2. Fetch a version
    3. Fetch a tree
    4. Fetch content list
    5. Create content
    6. Move content
    7. Update content
    8. Delete content
    9. Set priority
    10. Login
    11. Logout
    12. Renew access token
    13. Get current user’s information
    14. Request reseting password
    15. Reset password
    16. Enable/Disable user
    17. Upload a file
    18. Upload an image

Rest API List

Below is a list of rest api

Operation Description
Content  
content/get Fetch a content
content/tree Fetch a content tree
content/list Fetch content list
content/create Create content
content/move Move content
content/update Update content
content/delete Delete content
content/set-priority Set priority
Authorization  
auth/auth Auth to get token to login
auth/token/revoke Revoke token to logout
auth/token/renew Renew access token
User  
user/current  
user/reset-password Request reseting password
user/resetpassword-confirm Confirm reset passwork link
user/enable Enable/Disable user
Utility  
util/uploadfile Upload file
util/uploadimage Upload image

Common response

Digimaker CMF will always return a json format. For a successful page it will be like below, where “error” is always false. All th ‘real’ data will be inside “data”

{
  "error": false,
  "data": {
    "cid": 3,
    "version": 4,
    "published": 1628163956,
    "modified": 1628196214
  }
}

For error it will put error information into data and set “error” to true

{
  "error": true,
  "data": {
    "code": "10001",
    "message": "Cann't get content type",
    "detail": ""
  }
}

API details

Fetch a content

Format content/get/<content type>/<id>

Result JSON of the content

Example: content/get/article/1

Fetch a version

content/version

Fetch a tree

content/treemenu

Fetch content list

Fetch content list, with user’s permission considered.

Format

content/list/<content type>?<parameters...>

Parameters

Parameter Example Description
parent 3 parent id of a content. No need if it’s non-location content
level 1 Level under the parent id, 1 means the direct children . No need if it’s non-location content
limit 10 How many for record to fetch
offset 0 Which position to fetch records
sortby priority desc,id desc sort by. Support multi fields
field.* field.title filter by field
location.* location.priority filter by location’s attribute. eg. priority, publish. modified

Result

List of the content like below

{
  "list": 
     [{"title":"Test", 
       "body":"<p>Test body</p>"}
     ],   
   "count": 4
}  

Create content

Format

url: content/create/<content type>/<parent location id>, with a json as request body. Note: non-location content doesn’t need parent location id.

Here is a body example, where title&body are field identifiers

{
  "title":"Test", 
  "body":"Test body"
 }

Return

Move content

Format: content/move

Update content

Format url: content/update/<location id> or content/update/<content type>/<content id>. Put json as request body.

Here is a body example, where title&body are field identifiers

{ "title":"Test",
  "body":"Test body"}

Delete content

Format: url: content/delete?id=<location id> or content/delete?type=<content type>&id=<content id>.

Set priority

content/setpriority

Login

Format: auth/auth Method: POST

Body:

{ "username":"<username or email>",
  "password":"<password>"}

Response:

Access token and refresh token, example like below.

{
  "access_token": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJleHAiOjE2MzE1MzgzNDcsInVzZXJfaWQiOjEsInVzZXJfbmFtZSI6IkFkbWluaXN0cmF0b3IgQWRtaW4ifQ.VV3yJW7q5oZ4PVMj8d-2m224MmOP7PG3QJCWPL3mv0w",
  "refresh_token": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJleHAiOjE2MzE1NDYxNDcsImd1aWQiOiI4MWZjZjYzMC02ZWFhLTQwMjctOGI1Zi1kZjc2YjgwY2JjNDgiLCJ1c2VyX2lkIjoxfQ.DegXqhzWML1sgENCnZVjC_udW77_m_rkV0Us7-CcP-M"
}

Logout

Format auth/token/revoke

Renew access token

Formatauth/token/renew

Get current user’s information

Format user/current

Request reseting password

user/resetpassword

Reset password

user/resetpassword-confirm

Enable/Disable user

Format user/enable

Upload a file

Formatutil/uploadfile

Upload an image

Format util/uploadimage