Hi @sheejo
Yes, it's possible to query to AEP using API calls. Refer to the following documentation that will guide you in using the query service.
https://developer.adobe.com/experience-platform-apis/references/query-service/
https://experienceleague.adobe.com/docs/experience-platform/query/api/getting-started.html?lang=en
You can export the queried data from AEP to CSV file.
There are two ways to save the results of a query when using a PSQL client. You can use the Copy To command or create a statement using the following format: