Random Images from API with python


Close up of grey cat with blue eyes

By T. McDonald | 2/07/19
You may have heard of API’s and wondered what you can do with them. This is a simple but satisfying use of this powerful technology.

What is API?

Application programming interface.

What does it do?

An API will allow communication between two applications. The API I am using is a publicly available web-based API , which returns data as in JSON or XML.  In other words, I send a message to a stated website and request some data, in this case images are then returned to me. 


Using python 2 is a little different in the coding. 



It is worth noting that the ['file'] at the end of json.loads() may be different in the website you are connecting to.  I connected to randomcat.com
 
Hope you enjoyed this quick blog.  Please leave a comment below. 

Comments