Can the API return the topic's original author?

(Keith) #1

We’re creating featured tiles on my community: and I’d love to include the name of the original topic creator on the tile, however we seem to only be able to get the “last_power_username” which isn’t quite what we’re looking for…

Is it possible to query the original author’s name?

(Erick Guan) #2

How you made those tiles? Plugin or? And where did you find last_power_username?

(cpradio) #3

It would help if we knew what API call you were making, as if you call out to the topic.json, you can easily get that information (under details.created_by).

(Yegor) #4

Hello everyone!
I’m actually the guy who programmed the stuff for Keith (topicstarter).

@cpradio, thanks, at this moment I’ve ended up using the /t/{id}.json API call, but anyway…

This means, that I’ll need to make 8 separate (if I have 8 tiles) API requests to get the author username for each thread. Which takes more time…

To get the threadlist for our tiles I’ve used the /c/{id}.json call. Which has topic_lists.topics object in the response.

I can’t understand why didn’t Discourse put the topicstarter username in each topic object? I don’t think that this is something complicated :smiley: We have the “last_poster_username”, but don’t have the “topic_starter_username” there. Why?

(cpradio) #5

Wait… so when I load

I see a users section at the very top and then for each topic I see something similar to

"topics": [
    "id": 46837,
    "title": "Can the API return the topic's original author?",
    "fancy_title": "Can the API return the topic’s original author?",
    "slug": "can-the-api-return-the-topics-original-author",
    "posts_count": 4,
    "reply_count": 0,
    "highest_post_number": 4,
    "image_url": null,
    "created_at": "2016-07-05T07:52:03.351Z",
    "last_posted_at": "2016-07-16T11:56:33.660Z",
    "bumped": true,
    "bumped_at": "2016-07-16T11:56:33.660Z",
    "unseen": false,
    "last_read_post_number": 4,
    "unread": 0,
    "new_posts": 0,
    "pinned": false,
    "unpinned": null,
    "visible": true,
    "closed": false,
    "archived": false,
    "notification_level": 3,
    "bookmarked": false,
    "liked": false,
    "views": 120,
    "like_count": 6,
    "has_summary": false,
    "archetype": "regular",
    "last_poster_username": "Yegor",
    "category_id": 6,
    "pinned_globally": false,
    "tags": [
    "has_accepted_answer": false,
    "posters": [
        "extras": null,
        "description": "Original Poster",
        "user_id": 19898
        "extras": null,
        "description": "Frequent Poster",
        "user_id": 8810
        "extras": null,
        "description": "Frequent Poster",
        "user_id": 8300
        "extras": "latest",
        "description": "Most Recent Poster",
        "user_id": 22733

There is a poster’s section for each topic, that has one with the description of ‘Original Poster’, which identifies with a user id in the users section. Is that not what you need?

Sample of users section

"users": [
    "id": 19898,
    "username": "keith1",
    "avatar_template": "https: //{   size }.png"
    "id": 8810,
    "username": "fantasticfears",
    "avatar_template": "/user_avatar/{   size }/51902_1.png"
    "id": 8300,
    "username": "cpradio",
    "avatar_template": "/user_avatar/{   size }/4970_1.png"

(Yegor) #6

Wow, I should have digged more… Thanks, this looks like it! I’ll test it soon :slight_smile:

(Yegor) #7

Yeah, changed the things with success :smiley: Thanks again.