Code Monkey home page Code Monkey logo

api_mongoose's Introduction

Api_Mongoose

Api rest with MongoDb + Express Welcome! This README file will provide you with an overview of the API, its features, how to use it, and other important information.

API structure

This rest api is created on node.js with express (server), javascript files with business logic, models for data access control, databases with MongoDb (Non-relational database)



API Base URL

The base URL's for accessing the API are: https://api-mongoose-alpha.vercel.app/api/providers and https://api-mongoose-alpha.vercel.app/api/products

Introduction

The Api_Mongoose is an API for managing a collection of providers and it's products. It provides endpoints to retrieve, search, create, update, and delete them.

Getting Started

Prerequisites To use this API, you will need:

  1. Ensure that you have a local development environment set up with Node.js and npm installed.
  2. Make sure you have a data base conection.


Installation:

  1. Clone the Api_Mongoose repository to your local machine.
  2. Navigate to the project directory.
  3. Run the following command to install the dependencies:


``` npm install ```

Starting the API:

In the project directory, run the following command to start the API server:

  npm run dev

The API will be accessible at:

Using the API:

  • You can send HTTP requests to the API using tools like cURL, Postman, or any programming language's HTTP library.
  • Refer to the provided endpoints in the API's README file for the available routes and their functionalities.
  • Use the appropriate HTTP methods (GET, POST, PUT, DELETE) and URLs to interact with the API.
  • Include your API key in the request URL for authentication when necessary.

Examples routes:


To manage Providers:


  1. To get information about one provider with the name , send a GET request to

EndPoint:

    https://api-mongoose-alpha.vercel.app/api/providers?company_name=Mama%20Conchi


Response:

    [
      {
        "company_name": "Mama Conchi",
        "CIF": "A05000039",
        "address": "Av. de Rafael Alberti, 26, 28018 Madrid",
        "url_web": "https://www.instagram.com/comida_casera_mama_conchi/"
      }
    ]


  1. To search for all providers, send a GET request to
EndPoint:

    https://api-mongoose-alpha.vercel.app/api/providers


Response:

    [
      {
        "company_name": "Roca Fría",
        "CIF": "B40579751",
        "address": "28033 Madrid",
        "url_web": "https://rocafria.com/"
      },
      {
        "company_name": "Mama Conchi",
        "CIF": "A05000039",
        "address": "Av. de Rafael Alberti, 26, 28018 Madrid",
        "url_web": "https://www.instagram.com/comida_casera_mama_conchi/"
      }
    ]


  1. To create a new provider, send a POST request to
EndPoint:

    https://api-mongoose-alpha.vercel.app/api/providers


request body:

    {
      "company_name": "Panda sushi",
      "CIF": "pand994",
      "address": "av.Pablo neruda 108, 28018 Madrid",
      "url_web": "www.pandasushi.eatbu.com"
    }


response: 

    {
      "message": "provider creado con éxito",
      "provider": {
        "company_name": "Panda sushi",
        "CIF": "pand994",
        "address": "av.Pablo neruda 108, 28018 Madrid",
        "url_web": "www.pandasushi.eatbu.com"
      }
    }

  1. To update an existing provider, send a PUT request to
EndPoint:

    https://api-mongoose-alpha.vercel.app/api/providers


request body:

    {
      "old_companyName": "Panda sushi",
      "new_companyData": {
        "CIF": "pand985"
      }
    }


response: 

    {
      "message": "provider Modificado con éxito",
      "newDataProvider": {
        "CIF": "pand985"
      }
    }

  1. To delete an provider, send a DELETE request to
EndPoint:

    https://api-mongoose-alpha.vercel.app/api/providers


request body:

    {
      "company_name": "Panda sushi 2"
    }


response: 

    {
      "message": "provider eliminado con éxito, company_name: Panda sushi 2"
    }



To manage Products:


  1. To get one product with title , send a GET request to
EndPoint:

  https://api-mongoose-alpha.vercel.app/api/products?title=Maki%20salmón


