Improved
New API response format
over 2 years ago by Mark Healey
Versions 0.16.0 (beta) and 0.17.0 represent the introduction of a new API response format for the Taffrail API.
This is entirely opt-in right now. Some details are below.
Advice API JSON
In V1 (anything prior to 0.16.0), the API responds with a single advice[] array containing the stack of "display nodes" in the order our Engine sees them.
In V2, the API relies on this same "display node" collection, but the API returns new subsets of the data instead of a singular advice[] array that needs to be filtered client-side.
Replaced advice[] with:
advice[] with:advice[]- collection of "regular" advice (basically any Advice node without atypetag specified)assumptions[]- collection of Advice nodes tagged asassumptiontypecurrentFocus{input request}- current location where API is stuck, i.e., the last unanswered question. If all questions are answered, this field disappears.examples[]- collection of Advice nodes tagged asexampletypeinputRequests[]- collection of Input Request nodes- Each item now has two additional properties:
index (int)- literally the index of the item in the arraybacklink{}- the id, name, and value of the variable linked to the input request. This is currently looked up every time client-side.
- Each item now has two additional properties:
opengraph{}- object containing open graph data for link previews, search engines, etc. The data is sourced from the first Advice node (the primary recommendation/main heading)sources[]- combined list of all AdviceSet and Input Request and Advice reference documents, de-duplicated
Overhauled Sources (referenceDocuments[])
referenceDocuments[])- Added
fileIdproperty to all types - For any non-
linkor non-filetypes, no changes - For
files:- Removed
bodyif NULL - Add
sizeFormattedusing the Numeral library - Add
displayUrl, e.g.,View file (pdf), 1.2mbwhich helps with consistency when building lists of links when some are files
- Removed
- For
links:- Removed
size - Removed
versionId - Changed
contentTypefromtext/plaintotext/x-uri - Added
url_isCanonicalif the OG scraper found one - Added
displayUrlwhich is the URL without the protocol and host prefix
- Removed
Removed
- Remove
audienceType(root level), it is no longer in use
HTML rendering
- Any Markdown table elements will automatically have
class="taffrail-table"added to the markup - Any Markdown blockquote elements will have
class="taffrail-blockquote"added to the markup
