you can only set a community to only allow local users, not prevent users from interacting with remote communities.
you’d have to either disable federation or set up a script to automatically remove all remote communities, but that also won’t be a per user thing, just a per instance thing.
you can find your user info in the
/api/v3/site
response. the/api/v3/user
endpoint requires a name or person id.i recommend checking out https://join-lemmy.org/api/classes/LemmyHttp.html