With the external Data API you can't read the actual opend note as it is not possible to read out which note is currently open, but with the Plugin API this is possible.
const slectedNote = await joplin.workspace.selectedNote();