Skip to content

Sushant1-oops/Python-API-Request-Handling

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 

Repository files navigation

API Data Fetch and Filtering Task

This project is a simple Python program that demonstrates how to work with public APIs using the GET method. It retrieves user data from a public API, displays it in a structured format, filters specific users based on a condition, and handles possible errors.

The program uses the requests library to fetch data from the following public API endpoint: https://jsonplaceholder.typicode.com/users

It first prints details of all users and then displays only those whose city name starts with the letter 'S'. If no such user exists, it shows an appropriate message. The script also handles cases where the API fails to respond or returns an empty list.

The following details are displayed for each user:

  • Name
  • Username
  • Email
  • City (from address.city)

The output format is simple and readable, for example:

User 1:
Name: Leanne Graham
Username: Bret
Email: Sincere@april.biz
City: Gwenborough

If there are no users whose city starts with ‘S’, the program prints:
No users found with city starting with 'S'.

To run the program:

  1. Make sure Python 3 is installed on your system.
  2. Install the requests library if not already installed using: pip install requests
  3. Save the Python file as api_request.py.
  4. Open the terminal in the same directory and run: python api_request.py

The program will then fetch the data from the API, print all user details, and display filtered results if applicable. It also provides clear error messages in case of a failed API response or empty data.

This project is part of an internship task designed to demonstrate the ability to:

  • Use API calls with the GET method
  • Handle and parse JSON data
  • Loop through data and print selected fields
  • Apply filtering logic
  • Implement error handling

Author: Sushant Thakur
B.Tech Student, Delhi Technical Campus (GGSIPU)

About

This is my task related to python development Internship .This project is a simple Python program that demonstrates how to work with public APIs using the GET method. It retrieves user data from a public API, displays it in a structured format, filters specific users based on a condition, and handles possible errors.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages