I have recently started using Obsidian and decided to try writing some plugins. I started by examining existing community plugin files, such as nldates-obsidian by Argentina Ortega Sáinz. In it, I found that the devs are using private properties and methods of native Obsidian classes, like app.vault.getConfig() or EditorSuggest.suggestions, which I assume are used as shortcuts for otherwise public APIs.
Since they are neither covered by the docs nor the type declarations, how do devs find out about these private APIs?
Some functions or classes are not directly accessible from console, but you can interact them in the console by, for example, writing
// in constructor of a subclass of EditorSuggest
(window as any).suggest = this
in your plugin.
Reading app.js etc
You can read app.js where the public & private API functions are defined from dev tools > Source. (but it’s a little bit hard to read because it’s minified)
obsidian-ex.d.ts
There is an unofficial type definition file called obsidian-ex.d.ts maintained by a community member. It’s not perfect but is really helpful.