Parsing binary data from API

(flagged this under 'tidyverse' though the question is maybe tidy-adjacent in that it's httr related.)

So, the terrific httr vignette mentions that the sequence of bytes ("raw") from a server is "the highest fidelity way of saving files to disk" and goes on to suggest writeBin() without mentioning any subsequent read step to parse the data.

In my case, I'm accessing an API whose data is sent in binary format only, and I'm struggling a bit with how to decode it. The manual for the API defines the byte sequence response, eg "timestamp of 8 bytes of data in long integer format, followed by four byte string, followed by 4 byte single-precision float", and so on.

My question: Do I have to build my own parser for this kind of thing where I tediously decode each chunk of the string using rawToChar() or readBin() and the like?
Or is this a common problem that has been addressed elsewhere with an opinionated method?

And thank you for this forum.

httr::content does a pretty good job of parsing whatever you throw at it in my experience, but I'm sure it's possible to feed it something it won't like. Is there a way to make a reasonably minimal reprex (tidyverse; SO)?


So, I do have to parse it myself, and the Best Practices for API Packages vignette was just what the Dr ordered.