*The author of this script is not responsible for any damage caused by the use of this script. Use it at your own risk.
I am a student at the Faculty of Science, Alexandria University (AUFS). The university has a website where students can check their grades. However, the website is not very user-friendly, and it requires students to log in every time they want to check their grades. This is a problem for me because I often forget to check my grades. That's when I decided to create a script that will check my grades for me and notify me when they are available. I also wanted to make the script easy to use, so I decided to create a REST API that can be used by anyone who wants to check their grades.
Quick note: Make sure you are calling the API from a computer not using a mobile app because it does not work there. Use a tool like Postman as this tool is tested and it's working with it.
Login page:
The login page of the website.
Main page:
Once you log in, you will be redirected to the main page of the website. This page contains all the information about the student:
Grades page:
This is the page where the students can check their grades.
The page contains a table for each semester, with the info about the courses the student has enrolled into as shown in the image above. Please note that the website is in Arabic, and all the course names are in Arabic, I translated the site so anyone would understand the concept. So the API will send the grades in Arabic (as how you will see later) since the website is in Arabic by default..
You just need to call the /start endpoint with the following parameters:
POST /start HTTP/1.1
{
"username": "your_username",
"phoneNumber": "your_phone_number",
"token": "your_token"
}
Example call:
POST /start HTTP/1.1
{
"username": "2024123456",
"phoneNumber": "+201234567890",
"token": "your_token"
}
Returns:
201 Created
{
"message": "Grade checking service started."
}
https://www.scialex.org/S/your_token/Student/2018
Just copy the token from the url and paste it in the token parameter in the API. That's it!
The token will be used to authenticate the user and get the grades.
If the token expires for any reason, you will be notified via WhatsApp. And you will need to log in again and get a new token.
The token will be stored in the database and will be used to authenticate the user in the future.
The API will check if the user is already registered in the database. If not, it will register the user and store the token in the database and send a message via WhatsApp to the user with a message like this:
"Hello! You have successfully registered to the grades checker API. You will be notified via SMS when your grades are available."
*Your username*: 'your_username'
*Your Pending Courses*: 'List of all pending courses'
*Your current CGPA*: 'your_current_cgpa'
The API will regularly check the grades every 9 minutes, and that was achieved by using cron-jobs, and if any grades had been revealed, it will send a message via SMS to the user with the revealed grades and the current CGPA. The message will look like this:
Notification sent as an SMS message.
Sometimes, you would get a response like this:
500 Internal Server Error
{
"error": "Error starting background process for {username}: $ is not a function"
}
I implemented the checking logic to check the Appreciation column, by default after you completed the course's survey, the grade for the course is 'P' indicating that the grade is not revealed yet. Once the grade is revealed, it will be changed to 'A' or 'B' or any other grade. So I just check if the grade is 'P' or not. If it is not 'P', then the grade is revealed and I will send a message to the user with the revealed grades and the current CGPA.
Once all grades are revealed, the API will stop checking the grades, delete all the user's data, and will send a message via WhatsApp to the user with a message like this:
"Hello! All your grades are revealed. Your current CGPA is {cgpa}. Thank you for using the grades checker API."
"Hello! Your token has expired. Please log in again and get a new token. Thank you for using the grades checker API."
However, if you decide to stop the service at anytime, you can just call the /stop endpoint with the following parameters:
DELETE /stop HTTP/1.1
{
"username": "your_username"
}
Returns:
204 No Content
{
"message": "Grade checking service stopped for user {username}."
}
"Hello! You have successfully stopped the grades checker API. Thank you for using the grades checker API."
Info:
*Duration*: x minutes
*Start date*: DD/MM/YYYY, HH/MM/SS (24-hour format)
*End date*: DD/MM/YYYY, HH/MM/SS (24-hour format)
I implemented a rate limiting feature to prevent abuse of the API. The API will limit the number of requests to 100 requests every 15 minutes. If the user exceeds this limit, the API will return a 429 Too Many Requests error.
Component Diagram
Call Flow Diagram
Well, I needed to host the API somewhere, so based on my use case, I decided to use Railway. The API is hosted on a free tier, as the API is not very heavy and does not require a lot of resources. But if the API is used by a lot of users, I would need to upgrade the plan, and I don't think I will do that. So the solution for you would be to either:
If you want to host it on your own server, you can just clone the repository using the following command:
git clone https://github.com/MohamedWElteir/grades-checker.git
Then, navigate to the project directory and install the dependencies:
npm install
Then, you can run the API using the following command:
npm start
Make sure you have the environment variables set up correctly. You can find the environment variables in the .env.example
file. Just copy the file and rename it to .env
, then fill in the required values.
In the end, this is a script I did for fun and because I am lazy and I don't want to check my grades every time. I am not responsible for any damage caused by the use of this script. Use it at your own risk. I hope you find it useful.
If you have any new idea or suggestion that would add to the project, feel free to create a pull request with your additions!