Get widget locations in WordPress plugin

AFAIK there is no such function.

There is – or better was, since it is deprecated since 2.8.1; it is of course [sic!] still in use all over the place in core – the function wp_get_sidebars_widgets()source – which gives back an array of all sidebars with their widgets. So thinking long term you probably should use this one, although it’s used heavily in core.

Generally, take a look at the source link above. But to mention it here, there are other possibilities, like the globals $_wp_sidebars_widgets or $sidebars_widgets. And you can get the same information like this:

get_option('sidebars_widgets', array())

From there, so from the information of the globals $_wp_sidebars_widgets or $sidebars_widgets or the sidebar_widhets option, you have to do some kind of search on the array to receive back the according sidebar ids.