obsidian-api-request
obsidian-api-request copied to clipboard
FR: Preventing repeated requests to the API
Is your feature request related to a problem? Please describe. Many API's are rate limited by tier or cost each time it is used. The plugin sends a request out to the API each time the page is loaded regardless if there is need to update the data itself.
Describe the solution you'd like Few options that would work to limit repeat calls.
-
Offer a setting that will automatically call the API if N amount of time has passed since the last call. This would require storing the last request time in some way, could be done with a custom defined property within the code block. If there is nothing in the file property for that custom name then call the api. If a datetime is stored there compare the time difference between than and now, evaluate as stated in the codeblock. The Period could be defined in the codeblock as is in ISO8601 (https://en.wikipedia.org/wiki/ISO_8601#Durations)
-
Offer a setting to be used in the code block that will present a button in Obsidian labeled "Refresh", or "Recall", or better yet have the text customizable. Offering the same custom defined property in the code block as above to store when the API was last called could be helpful as it can be used to present to the user how old the data is.
I think the second option would probably be simpler to implement and be good enough for most use cases.
Describe alternatives you've considered Only alternative solution I can think of is running a reverse proxy locally with lots of caching to prevent repeated api requests (I have done this in the past for a different use case)