How does Confluence Server query page and space permissions through APIs?

How does Confluence Server query page and space permissions through APIs?
I need to query if the specified page is publicly accessible.