1๐
โ
If this is an internal API โ that is, you/your views and the API have the same access to resources โ why are you consuming the API rather than getting its results normally (through model manipulation, etc)? If you want to avoid code duplication, break out common code into separate functions that can be used by both processes.
If this is an external API โ for example, your site is communicating with BitBucket โ an HTTP client is about the only (sane) way to go about consuming it. Though I personally would choose httplib over urllib.
๐คeternicode
Source:stackexchange.com