Scripting Documentation

Sorry if this is a newbie question that I should be able to answer from the documentation, but I get the impression that Logseq can run arbitrary clojure code from within a block (page?), which I’d like to do in order to run some statistical analysis on information drawn from a set of notes. I can’t find the documentation (1) on how to do this ie where does one save the code and how is it invoked; and (2) the API for navigating between notes and extracting properties (I want to compare before and after values, held in separate, but linked, notes).

Any pointers gratefully received.!