Welcome to the MITPA API! This API provides functionalities for managing users, rankings, study results, and integration with Discord.
🔐 CORS (Cross-Origin Resource Sharing) is ENABLED in this API.
❗ Only official and authorized MITPA websites are allowed to make requests to the API endpoints.
🚫 Requests made directly from browsers on unauthorized domains will be automatically blocked.
🛡️ This ensures user data security and system integrity.
- Method:
POST
- Description: Sends an image and a message to a Discord channel.
- Parameters:
userId
(required): User ID.message
(optional): Message to be sent.image
(required): Image file.
- Usage example:
curl -X POST -F "userId=123" -F "image=@path/to/image.jpg" http://api.mitpa.tech/share-result
- Method:
GET
- Description: Returns the user ranking based on accumulated points.
- Usage example:
curl http://api.mitpa.tech/ranking
- Methods:
GET /user-email/:userId
: Returns the user's email.POST /user-email
: Adds or updates the user's email.
- Parameters:
userId
(required): User ID.email
(required for POST): User email.
- Usage example:
curl http://api.mitpa.tech/user-email/123 curl -X POST -H "Content-Type: application/json" -d '{"userId": "123", "email": "user@example.com"}' http://api.mitpa.tech/user-email
- Method:
GET
- Description: Returns the user's study days and total points.
- Parameters:
userId
(required): User ID.
- Usage example:
curl http://api.mitpa.tech/get-study-days/123
- Method:
GET
- Description: Returns user information such as nickname, level, points, and completed SEs.
- Parameters:
userId
(required): User ID.
- Usage example:
curl http://api.mitpa.tech/user-info/123
- Methods:
GET /user-ses/:userId
: Returns the user's SEs.POST /user-ses
: Adds a new SE for the user.
- Parameters:
userId
(required): User ID.SE
(required for POST): Object containingtitle
,score
,total
, anddate
.
- Usage example:
curl http://api.mitpa.tech/user-ses/123 curl -X POST -H "Content-Type: application/json" -d '{"userId": "123", "SE": {"title": "SE1", "score": 90, "total": 100, "date": "2023-01-01"}}' http://api.mitpa.tech/user-ses
- Method:
POST
- Description: Verifies a user and creates an initial data file for them.
- Parameters:
user_id
(required): User ID.email
(optional): User email.
- Usage example:
curl -X POST -H "Content-Type: application/json" -d '{"user_id": "123", "email": "user@example.com"}' http://api.mitpa.tech/verify-user
- Method:
POST
- Description: Generates a verification code and sends it by email.
- Parameters:
to
(required): Recipient email.user_id
(required): User ID.
- Usage example:
curl -X POST -H "Content-Type: application/json" -d '{"to": "user@example.com", "user_id": "123"}' http://api.mitpa.tech/generate-code
- Method:
GET
- Description: Verifies if the submitted code is valid.
- Parameters:
user_id
(required): User ID.code
(required): Verification code.
- Usage example:
curl "http://api.mitpa.tech/verify-code?user_id=123&code=654321"
Make sure to set the environment variables in the .env
file:
DISCORD_TOKEN
DISCORD_CHANNEL_ID
MEMBERS_INFO_ENDPOINT
EMAIL_SEND_ENDPOINT
ALLOWED_ORIGIN_1
,ALLOWED_ORIGIN_2
, etc.
- Clone the repository:
git clone https://github.com/your-repository/api.mitpa.tech.git
- Install dependencies:
npm install
- Start the server:
npm start
We welcome contributions from developers, students, and enthusiasts who are passionate about creating impactful tools for the MITPA community.
If you’d like to contribute, please follow these guidelines:
- Fork the repository and create a new branch with a descriptive name.
- Make your changes with clean, readable code and clear commit messages.
- Ensure your code is well-tested and does not introduce regressions.
- Open a pull request detailing your changes, the problem it solves, and any relevant context.
🧠 We're especially interested in contributions that enhance performance, security, and user experience — aligned with MITPA’s mission of academic excellence and innovation.
If you're not sure where to start, check the issues section for open tasks, or feel free to open a discussion.