SP provides a set of Ruby classes as a layer between the scripts and the low-level API.
Generated RDoc documentation.
These classes are however not properly documented yet, you can try looking at the source file data/script/SP/sp.rb.