You say you've been struggling even though you've tried Obsidian. It has support for code blocks. I don't know about a rest API, but if you want to use CLI tools, the files are already stored in markdown format on your hard drive. I use CLI tools on my Obsidian files all the time.