Socialwg/Social API/Identity to API endpoints
< Socialwg | Social API
This is rough pseudocode for discovering the "friends" API endpoint for a given URI.
let f = "http://example.com/social-api/friends" let u = the identity URI let p = protocol of u if p == "http" or p == "https" let hr = send a HEAD request to server for u if hr includes a Link: header for the f relation return the value of that header else let gr = send a GET request to the server for u if gr has content type "text/html" let ht = HTML.parse gr.body if ht includes a <link> element with rel = f return href of that <link> element else if ht includes an <a> element with rel = f return href of that <a> element else return null else if gr has content type "application/activity+json" let ao = JSON.parse gr.body return link-relation f from ao else if gr has content type "?" // Other discovery types here... else return null else if p == "acct" do Webfinger discovery of link relation f for identity u