Skip to content

Latest commit

 

History

1 Commit

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 

Repository files navigation

Java API Interaction Project

This project demonstrates interaction with a REST API using Java's HttpClient. It consists of three tasks: managing user data, retrieving comments from the last post of a user, and fetching open tasks for a user. The project leverages HttpClient for making API requests and Gson for parsing JSON responses.

Table of Contents

  1. Introduction
  2. Features
  3. Technologies Used
  4. Implemented Tasks

Introduction

This project interacts with the https://jsonplaceholder.typicode.com API and consists of the following tasks:

  1. User Management: Allows creating, updating, deleting, and retrieving user data.
  2. Fetching Comments from Last Post: Retrieves all comments from the most recent post of a given user and saves them to a JSON file.
  3. Fetching Incomplete Tasks: Retrieves all pending tasks for a specified user.

These tasks demonstrate API interactions, JSON processing, and file handling in Java.

Features

  • REST API Interaction: Uses HttpClient to send and receive HTTP requests.
  • JSON Handling: Parses API responses and constructs JSON data using Gson.
  • File Storage: Saves API responses to structured JSON files.
  • Asynchronous Requests: Efficiently processes API calls without blocking execution.
  • Error Handling: Includes exception handling for failed requests.
  • Modular Design: Each task is structured in a separate class for maintainability.
  • Clear and Structured Output: Ensures well-formatted responses for easy readability.

Technologies Used

  • Java
  • HttpClient for API communication
  • Gson for JSON parsing
  • File I/O for saving data
  • Exception Handling for robust request management

Implemented Tasks

1. User Management

Purpose:

  • Perform CRUD operations on user data via API requests.
  • Retrieve users by ID and username for targeted queries.

Key Concepts Used:

  • HttpClient for sending HTTP requests.
  • Gson for parsing JSON responses.
  • Exception handling for failed API requests.

2. Last Post Comments Extractor

Purpose:

  • Identify and fetch comments from the latest post of a specified user.
  • Store comments in a structured JSON file named user-X-post-Y-comments.json (where X is the user ID and Y is the post ID).

Key Concepts Used:

  • HttpClient for API requests.
  • JSON parsing using Gson.
  • File handling for storing data.

3. Pending Task Tracker

Purpose:

  • Retrieve all tasks assigned to a user and filter out only the pending ones.

Key Concepts Used:

  • HttpClient for fetching task data.
  • JSON filtering to identify incomplete tasks.
  • Console output for displaying results in a structured manner.

This project provides practical experience in working with REST APIs in Java, demonstrating how to fetch, process, and store structured data efficiently.

About

No description, website, or topics provided.

Resources

Stars

0 stars

Watchers

1 watching

Forks

Releases

Packages

Contributors

Languages