generate_url function

Generate URL for specific API query by type and (if appropriate) ID