Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

An API endpoint to fetch the profile pic of a user OR organization based on the username alone #10132

Closed
Booligoosh opened this issue Sep 1, 2020 · 6 comments
Assignees
Labels
area: API api or request related issues external contributors welcome contribution is welcome!

Comments

@Booligoosh
Copy link

Booligoosh commented Sep 1, 2020

Is your feature request related to a problem? Please describe.
I want to get an avatar URL based on a dev.to username. Since a username can be either for an organization or a user, there is currently no way to do this.

For user profile pics, I can get the profile pic by requesting https://dev.to/api/users/by_username?url=<username>. However, there is no corresponding endpoint for organizations at the moment (see #9212).

But even if this endpoint did exist, there would still be no way to get the profile pic from username alone, unless you made two requests, one to the organization endpoint and one to the the user endpoint, and then checked which returned a response.

Describe the solution you'd like
Some endpoint along the lines of /api/profile_pic/by_username?url=<username> that works with both organization and user usernames.

It could also be an endpoint like /api/profile_info/by_username?url=<username> which returns basic profile info fields shared across users and organizations such as name, profile pic and location (this would be the preferred functionality).

Describe alternatives you've considered
At the moment, I'm just fetching /api/users/by_username?url=<username> and if a 404 is returned, I just display a fallback image.

Note that you can get organization profile pics at the moment if you have the URL of a post, since the articles endpoint returns the organization info as well as user info, but that only works if you know one of the organization's article URLs.

Additional context

N/A

@github-actions
Copy link
Contributor

github-actions bot commented Sep 1, 2020

Thanks for the issue! We'll take your request into consideration and follow up if we decide to tackle this issue.

To our amazing contributors: issues labeled type: bug are always up for grabs, but for feature requests, please wait until we add a ready for dev before starting to work on it.

To claim an issue to work on, please leave a comment. If you've claimed the issue and need help, please ping @forem/oss and we will follow up within 3 business days.

For full info on how to contribute, please check out our contributors guide.

@Booligoosh Booligoosh changed the title An endpoint to fetch the profile pic of a user OR organization based on the username alone An API endpoint to fetch the profile pic of a user OR organization based on the username alone Sep 1, 2020
@rhymes rhymes added area: API api or request related issues tech: ruby labels Sep 1, 2020
@rhymes
Copy link
Contributor

rhymes commented Oct 1, 2020

I think we should add a /profile-pictures/{username} endpoint to the API to solve this

@diogoosorio
Copy link
Contributor

Seems simple enough, I can pick this one up! 👍

@fdocr
Copy link
Contributor

fdocr commented Oct 1, 2020

Thank you @diogoosorio I just assigned the issue to you

@ankiiitraj
Copy link

Hello, I'm new here, this seems an easy task for me to get started. Let me know if I can work on it! 😃

@rhymes
Copy link
Contributor

rhymes commented Oct 2, 2020

@ankiiitraj, thanks for offering, @diogoosorio already claimed this PR but you're welcome to choose any other issue :) You can take a lok at the rest of the hacktoberfest pool or those tagged with difficulty: easy as well

Thank you!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area: API api or request related issues external contributors welcome contribution is welcome!
Projects
None yet
Development

No branches or pull requests

7 participants