Skip to content

RubenRaMar/Figuranis-API

Repository files navigation

API Documentation

Welcome to the FIGURAniS API documentation! This API serves as the backend for the FIGURAniS project, allowing users to manage their anime figure collection. The API provides endpoints for user authentication and retrieving figure data from a MongoDB database. To ensure security, authentication is required to access the figure-related endpoints, and users can only retrieve figures associated with their user ID.

Authentication

👉Login User👈

  • Endpoint: POST /user/login

  • This endpoint is used to log in a user and obtain an authentication token.

Request Body:

{
  "username": admin,
  "password": admin
}

Response:

{
  "token": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiI4OTA4MDk4MDk4MDk4MDk4IiwibmFtZSI6ImlzZGljb3VkYWhzIiwiaWF0IjoxNjg0MTUxNzEwLCJleHAiOjE2ODQyMzgxMTB9.8nONfhY3flP0sw2T1251a6freHSEb1eF4hRcSiA9gyA"
}
Note: The obtained token must be included in the Authorization header of subsequent requests as a Bearer token.

Figures

👉Get Figures👈

  • Endpoint: GET /figures

    • This endpoint retrieves all the figures associated with the authenticated user.

Request Headers:

Authorization: Bearer <token>

Response:

{
  "figures": [
    {
      "_id": "614c5ec9a5207e001f6ffabc",
      "title": "Figure 1",
      "character": "Character 1",
      "franchise": "Franchise 1",
      "isPurchased": true,
      "manufacturer": "Manufacturer 1",
      "material": "Material 1",
      "size": 10,
      "weight": 0.5,
      "price": 100,
      "image": "https:/discord/image1.jpg"
    },
    {
      "_id": "614c5ed8a5207e001f6ffabd",
      "title": "Figure 2",
      "character": "Character 2",
      "franchise": "Franchise 2",
      "isPurchased": false,
      "manufacturer": "Manufacturer 2",
      "material": "Material 2",
      "size": 15,
      "weight": 0.7,
      "price": 150,
      "image": "https:/discord/image2.jpg"
    }
  ],
  "length": 2
}

👉Get Figure by ID👈

  • Endpoint: GET /figures/:id

    • This endpoint retrieves a specific figure by its ID. Only figures associated with the authenticated user can be accessed.

Request Headers:

Authorization: Bearer <token>

Response:

{
  "figure": {
    "title": "Jimei Palace Enel the god of thunder One Piece",
    "character": "Enel",
    "franchise": "One Piece",
    "isPurchased": true,
    "manufacturer": "Jimei Palace",
    "material": "Resin + LED",
    "size": 62,
    "weight": 9.87,
    "price": 1599,
    "image": "https://i.ibb.co/5Mv33z5/enel.webp",
    "user": "646fc50910c8e8c5b17d54a7",
    "id": "6489adcd75f15c7f21954b8b"
  }
}

👉Delete Figure👈

  • Endpoint: DELETE /figures/delete/:id

    • This endpoint deletes a specific figure by its ID. Only figures associated with the authenticated user can be deleted.

Request Headers:

Authorization: Bearer <token>

Response:

{
  "message": "The figure has been removed"
}

👉Update Figure👈

  • Endpoint: PUT /figures/:id

    • This endpoint updates a specific figure by its ID. Only figures associated with the authenticated user can be updated.

Request Headers:

Authorization: Bearer <token>

Request Body:

{
  "title": "Updated Figure",
  "character": "Updated Character",
  "franchise": "Updated Franchise",
  "isPurchased": true,
  "manufacturer": "Updated Manufacturer",
  "material": "Updated Material",
  "size": 20,
  "weight": 1.2,
  "price": 200,
  "image": "https:/discord/updated-image.jpg"
}

Response:

{
  "message": "The figure could not be updated"
}

👉Add Figure👈

  • Endpoint: PUT /figures/:id

    • This endpoint adds a specific figure by sending it in the body. It will be added in the database associated to the user.

Request Headers:

Authorization: Bearer <token>

Request Body:

{
  "title": "Dragon Ball Fat Buu BT Studio",
  "character": "Fat Buu",
  "franchise": "Dragon Ball",
  "isPurchased": false,
  "manufacturer": "BT Studio",
  "material": "Resin",
  "size": 30,
  "weight": 2.87,
  "price": 205.4,
  "image": "https://i.ibb.co/rsWcdcc/fat-boo-dog.webp"
}

Response:

{
  "figure": {
    "user": "646fc50910c8e8c5b17d54a7",
    "id": "6490128f5b7e2763363c4d7b",
    "title": "Dragon Ball Fat Buu BT Studio",
    "character": "Fat Buu",
    "franchise": "Dragon Ball",
    "isPurchased": false,
    "manufacturer": "BT Studio",
    "material": "Resin",
    "size": 30,
    "weight": 2.87,
    "price": 205.4,
    "image": "https://i.ibb.co/rsWcdcc/fat-boo-dog.webp"
  }
}

Technologies

The FIGURAniS API is built using the following technologies:

TypeScript Express.js MongoDB mongoosejs Jest Node.js jwt bcryptjs supertest

About

The REST API that serves data to the FIGURAniS web application.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published