split out url generation into separate functions

Use urlencode to generate API request urls

While I think this is cleaner, it probably sacrifices something for a simple newbie tutorial...
So maybe for a separate branch or just reject the PR, it won't hurt my feelings, just dumping code here