README.rst 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. ========
  2. hostmeta
  3. ========
  4. A simple Python client implementation of `Web Host Metadata RFC 6415 <https://tools.ietf.org/html/rfc6415>`_.
  5. Web Host Metadata is a discovery protocol that allows you to find information about endpoints on a webserver host, given that you have a hostname to look up, in a standardized way. See the `spec <https://tools.ietf.org/html/rfc6415>`_ for more information.
  6. Basic usage::
  7. >>> from hostmeta import get_host_meta
  8. >>> hm = get_host_meta('social.umeahackerspace.se')
  9. >>> len(hm.link)
  10. 6
  11. >>> hm.find_link('http://apinamespace.org/oauth/request_token').href
  12. 'https://social.umeahackerspace.se/api/oauth/request_token'
  13. >>>
  14. >>> wf_url = hm.webfinger.apply_template('acct:mmn@social.umeahackerspace.se')
  15. >>> wf_url
  16. 'https://social.umeahackerspace.se/.well-known/webfinger?resource=acct%3Ammn%40social.umeahackerspace.se'
  17. >>> import rd
  18. >>> wf = rd.loads(requests.get(wf_url, headers={'Content-Type': hm.webfinger.type}).text, hm.webfinger.type)
  19. >>> wf.find_link('describedby').href
  20. 'https://social.umeahackerspace.se/mmn/foaf'
  21. get_host_meta
  22. =============
  23. get_host_meta(host, scheme='https')
  24. *get_host_meta* will lookup a certain host with the optionally specific scheme. The *host* parameter is a fully qualifiable domain name. The optional *scheme* parameter lets you override the default policy of connecting using HTTPS.
  25. Dependencies
  26. ============
  27. * `requests <https://pypi.python.org/pypi/requests>`_
  28. License
  29. =======
  30. python-hostmeta is distributed under the `BSD license <http://creativecommons.org/licenses/BSD/>`_.
  31. See LICENSE for the full terms.