Github API v3 : deduce api repos endpoint from html url

I’m writing a script that retrieve data from a  provided GitHub (html) URL as :

https://github.com/shumatech (is an user page)

https://github.com/RocketChat (is an org page)

My problem is I can’t deduce the API endpoint to repos automatically because the url scheme depends on if it’s an org or an user ; respectively : https://api.github.com/users/shumatech/repos and https://api.github.com/orgs/RocketChat/repos

How would you suggest me to implement this ?

Would it be the following are equivalent ? :

https://api.github.com/users/RocketChat/repos

https://api.github.com/orgs/RocketChat/repos

It *seems* to return the same data (but different order). Are orgs and users unique to GitHub ?

You could always do a quick call to the Get an organization endpoint to determine if it is a user or organization before querying further.