January 2020
Intermediate to advanced
532 pages
13h 31m
English
Given a story ID, we can retrieve information about the story using the item endpoint of the Hacker News API. Before we write the function, let's define a type to store the data:
struct Story by::String descendants::Union{Nothing,Int} score::Int time::Int id::Int title::String kids::Union{Nothing,Vector{Int}} url::Union{Nothing,String}end
The fields of a Story are designed according to the JSON schema documented on the Hacker News API website. Sometimes, a field may be unavailable for certain story types, in which case we will leave them as nothing in the object. These optional fields include descendants, kids, and url. Lastly, every story comes with a unique identifier id.
We need a constructor to create ...
Read now
Unlock full access