- This python script fetches and displays random book data using the Free API from api.freeapi.app in CLI/TERMINAL.
- It's designed for quick demos and learning purposes around API consumption.
- Retrieves random books info
- Shows book name, published date, author, etag, book-id
- Includes basic error handling for connection issues
- Python 3.x (x = 9 or 9+)
- requests library (
pip install requests
)
- Run the script with:
python script_name.py
(Replacescript_name.py
with your actual filename) - The script will print random book information from the API.
- If the API fails or internet is unavailable, an exception is raised:
"failed, to fetch book data "
- Source: FreeAPI – https://api.freeapi.app
- Endpoint:
https://api.freeapi.app/api/v1/public/stocks/stock/random
- This is a demo API and the data is randomly generated for learning/testing.

A minimal and practical script created to demonstrate how to consume REST APIs in Python using the requests module.