Is it possible to access URL parameters, e.g. http://octoprint.local/?myPluginParam=foobar
within a plugin?
You mean from the python side? Context of the question may be helpful.
Yes on the python side. I want to pass a parameter to the plugin via the URL. To be specific without the detour over JavaScript.
You may have a look on this plugin how it can work:
You're probably looking for something like route hooks. It allows you to redirect specific paths to your plugin side.
https://docs.octoprint.org/en/master/plugins/hooks.html#octoprint-server-http-routes
An example of its usage can be seen here in my Thumbnail plugin. I believe part of that callback will pass request object as a kwarg which you could get the parameters from, but don't quote me on that.
Another possible option is using SimpleApiPlugin mixin and using a get request. An example of that option can be seen here in my BLVLogger plugin.
You might have to explain the use of this a bit more. If you want to know the URL parameters when the core UI is loaded, then there is a different method vs. what has already been shown, a custom path that you can pass query params to.
I am struggling to see the need for finding query parameters when the UI is loaded, so a clearer explanation of why you need access to that would help.
I don't want to discuss if I need this, I just wanted to know if it is possible. Because clients must be registered on the backend to receive data updates I thought it might. But I guess the answer is no. Therefore it looks like I have to get the parameter on the frontend and send it to an API endpoint on the backend. Thanks.