Yes, check out the Database
API: https://prodi.gy/docs/api-database#database For example, here's how you would connect, get all dataset names and get all annotations of a given dataset:
from prodigy.components.db import connect
db = connect()
all_dataset_names = db.datasets
examples = db.get_dataset("my_dataset")
The source of the stats
command/recipe is also shipped with Prodigy, so you can always check it out in recipes/commands.py
and see how it's done there.