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 : (is an user page) (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 : and

How would you suggest me to implement this ?

Would it be the following are equivalent ? :

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.