# API call to have a user watch specific category(ies)?

**URL:** <https://meta.discourse.org/t/api-call-to-have-a-user-watch-specific-category-ies/67450>\
**Category:** Development\
**Created:** [2017 年8 月 4 日 13:02 UTC](https://meta.discourse.org/t/api-call-to-have-a-user-watch-specific-category-ies/67450 "2017-08-04T13:02:51Z")\
**Posts on this page:** 1\
**Showing post:** 6

<div class="post-metadata">

作者： ![kgoetz](https://avatars.discourse-cdn.com/v4/letter/k/bb73d2/32.png) [@kgoetz](https://meta.discourse.org/u/kgoetz)\
发布日期： [2017 年10 月 17 日 04:35 UTC](https://meta.discourse.org/t/api-call-to-have-a-user-watch-specific-category-ies/67450/6 "2017-10-17T04:35:45Z")

</div>

I’m sure @Osama’s method works, but setting user watches via the category seemed a bit weird to me. The following sets the watch list directly against the user (This is via python requests, but shows what is required).

DISCOURSE\_URL - domain, including http(s)  
username - user to change  
DISCOURSE\_API\_KEY - api key generated by, and associated with a user  
DISCOURSE\_API\_USERNAME - user who the key is associated with  
watch\_category - a list of categories the user should be watching

> requests.request(‘PUT’, ‘{0}/u/{1}.json’.format(DISCOURSE\_URL, username), allow\_redirects=False, params={“api\_key”:DISCOURSE\_API\_KEY, “api\_username”: DISCOURSE\_API\_USERNAME}, json={‘watched\_category\_ids’: [watch\_category]}, headers={‘Accept’: ‘application/json; charset=utf-8’})

@SwisherSweet if you end up opening a bug against the docs for missing info on how to modify the watch list/user prefs do post back here with it.

---

_[View the full topic](https://meta.discourse.org/t/api-call-to-have-a-user-watch-specific-category-ies/67450)._