Response:

  {
    "message": "producto creado",
    "product": {
      "title": "Maki salmón",
      "price": 5,
      "description": "sushi",
      "image": "image",
      "provider": "648ca9e5380b8fefd581b750"
    }
  }


  1. To get all products of a company with company name , send a GET request to
EndPoint:

  https://api-mongoose-alpha.vercel.app/api/products?companyName=Panda%20sushi%202


Response:

  [
    {
      "title": "Maki salmón",
      "price": 5,
      "description": "sushi",
      "image": "image",
      "provider": {
        "company_name": "Panda sushi 2",
        "CIF": "pan8694",
        "address": "av.Pablo neruda 109, 28018 Madrid",
        "url_web": "www.pandasushi2.eatbu.com"
      }
    },
    {
      "title": "Sopa de pollo con champiñones",
      "price": 3.95,
      "description": "Sopa tradicional",
      "image": "https://encrypted-tbn0.gstatic.com/images?q=tbn:ANd9GcTf22KDdRrQ6U4tMniX3ZZ-0HLb3O2GrUWVHw&usqp=CAU",
      "provider": {
        "company_name": "Panda sushi 2",
        "CIF": "pan8694",
        "address": "av.Pablo neruda 109, 28018 Madrid",
        "url_web": "www.pandasushi2.eatbu.com"
      }
    },
    {...},
    {...}
  ]


  1. To get all products , send a GET request to
EndPoint:

  https://api-mongoose-alpha.vercel.app/api/products


Response:

  [
    {
      "title": "Maki salmón",
      "price": 5,
      "description": "sushi",
      "image": "image",
      "provider": {
        "company_name": "Panda sushi 2",
        "CIF": "pan8694",
        "address": "av.Pablo neruda 109, 28018 Madrid",
        "url_web": "www.pandasushi2.eatbu.com"
      }
    },
    {...},
    {...}
  ]


  1. To create a new product, send a POST request to
EndPoint:

    https://api-mongoose-alpha.vercel.app/api/products


request body:

    {
      "title": "Arróz frito con pollo",
      "price": 4.75,
      "description": "Arróz frito tradicional",
      "image": "https://pandarestaurant.es/wp-content/uploads/2021/11/Xian-soba-noodles.jpg",
      "provider_name": "Panda sushi"
    }


response: 

    {
      "message": "producto creado",
      "product": {
        "title": "Arróz frito con pollo",
        "price": 4.75,
        "description": "Arróz frito tradicional",
        "image": "https://pandarestaurant.es/wp-content/uploads/2021/11/Xian-soba-noodles.jpg",
        "provider": "648c9bce6329187183f210c7"
      }
    }


  1. To update an existing product, send a PUT request to
EndPoint:

    https://api-mongoose-alpha.vercel.app/api/products


request body:

    { 
      "old_title": "product1", 
      "new_data": {
        "title": "nigiri sushi / sashimi",
        "price": 27,
        "description": "selección del chef 6 piezas",
        "image": "https://s1.ppllstatics.com/diariovasco/www/multimedia/201906/21/media/cortadas/nigiri-ko9C--624x385@Diario%20Vasco.jpg"
      }
    }


response: 

    {
      "message": "producto Modificado con éxito",
      "newData": {
        "title": "nigiri sushi / sashimi",
        "price": 27,
        "description": "selección del chef 6 piezas",
        "image": "https://s1.ppllstatics.com/diariovasco/www/multimedia/201906/21/media/cortadas/nigiri-ko9C--624x385@Diario%20Vasco.jpg"
      }
    }


  1. To delete a specific product, send a DELETE request to
EndPoint:

    https://api-mongoose-alpha.vercel.app/api/products


request body:

    { 
      "title": "product3"
    }


response: 

    {
      "message": "producto eliminado con éxito, title: product3"
    }


  1. To delete all products of a company, send a DELETE request to
EndPoint:

    https://api-mongoose-alpha.vercel.app/api/products


request body:

    { 
      "provider": "company 1"
    }


response: 

    {
      "message": "productos eliminados con éxito del proveedor company 1"
    }



That's it!, Happy Coding!!!.





© Mariangelica Rodriguez

api_mongoose's People

Contributors

gromarant 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.