
TL;DR: Most websites expose REST APIs that power their UI -- but these same APIs can be called directly from Python scripts to automate tasks. Using the
requestsmodule, you can build scripts that monitor bitcoin/product prices, fetch images from Nat Geo's photo of the day, and even set them as your desktop background. This post introduces the concept and walks through practical automation examples.
Automate Rest API tasks using python requests module.
Many websites use rest APIs to interact with their backend, (Others may use sockets or GRPC or something else). UI is a simple way to interact with Rest APIs ( simple to interact for a normal user ).
There are other ways these APIs can be used. They can be invoked directly from python(or any other language) scripts.
An API can be used to fetch some data or trigger some operation at server. I am listing down some examples, where I have used Rest APIs to automate some tasks.
- Monitor bitcoin price or price of any item on shopping website.
- Fetch images from nat geo photo of the day page and set it as desktop background.