Skip to content

Latest commit

 

History

History
481 lines (377 loc) · 11.6 KB

API_REFERENCE.md

File metadata and controls

481 lines (377 loc) · 11.6 KB

API Reference

(POST methods are closed for use. However, it will work correctly when you run it on your computer)

API Token

It is required to include X-Auth-Token in the header for all requests.

Header Type Description
X-Auth-Token string required. Your api token

Supplements

Fetch All Supplements

  GET /api/supplement
cURL Usage
curl -X GET -H "X-Auth-Token: YOUR_API_KEY" https://vitamins-and-supplements.vercel.app/api/supplement/
Axios Usage
axios
  .get("https://vitamins-and-supplements.vercel.app/api/supplement/", {
    headers: { "X-Auth-Token": YOUR_API_KEY },
  })
  .then((response) => console.log(response.data))
  .catch((error) => console.error(error));

Fetch Supplements by Tag

  GET /api/supplement/:tag
Parameter Type Description
tag string required. Tag information of the item to be called
cURL Usage
curl -X GET -H "X-Auth-Token: YOUR_API_KEY" https://vitamins-and-supplements.vercel.app/api/supplement/tag
Axios Usage
axios
  .get("https://vitamins-and-supplements.vercel.app/api/supplement/tag", {
    headers: { "X-Auth-Token": YOUR_API_KEY },
  })
  .then((response) => console.log(response.data))
  .catch((error) => console.error(error));

Create Supplement

post requests are unavailable

  POST /api/supplement/create
Body Type
name string
rating number
recommendation string
tags string[]
benefits string[]
whoShouldUse string[]
dose string
timing string
suggestions string[]
cURL Usage
curl -X POST -H "Content-Type: application/json" -H "X-Auth-Token: YOUR_API_KEY" -d '{YOUR_BODY_VALUES}' https://vitamins-and-supplements.vercel.app/api/supplement/create
Axios Usage
axios
  .post(
    "https://vitamins-and-supplements.vercel.app/api/supplement/create",
    {
      YOUR_BODY_VALUES,
    },
    { headers: { "X-Auth-Token": YOUR_API_KEY } }
  )
  .then((response) => console.log(response.data))
  .catch((error) => console.error(error));

Update Supplement

post requests are unavailable

  PUT /api/supplement/update?name=
Query String Type Description
name string required. The name value of the item to be updated
cURL Usage
curl -X PUT -H "Content-Type: application/json" -H "X-Auth-Token: YOUR_API_KEY" -d '{"updatedValue": "Updated description"}' https://vitamins-and-supplements.vercel.app/api/supplement/update?name=supplement
Axios Usage
axios
  .put(
    "ttps://vitamins-and-supplements.vercel.app/api/supplement/update?name=supplement",
    {
      updatedValue: "Updated description",
    },
    { headers: { "X-Auth-Token": YOUR_API_KEY } }
  )
  .then((response) => console.log(response.data))
  .catch((error) => console.error(error));

Delete Supplement

post requests are unavailable

  DELETE /api/supplement/delete?name=
Query String Type Description
name string required. The name value of the item to be deleted
cURL Usage
curl -X DELETE -H "X-Auth-Token: YOUR_API_KEY" https://vitamins-and-supplements.vercel.app/api/supplement/delete?name=supplement
Axios Usage
axios
  .delete(
    "https://vitamins-and-supplements.vercel.app/api/supplement/delete?name=supplement",
    {
      headers: { "X-Auth-Token": YOUR_API_KEY },
    }
  )
  .then((response) => console.log(response.data))
  .catch((error) => console.error(error));

Vitamins

Fetch All Vitamins

  GET /api/vitamin
cURL Usage
curl -X GET -H "X-Auth-Token: YOUR_API_KEY" https://vitamins-and-supplements.vercel.app/api/vitamin/
Axios Usage
axios
  .get("https://vitamins-and-supplements.vercel.app/api/vitamin/", {
    headers: { "X-Auth-Token": YOUR_API_KEY },
  })
  .then((response) => console.log(response.data))
  .catch((error) => console.error(error));

Fetch Vitamins by Tag

  GET /api/vitamin/:tag
Parameter Type Description
tag string required. Tag information of the item to be called
cURL Usage
curl -X GET -H "X-Auth-Token: YOUR_API_KEY" https://vitamins-and-supplements.vercel.app/api/vitamin/tag
Axios Usage
axios
  .get("https://vitamins-and-supplements.vercel.app/api/vitamin/tag", {
    headers: { "X-Auth-Token": YOUR_API_KEY },
  })
  .then((response) => console.log(response.data))
  .catch((error) => console.error(error));

Create Vitamin

post requests are unavailable

  POST /api/vitamin/create
Body Type
name string
rating number
recommendation string
tags string[]
benefits string[]
whoShouldUse string[]
dose string
timing string
suggestions string[]
cURL Usage
curl -X POST -H "Content-Type: application/json" -H "X-Auth-Token: YOUR_API_KEY" -d '{YOUR_BODY_VALUES}' https://vitamins-and-supplements.vercel.app/api/vitamin/create
Axios Usage
axios
  .post(
    "https://vitamins-and-supplements.vercel.app/api/vitamin/create",
    {
      YOUR_BODY_VALUES,
    },
    { headers: { "X-Auth-Token": YOUR_API_KEY } }
  )
  .then((response) => console.log(response.data))
  .catch((error) => console.error(error));

