Is there a way to get all emails of users with the API?

You can use the Data Explorer plugin to create a query and then hit the query API afterwards in a query like SELECT * FROM user_emails.

At per user there is also the https://meta.discourse.org/u/<username>/emails.json endpoint.