There isn't a direct way to do this through an API. What you'll want to do is develop a crawler, either local (e.g., automate IE or Selenium) or cloud-based. As Private PAIR access requires passing 2-factor authentication from the uspto.gov website, you'll need to build that authentication process into your framework. As a result, you'll need to wait for the user input or have some email configured on the server to receive/handle authentication messages from PTO before you can log-in.
Once you log-in to the internal Pair page, then it's just a matter of automating clicks and moving through their website while collecting data or downloading documents. Either way, it's a quite a bit of work. Also, the USPTO is always tweaking their site and actively trying to prevent bots from accessing it, so it's a project that will require constant updates.
You can also consider getting some commercial software that can do it. For example:
Pair Downloader: https://www.neustelsoftware.com/pairdownloader/