Update Vitamin

post requests are unavailable

  PUT /api/vitamin/update?name=
Query String Type Description
name string required. The name value of the item to be called
cURL Usage
curl -X PUT -H "Content-Type: application/json" -H "X-Auth-Token: YOUR_API_KEY" -d '{"updatedValue": "Updated description"}' https://vitamins-and-supplements.vercel.app/api/vitamin/update?name=vitamin
Axios Usage
axios
  .put(
    "ttps://vitamins-and-supplements.vercel.app/api/vitamin/update?name=vitamin",
    {
      updatedValue: "Updated description",
    },
    { headers: { "X-Auth-Token": YOUR_API_KEY } }
  )
  .then((response) => console.log(response.data))
  .catch((error) => console.error(error));

Delete Vitamin

post requests are unavailable

  DELETE /api/vitamin/delete?name=
Query String Type Description
name string required. The name value of the item to be deleted
cURL Usage
curl -X DELETE -H "X-Auth-Token: YOUR_API_KEY" https://vitamins-and-supplements.vercel.app/api/vitamin/delete?name=vitamin
Axios Usage
axios
  .delete(
    "https://vitamins-and-supplements.vercel.app/api/vitamin/delete?name=vitamin",
    {
      headers: { "X-Auth-Token": YOUR_API_KEY },
    }
  )
  .then((response) => console.log(response.data))
  .catch((error) => console.error(error));

Categories

Fetch All Categories

  GET /api/category
cURL Usage
curl -X GET -H "X-Auth-Token: YOUR_API_KEY" https://vitamins-and-supplements.vercel.app/api/category/
Axios Usage
axios
  .get("https://vitamins-and-supplements.vercel.app/api/category/", {
    headers: { "X-Auth-Token": YOUR_API_KEY },
  })
  .then((response) => console.log(response.data))
  .catch((error) => console.error(error));

Fetch All Supplement Categories

  GET /api/category/supplements
cURL Usage
curl -X GET -H "X-Auth-Token: YOUR_API_KEY" https://vitamins-and-supplements.vercel.app/api/category/supplements/
Axios Usage
axios
  .get(
    "https://vitamins-and-supplements.vercel.app/api/category/supplements/",
    {
      headers: { "X-Auth-Token": YOUR_API_KEY },
    }
  )
  .then((response) => console.log(response.data))
  .catch((error) => console.error(error));

Fetch All Vitamin Categories

  GET /api/category/vitamins
cURL Usage
curl -X GET -H "X-Auth-Token: YOUR_API_KEY" https://vitamins-and-supplements.vercel.app/api/category/vitamins/
Axios Usage
axios
  .get("https://vitamins-and-supplements.vercel.app/api/category/vitamins/", {
    headers: { "X-Auth-Token": YOUR_API_KEY },
  })
  .then((response) => console.log(response.data))
  .catch((error) => console.error(error));

Search

Search All Supplements

  GET /api/search/supplement?name=
Query String Type Description
name string required. The name value of the item to be called
cURL Usage
curl -X GET -H "X-Auth-Token: YOUR_API_KEY" https://vitamins-and-supplements.vercel.app/api/search/supplement?name=supplement
Axios Usage
axios
  .get(
    "https://vitamins-and-supplements.vercel.app/api/search/supplement?name=supplement",
    {
      headers: { "X-Auth-Token": YOUR_API_KEY },
    }
  )
  .then((response) => console.log(response.data))
  .catch((error) => console.error(error));

Search All Vitamins

  GET /api/search/vitamin?name=
Query String Type Description
name string required. The name value of the item to be called
cURL Usage
curl -X GET -H "X-Auth-Token: YOUR_API_KEY" https://vitamins-and-supplements.vercel.app/api/search/vitamin?name=vitamin
Axios Usage
axios
  .get(
    "https://vitamins-and-supplements.vercel.app/api/search/vitamin?name=vitamin",
    {
      headers: { "X-Auth-Token": YOUR_API_KEY },
    }
  )
  .then((response) => console.log(response.data))
  .catch((error) => console.error(error));

Auth

Kayıt Oluştur

post requests are unavailable

  POST /api/auth/register
Body Type
username string
email number
password string
cURL Usage
curl -X POST -H "Content-Type: application/json" -H "X-Auth-Token: YOUR_API_KEY" -d '{YOUR_BODY_VALUES}' https://vitamins-and-supplements.vercel.app/api/auth/register
Axios Usage
axios
  .post(
    "https://vitamins-and-supplements.vercel.app/api/auth/register",
    {
      YOUR_BODY_VALUES,
    },
    { headers: { "X-Auth-Token": YOUR_API_KEY } }
  )
  .then((response) => console.log(response.data))
  .catch((error) => console.error(error));