Skip to content

A FastAPI project for managing ZIP code queries with ViaCEP API, MongoDB storage, and data export options (JSON/CSV). Includes CRUD operations, duplicate prevention, and robust validation. Ideal for integrating address lookup and management into apps efficiently. πŸš€

License

Notifications You must be signed in to change notification settings

petersonchiquetto/ZIP_Code_Lookup

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

10 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

πŸ“ ZIP Code Lookup - FastAPI Project

This project was developed to offer a complete service for querying, managing, and exporting ZIP codes, using Python, FastAPI, and MongoDB.

🎯 Goal

Develop a system that:

  • ZIP Code Lookup: Allows searching for ZIP codes using the ViaCEP API.
  • Storage: Saves query results in a MongoDB database.
  • Export: Provides the option to export data in JSON or CSV formats.
  • CRUD Operations: Implements CRUD operations (Create, Read, Update, and Delete) to manage stored data.

✨ Features

  1. ZIP Code Lookup πŸ”

    • Search ZIP codes by state and specific ZIP code.
    • Utilizes the ViaCEP API to fetch data.
    • Includes validation to ensure integrity and handle errors effectively.
  2. Storage in MongoDB πŸ—‚οΈ

    • Saves query data in MongoDB.
    • Prevents duplication by verifying records before saving.
  3. Data Export πŸ“€

    • Stored data can be exported as:
      • JSON: Structured for integration or API usage.
      • CSV: For data analysis or spreadsheet manipulation.
  4. CRUD Operations πŸ”§

    • Create: Manually add a ZIP code record.
    • Read: List all stored ZIP codes.
    • Update: Update data for a specific ZIP code.
    • Delete: Remove unwanted records.

πŸ› οΈ Technologies Used

  • Python 🐍: Main programming language.
  • FastAPI ⚑: Framework for API development.
  • MongoDB πŸƒ: NoSQL database for storage.
  • ViaCEP API πŸ“‘: Service for ZIP code lookup.
  • Postman πŸ“¬: Tool for endpoint testing and validation.

πŸ“š Additional Libraries

  • pymongo: MongoDB connection.
  • csv, json: Data manipulation and export.
  • requests: External API consumption.

πŸš€ Installation

Clone the repository:

git clone https://github.com/your-username/zip-code-lookup.git  
cd zip-code-lookup  

Install dependencies:

pip install -r requirements.txt  

Configure MongoDB:

Ensure MongoDB is installed and running on the default port.

Start the service:

python zip_code_lookup.py  

πŸ”§ Usage

API Endpoints

  • POST /create/: Creates a new ZIP code record.
  • GET /read/: Lists all stored ZIP code records.
  • PUT /update/{zip_code}/: Updates data for a specific ZIP code.
  • DELETE /delete/{zip_code}/: Deletes a ZIP code record.

Available Scripts

  • Export to JSON:

    python zip_code_lookup.py --export json  
  • Export to CSV:

    python zip_code_lookup.py --export csv  

πŸ“ Repository Files

  • zip_code_lookup.py: Main script implementing the service.
  • queries.json: Example export in JSON format.
  • queries.csv: Example export in CSV format.

About

A FastAPI project for managing ZIP code queries with ViaCEP API, MongoDB storage, and data export options (JSON/CSV). Includes CRUD operations, duplicate prevention, and robust validation. Ideal for integrating address lookup and management into apps efficiently. πŸš€

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages