Giter Club home page Giter Club logo

fcc-exercise-tracker's Introduction

Simple API Documentation

This is a simple API for freecodecamp backend certification. You're able to create new users and register exercises.

Entities

User

{
    "_id": "string",
    "username": "string",
    "exercises": [Exercise]
}

Exercise

{
    "description": "string",
    "duration": "number",
    "date": "string"
}

Endpoints

⚡️ Create a User

  • HTTP Method: POST

  • Endpoint: /users

  • Description: Creates a new user.

  • Request Body:

    • Content Type: application/x-www-form-urlencoded
    • Data Format: URL-encoded key-value pairs.

    Request Body Parameters:

    • username (string): The username of the new user.
  • Response:

    • 200 OK: Successful user creation.
      • _id (string): The unique identifier for the created user.
      • username (string): The username of the created user.
    • 400 Bad Request: If the request body is invalid.

⚡️ Get All Users

  • HTTP Method: GET
  • Endpoint: /users
  • Description: Retrieves a list of all users.

Response:

  • 200 OK: Successful retrieval of the user list.
    • An array of user objects, each containing:
      • _id (string): The unique identifier for the user.
      • username (string): The username of the user.
  • 500 Internal Server Error: If there's an application error.

⚡️ Create an Exercise for a User

  • HTTP Method: POST
  • Endpoint: /users/:_id/exercises
  • Description: Creates a new exercise entry for a specific user.

URL Parameters:

  • _id (string): The unique identifier of the user for whom the exercise is being created.

Request:

  • Content Type: application/x-www-form-urlencoded
  • Data Format: URL-encoded key-value pairs.

Request Body Parameters:

  • description (string): Description of the exercise.
  • duration (number): Duration of the exercise in minutes.
  • date (string, optional): Date of the exercise in the format "YYYY-MM-DD" (default is the current date if not provided).

⚡️ Get User Exercise Logs

  • HTTP Method: GET
  • Endpoint: /users/:_id/logs
  • Description: Retrieves exercise logs for a specific user with optional filtering and limiting.

URL Parameters:

  • _id (string): The unique identifier of the user for whom exercise logs are being retrieved.

Query Parameters:

  • from (string, optional): Start date for filtering exercises (inclusive). Format: "YYYY-MM-DD".
  • to (string, optional): End date for filtering exercises (inclusive). Format: "YYYY-MM-DD".
  • limit (number, optional): Maximum number of exercise logs to return.

Response:

  • 200 OK: Successful retrieval of exercise logs.
    • _id (string): The unique identifier for the user.
    • username (string): The username of the user.
    • count (number): Total count of exercise logs.
    • log (array of objects): An array of exercise log entries, each containing:
      • description (string): Description of the exercise.
      • duration (number): Duration of the exercise in minutes.
      • date (string): Date of the exercise in "YYYY-MM-DD" format.
  • 400 Bad Request: If there are query parameter validation errors.
  • 500 Internal Server Error: If there's an application error.

fcc-exercise-tracker's People

Contributors

ifonso avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.