Deploying YAPI for API Management
YAPI provides a collaborative paltform for designing, testing, and managing APIs, offering features like mock servers, automated testing, and role-based access control.
System Prerequisites
- Node.js (version 7.6 or higher, version 12 or lower recommended)
- MongoDB (version 2.6 or higher)
Setting Up MongoDB
YAPI requires a MongoDB instance for data storage. Use the following Docker command to launch a MongoDB container:
docker run --name yapi-mongo -v /opt/yapi/mongo_data:/data/db -d -p 27017:27017 mongo:5.0
Installation Methods
Web-Based Setup
This method uses a graphical interface for configuration.
- Install the YAPI command-line tool globally:
npm install -g yapi-cli --registry https://registry.npmjs.org - Launch the setup wizard, wich runs on port 8080 by default:
yapi server - After deployment completes, start the application in the background:
nohup node ./vendors/server/app.js &> /dev/null &
Access the platform via the provided URL and log in with the administrator email and default password (ymfe.org).
Manual Setup
Use this approach for environments with restricted network access or special configurations.
mkdir api-platform && cd api-platform
# Clone the repository with minimal history
git clone --depth 1 https://github.com/YMFE/yapi.git yapi-core
# Copy and rename the configuration template
cp yapi-core/config_example.json ./config.prod.json
cd yapi-core
# Install dependencies
npm install --production
# Initialize the database and create the admin account
npm run install-server
# Start the application
node server/app.js
After starting, access the service at http://localhost:<port> as defined in the configuration file.