Building a Customer API Wrapper with RandomUser

This mini-project involves creating a lightweight customer API wrapper using the RandomUser API for a fake use case. The goal is to design a Python class that retrieves customer data while incorporating data validation and transformation.

Key Features:

  • Developed a class with a get_customers method to fetch customer data.
  • Allowed users to specify the number of customers (default: n=100).
  • Made API calls via GET requests.
  • Validated the response using Pydantic to ensure data integrity.
  • Transformed the API output into a pandas DataFrame for easy analysis.

Time to complete: Took ~1 day.

Customers.py

Script that fetches customer data from the RandomUser API, validates it using Pydantic, converts it into a pandas DataFrame, and saves it as a CSV file.

schema.py

Defines Pydantic models for validating and structuring customer data, including name, location, birthdate, and picture information, based on the RandomUser API response.