Preferences

I didn't see any API offered anywhere (which I would definitely love), so I decided to poke around. https://apirank.dev/__data.json will return paged data sources (query param ?p={pageNum}), and what really caught my interest here was how the data came in.

A sample response takes this form: `{ type: 'data', nodes: [ { type: 'data', data: [Array], uses: [Object] }, ... ] }`

Things get a little strange (for me at least!) when I start poking around in the data array. At index 0 in this array is an object with some information on what I think is mostly just paging and the length of the data array (sans this first element). At index 1 is an array filled with numbers that correspond to array indices in the initial data array, and the objects at those specified indices are the actual data sources. While the keys in those objects are actual descriptors of relevant information, the VALUES for those keys are also array indices. Essentially the incoming data structure is a super flattened array with some objects/ additional arrays that just point to other indices in the data array.[1]

Is there a name for this type of pattern? Is it just an artifact of using some query library to handle data fetching? Apologies for the naivety, I still consider myself a fairly new dev (especially when I see something like this!).

[1] More complete example (not sure if I explained this well):

  {
    type: 'data',  
    data: [  
      { endpoints: 1, count: 3971, currentPage: 5 },
      [2,221,355,...], // at array index 2 we should expect an object
      { id: 3, commentsRatio: 4, owaspIssues: 6, ... }, // array index 2: object with values that are all indices in the original data array that hold the actual values!
      ...
    ]
  }

This item has no comments currently.

Keyboard Shortcuts

Story Lists

j
Next story
k
Previous story
Shift+j
Last story
Shift+k
First story
o Enter
Go to story URL
c
Go to comments
u
Go to author

Navigation

Shift+t
Go to top stories
Shift+n
Go to new stories
Shift+b
Go to best stories
Shift+a
Go to Ask HN
Shift+s
Go to Show HN

Miscellaneous

?
Show this modal