API endpoint for searching file content?

Hi all, I’m playing around with making an Obsidian plugin, but I’ve run into a gap in my understanding.

Does anyone know of an API endpoint for searching file content programatically? I’ve seen a couple of plugin authors sneak into the ‘global-search’ plugin to initiate a UI search, but I don’t see any way of initiating a query from JavaScript and getting the results as a JavaScript object.

My use case is that I want a way to execute a search and then render the results differently – sorting by matched line rather than grouping by file. This would be useful for e.g. sorting task lines by title or due date. My strategy right now is to use a custom code block (like the recently-added query block).

I don’t mind manually iterating through the notes in the vault, but I’d rather make use of the existing search engine (with its syntax, knowledge about tags and metadata, etc.) if possible.

3 Likes

If someone ever finds the answer for this. Let me know. I to want to query date (in this caste text) from Obsidian to send it to an external app. I could do this using a Cronjob with a grep command but I want to bundle it as a plugin.

This is also something I’m interested in.

@Craig Where did you find examples of plugin’s sneaking around like that? I’ve just starting looking at plugin source this weekend and haven’t found anything like that.

I know the Text Expand plugin does this.

Thanks NomarClub! Yes, the text expand plugin was one of them – all the ones I found used a similar strategy.