What is currently the best way to access the WordPress data

What is currently the best way to access the WordPress data outside of WordPress? I have a script that is going to run nightly that dumps data from WordPress into a json file. What is the best way for this script, which is external from the WordPress website, to access the data from the WordPress post and post_meta tables?

Thank you.
Beth