Hello Veizi Ioanna, Welcome to the Microsoft Q&A forum.
Yes, there is an API that you can use to collect data from Microsoft 365 Activity Explorer.
The Office 365 Management Activity API allows you to retrieve information about user, admin, system, and policy actions and events from Office 365 and Microsoft Entra activity logs.
You can use the actions and events from the Office 365 and Microsoft Entra audit and activity logs to create solutions that provide monitoring, analysis, and data visualization.
To access the API from your application, you'll need to first register it in Microsoft Entra ID and configure it with appropriate permissions. This will enable your application to request the OAuth2 access tokens it needs to call the API. For more information, see Get started with Office 365 Management APIs.
Please see the below Microsoft official documentation page
https://learn.microsoft.com/en-us/office/office-365-management-api/
I hope this answers your question.
If this answers your question, please consider accepting the answer by hitting the Accept answer and up-vote as it helps the community look for answers to similar questions.