I'm currently working with the open-source OpenToonz (released by Studio Ghibli: https://opentoonz.github.io/e/), but the ECMAScript API is not very robust.
I tried Blender3D, which has a robust Python API, but it renders extremely slowly, even with raytracing off.
Youtuber 3Blue1Brown has a specialized math animation toolkit (https://github.com/3b1b; example here: https://www.youtube.com/watch?v=AmgkSdhK4K8), but it's lacking in tutorials and doesn't seem too suited for my purposes.