Package: webfinger
A simple Python client implementation ofWebFinger RFC 7033.WebFinger is a discovery protocol that allows you to find information about people or things in a standardized way. See thespecorwebfinger.netfor more information.>>> from webfinger import finger
>>> wf = finger('acct:eric@konklone.com')
>>> wf.subject
acct:eric@konklone.com
>>> wf.avatar
https://secure.gravatar.com/avatar/ac3399caecce27cb19d381f61124539e.jpg?s=400
>>> wf.profile
https://konklone.com
>>> wf.properties.get('http://schema.org/name')
Eric Millfingerfinger(resource, rel=None)fingeris a convenience method for instantiating a WebFingerClient object and making the request. Theresourceparameter is a URI of the resource about which you are querying. The optionalrelparameter can be either a string or a list of strings that will limit the response to the specific relations. WebFinger servers arenotrequired to obey therelparameter, so you should handle the response accordingly.WebFingerClient supports additional options, so check that out iffingerdoes not meet your needs.WebFinger ClientWebFingerClient(timeout=None, official=False)Instantiates a client object. The optionaltimeoutparameter specifies the HTTP request timeout. The optionalofficialparameter is a boolean that determines if the client will useunofficial endpoints.finger(resource, host=None, rel=None, raw=False)The clientfingermethod prepares and executes the WebFinger request.resourceandrelare the same as the parameters on the standalonefingermethod.hostshould only be specified if you want to connect to a host other than the host in the resource parameter. Otherwise, this method extracts the host from theresourceparameter.rawis a boolean that determines if the method returns a WebFingerResponse object or the raw JRD response as a dict.If thehostparameter is passed to this method, unofficial endpoints are ignored. You’re asking for a specific host so who am I to disagree?WebFinger ResponseThe WebFinger response object provides handy properties for easy access and the raw JRD response. Read thespec for specifics of the JRD response.PropertiessubjectThe URI of the thing that the response JRD describes.aliasesA list of additional URIs that identify the subject.propertiesA dict of URIs and values that provides information about the subject.linksA list of dicts that define external resources for the subject.jrdA dict of the raw JRD response.Methodsrel(relation, attr=’href’)A convenience method that provides basic access to links. Therelationparameter is a URI for the desired link. Theattrparameter is the key of the returned value of the link that matchesrelation. Returns a string ifrelationandattrexist, otherwiseNone.>>> wf.rel('http://webfinger.net/rel/avatar')
https://secure.gravatar.com/avatar/ac3399caecce27cb19d381f61124539e.jpg?s=400The response JRD may have multiple entries with the same relation URI. Therelmethod will select the first one, since order is meant to imply priority. If you need to see all of the values, you’ll have to iterate over thelinksproperty and pull them out yourself.>>> rel = 'http://webfinger.net/rel/avatar'
>>> [l.get('href') for l in rel.links if l.get('rel') == rel]Ifattris None, the full dict for the link will be returned.Relation PropertiesThe following common link relation types are supported as properties of the response object:activity_streams:http://activitystrea.ms/spec/1.0avatar:http://webfinger.net/rel/avatarhcard:http://microformats.org/profile/hcardopen_id:http://specs.openid.net/auth/2.0/provideropensocial:http://ns.opensocial.org/2008/opensocial/activitystreamsportable_contacts:http://portablecontacts.net/spec/1.0profile:http://webfinger.net/rel/profile-pagewebfist:http://webfist.org/spec/relxfn:http://gmpg.org/xfn/11Example:>>> wf.avatar
https://secure.gravatar.com/avatar/ac3399caecce27cb19d381f61124539e.jpg?s=400Unofficial EndpointsWhile Facebook and Twitter do not officially support WebFinger, thewebfinger-unofficial projectprovides a proxy for basic subject information. By default, python-webfinger will attempt to use unoffical the endpoints for facebook.com and twitter.com resource domains. This behavior can be disabled by passingTrueto theofficialparameter:>>> wf = finger('acct:konklone@twitter.com', official=True)DependenciesrequestsLicensepython-webfinger is distributed under theBSD license.See LICENSE for the full terms.