Hi,
Regarding libraries your main controllers of interest are:
libraries,
library_contents,
folders, folder_contents -
please beware that folders API is considered work-in-progress and will probably be deprecated in future releases.
As of your error make sure that your local Galaxy, that you are trying to connect to via API, runs on the 4096 port that you specified for the script (by default local Galaxy runs at port 8080 - see universe_wsgi.ini for config changes).
Thank you for using Galaxy and let us know how it goes!
Martin, Galaxy Team