You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

130 lines
4.8 KiB

8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
  1. XRay
  2. ====
  3. ## Discovering Content
  4. The contents of the URL is checked in the following order:
  5. * A supported silo URL (coming soon)
  6. * h-entry, h-event, h-card
  7. * OEmbed (coming soon)
  8. * OGP (coming soon)
  9. ## API
  10. To parse a page and return structured data for the contents of the page, simply pass a url to the parse route.
  11. ```
  12. GET /parse?url=https://aaronparecki.com/2016/01/16/11/
  13. ```
  14. To conditionally parse the page after first checking if it contains a link to a target URL, also include the target URL as a parameter. This is useful if using XRay to verify an incoming webmention.
  15. ```
  16. GET /parse?url=https://aaronparecki.com/2016/01/16/11/&target=http://poetica.com
  17. ```
  18. In both cases, the response will be a JSON object containing a key of "type". If there was an error, "type" will be set to the string "error", otherwise it will refer to the kind of content that was found at the URL, most often "entry".
  19. ### Error Response
  20. ```json
  21. {
  22. "error": "not_found",
  23. "error_description": "The URL provided was not found"
  24. }
  25. ```
  26. Other possible errors are listed below:
  27. * not_found: The URL provided was not found. (Returned 404 when fetching)
  28. * ssl_cert_error: There was an error validating the SSL certificate. This may happen if the SSL certificate has expired.
  29. * ssl_unsupported_cipher: The web server does not support any of the SSL ciphers known by the service.
  30. * timeout: The service timed out trying to connect to the URL.
  31. * invalid_content: The content at the URL was not valid. For example, providing a URL to an image will return this error.
  32. * no_link_found: The target link was not found on the page. When a target parameter is provided, this is the error that will be returned if the target could not be found on the page.
  33. * no_content: No usable content could be found at the given URL.
  34. ## Response Format
  35. ```json
  36. {
  37. "data": {
  38. "type": "entry",
  39. "author": {
  40. "type": "card",
  41. "name": "Aaron Parecki",
  42. "photo": "https://aaronparecki.com/images/aaronpk-256.jpg",
  43. "url": "https://aaronparecki.com/"
  44. },
  45. "url": "https://aaronparecki.com/2016/01/16/11/",
  46. "published": "2016-01-16T16:26:43-08:00",
  47. "photo": [
  48. "https://aaronparecki.com/2016/01/16/11/photo.png"
  49. ],
  50. "syndication": [
  51. "https://twitter.com/aaronpk/status/688518372170977280"
  52. ],
  53. "summary": "Now that @MozillaPersona is shutting down, the only good way to do email-based login is how @poetica does it.",
  54. "content": {
  55. "html": "Now that <a href=\"https://twitter.com/MozillaPersona\">@MozillaPersona</a> is shutting down, the only good way to do email-based login is how <a href=\"https://twitter.com/poetica\">@poetica</a> does it.",
  56. "text": "Now that @MozillaPersona is shutting down, the only good way to do email-based login is how @poetica does it."
  57. },
  58. }
  59. }
  60. ```
  61. If a property supports multiple values, it will always be returned as an array. The following properties support multiple values:
  62. * in-reply-to
  63. * syndication
  64. * photo (of entry, not of a card)
  65. The content will be an object that always contains a "text" property and may contain an "html" property if the source documented published HTML content. The "text" property must always be HTML escaped before displaying it as HTML, as it may include unescaped characters such as `<` and `>`.
  66. The author will always be set in the entry if available. The service follows the [authorship discovery](http://indiewebcamp.com/authorship) algorithm to try to find the author information elsewhere on the page if it is not inside the entry in the source document.
  67. All URLs provided in the output are absolute URLs. If the source document contains a relative URL, it will be resolved first.
  68. In a future version, replies, likes, reposts, etc. of this post will be included if they are listed on the page.
  69. ```json
  70. {
  71. "data": {
  72. "type": "entry",
  73. ...
  74. "like": [
  75. {
  76. "type": "cite",
  77. "author": {
  78. "type": "card",
  79. "name": "Thomas Dunlap",
  80. "photo": "https://s3-us-west-2.amazonaws.com/aaronparecki.com/twitter.com/9055c458a67762637c0071006b16c78f25cb610b224dbc98f48961d772faff4d.jpeg",
  81. "url": "https://twitter.com/spladow"
  82. },
  83. "url": "https://twitter.com/aaronpk/status/688518372170977280#favorited-by-16467582"
  84. }
  85. ],
  86. "comment": [
  87. {
  88. "type": "cite",
  89. "author": {
  90. "type": "card",
  91. "name": "Poetica",
  92. "photo": "https://s3-us-west-2.amazonaws.com/aaronparecki.com/twitter.com/192664bb706b2998ed42a50a860490b6aa1bb4926b458ba293b4578af599aa6f.png",
  93. "url": "http://poetica.com/"
  94. },
  95. "url": "https://twitter.com/poetica/status/689045331426803712",
  96. "published": "2016-01-18T03:23:03-08:00",
  97. "content": {
  98. "text": "@aaronpk @mozillapersona thanks very much! :)"
  99. }
  100. }
  101. ]
  102. }
  103. }
  104. ```