Skip to content

YashDev-Design/Tasks-API

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Tasks API

A simple RESTful API for managing tasks, built with PHP and MySQL.

Description

This project provides endpoints to create, read, update, and delete tasks. It is designed to run locally using XAMPP.

Setup Instructions

  1. Install XAMPP

  2. Clone or Copy the Project

    • Place the tasks-api folder in /Applications/XAMPP/xamppfiles/htdocs/ (macOS) or the htdocs directory on your system.
  3. Import the Database

    • Open phpMyAdmin (http://localhost/phpmyadmin).
    • Create a database (e.g., tasks_db).
    • Import the provided SQL file in db folder named (schema ans seed.sql) to set up the tasks table.
  4. Configure Database Connection

    • Open db.php in the project folder.
    • Set your database credentials (DB name, user, password, host) as needed.

Base URL

http://localhost/tasks-api/

API Endpoints

Get All Tasks

GET /tasks

GET http://localhost/tasks-api/tasks

Get a Single Task

GET /tasks/{id}

GET http://localhost/tasks-api/tasks/1

Create a Task

POST /tasks

POST http://localhost/tasks-api/tasks
Content-Type: application/json

{
  "title": "Buy groceries",
  "description": "Milk, Bread, Eggs"
}

Update a Task

PUT /tasks/{id}

PUT http://localhost/tasks-api/tasks/1
Content-Type: application/json

{
  "title": "Go shopping",
  "description": "Milk, Bread, Eggs, Butter"
}

Delete a Task

DELETE /tasks/{id}

DELETE http://localhost/tasks-api/tasks/1

Toggle Task Status

PATCH /tasks/{id}/toggle

PATCH http://localhost/tasks-api/tasks/1/toggle

This endpoint flips the status of the specified task between pending and completed.

Testing the API

  • Use Postman or a similar tool to test the API endpoints.
  • Set the appropriate HTTP method and headers (e.g., Content-Type: application/json for POST/PUT).

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages