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.

115 lines
4.3 KiB

  1. Percolator
  2. ==========
  3. API
  4. ---
  5. To parse a page and return structured data for the contents of the page, simply pass a url to the parse route.
  6. ```
  7. GET /parse?url=https://aaronparecki.com/2016/01/16/11/
  8. ```
  9. 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 Percolator to verify an incoming webmention.
  10. ```
  11. GET /parse?url=https://aaronparecki.com/2016/01/16/11/&target=http://poetica.com
  12. ```
  13. 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".
  14. ### Error Response
  15. ```json
  16. {
  17. "type": "error",
  18. "code": "not_found",
  19. "summary": "The URL provided was not found"
  20. }
  21. ```
  22. Other possible errors are listed below:
  23. * not_found: The URL provided was not found. (Returned 404 when fetching)
  24. * invalid_ssl: There was an error validating the SSL certificate. This may happen if the SSL certificate has expired, or was signed by a root authority not recognized by this service.
  25. * timeout: The service timed out trying to connect to the URL.
  26. * invalid_content: The content at the URL was not valid. For example, providing a URL to an image will return this error.
  27. * 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.
  28. Response Format
  29. ---------------
  30. ```json
  31. {
  32. "type": "entry",
  33. "author": {
  34. "type": "card",
  35. "name": "Aaron Parecki",
  36. "photo": "https://aaronparecki.com/images/aaronpk-256.jpg",
  37. "url": "https://aaronparecki.com/"
  38. },
  39. "url": "https://aaronparecki.com/2016/01/16/11/",
  40. "published": "2016-01-16T16:26:43-08:00",
  41. "photo": [
  42. "https://aaronparecki.com/2016/01/16/11/photo.png"
  43. ],
  44. "syndication": [
  45. "https://twitter.com/aaronpk/status/688518372170977280"
  46. ],
  47. "summary": "Now that @MozillaPersona is shutting down, the only good way to do email-based login is how @poetica does it.",
  48. "content": {
  49. "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.",
  50. "text": "Now that @MozillaPersona is shutting down, the only good way to do email-based login is how @poetica does it."
  51. },
  52. }
  53. ```
  54. If a property supports multiple values, it will always be returned as an array. The following properties support multiple values:
  55. * in-reply-to
  56. * syndication
  57. * photo (of entry, not of a card)
  58. 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 `>`.
  59. 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.
  60. Replies, likes, reposts, etc. of this post will be included if they are listed on the page.
  61. ```json
  62. {
  63. "type": "entry",
  64. ...
  65. "like": [
  66. {
  67. "type": "cite",
  68. "author": {
  69. "type": "card",
  70. "name": "Thomas Dunlap",
  71. "photo": "https://s3-us-west-2.amazonaws.com/aaronparecki.com/twitter.com/9055c458a67762637c0071006b16c78f25cb610b224dbc98f48961d772faff4d.jpeg",
  72. "url": "https://twitter.com/spladow"
  73. },
  74. "url": "https://twitter.com/aaronpk/status/688518372170977280#favorited-by-16467582"
  75. }
  76. ],
  77. "comment": [
  78. {
  79. "type": "cite",
  80. "author": {
  81. "type": "card",
  82. "name": "Poetica",
  83. "photo": "https://s3-us-west-2.amazonaws.com/aaronparecki.com/twitter.com/192664bb706b2998ed42a50a860490b6aa1bb4926b458ba293b4578af599aa6f.png",
  84. "url": "http://poetica.com/"
  85. },
  86. "url": "https://twitter.com/poetica/status/689045331426803712",
  87. "published": "2016-01-18T03:23:03-08:00",
  88. "content": {
  89. "text": "@aaronpk @mozillapersona thanks very much! :)"
  90. }
  91. }
  92. ]
  93. }
  94. ```