Getting avatar URLs for use externally

I would like to display user avatars from a Discord I host on another part of my site. What’s the recommended way of doing this?

I see that the path to the avatar is at user.avatar_template in the JSON returned by /u/{username}.json, but I get CORS errors when I request data from that endpoint via JavaScript in the browser. I tried to create a service I can call from JavaScript which makes requests to Discourse’s JSON API for me, and that worked up to a point. On pages which load many avatars, the service starts to get 429 errors from Discourse before I have all the JSON. (The page I’m trying to build might need to display quite a few avatars, 60+ in one case.)

These approaches seem like they won’t succeed; what’s an alternative that would?

1 Like