The process of building custom applications and tools that interact with Microsoft SharePoint, including SharePoint Online in Microsoft 365.
Yes, you can using graph api for this.
- you should have a service principle grant persmission first
- call graph api to get token
- using the token to call the specific api
- try to use powershell as below
GET https://graph.microsoft.com/v1.0/sites/{site-id}/getByPath('/')/effectivePermissions/user({user-id})