KQL : How to get Users Data

Hello,

I’m currently using KQL. I aim to retrieve user data similar to this API through KQL: Users | Kirby CMS. However, I’m unsure if it’s feasible.

Could you guide me on how to formulate the query?

Here is the query structure I’m considering:

const bodyData = {
    // query: "page('home')",
    query: "site.users",
    select: {
        email: true,
    }
}

Please let me know if there are any adjustments needed.

Should be kirby.users, not site.users

{
  "query": "kirby.users",
  "select": {
    "email": true
  }
}

(https://kql.getkirby.com/)

1 Like

Thank you for responding!

It works without the “select,” but when I use “select,” I receive the following error message:

{
  "status": "error",
  "message": "Access to the class 'Kirby\\Cms\\User' is blocked",
  "code": 403,
  "exception": "Kirby\\Exception\\PermissionException",
  "key": "error.permission",
  "file": "/site/plugins/kql/src/Kql/Interceptor.php",
  "line": 227,
  "details": [],
  "route": "query"
}

Have you blocked access to that class in the config?

Oh, my mistake; yes, I had it blocked. Thank you for your help; it works now.

Which probably makes sense, because user data is sensitive information that shouldn’t be openly accessible without any authentication.

1 Like