I actually do, yes.
category_notifications = {'muted_category_ids': [54],
'regular_category_ids': [],
'tracked_category_ids': [],
'watched_category_ids': [],
'watched_first_post_category_ids': [61],
}
api(config, f"u/{username}.json", method='put',
json=category_notifications)
… where api() is a thin wrapper around the Requests python module and just does an HTTP PUT to /u/whateverusernameyouarechanging.json on your Discourse site, and the payload is just the categories you want changed. (You can skip any ones you don’t want to change.)
Note that you need the numeric category IDs — names won’t work. And of course if you want to merge or preserve what’s there already you’ll have to read the user first.