Title | Author | Date |
---|---|---|
Pulchowk student API wrapper 👋 |
Nischal Shakya |
November 18, 2022 |
This is the api wrapper around the Student API provided by Pulchowk Campus which provides easy to use API than what is provided by the college.
NestJS was used for building this API as it provides very clean architecture with how the files are arranged. Since, Typescript support is available by default, it provides very good developer experience.
- ✨ Demo
- 🙅 Problem
- 💡 Solution
- 🚀 Usage
- 👏 Contributing
- ⚙️ Installation
- 👨💻 Development scripts
- 📝 License
This simple demo is presented using Insomnia. It gives an idea of the type of data that is returned by the API.
The API provided by college require the use of URLSearchParams
to perform the required POST request.
const formData = new URLSearchParams();
formData.append('prog', prog);
formData.append('batch', batch);
formData.append('group', group);
This is quite cumbersome as of today.
Similarly, the response of the API is also not what you expect.
# API response
[
["075","BCT","123","JOHN DOE"],
["075","BCT","456","FIRSTNAME LASTNAME"],
["075","BCT","789","FIRSTNAME MIDDLENAME LASTNAME"],
...
]
This requires the users to put extra formatting logic to get the data in the way they want.
😩 I can't seem to get the student of particular
prog
,batch
,group
by their roll number.
The API which is easy to use and returns the response as expected.
# API response
[
{
"firstname": "JOHN",
"middlename": "",
"lastname": "DOE",
"batch": "075",
"prog": "BCT",
"roll": "123"
},
{
"firstname": "FIRSTNAME",
"middlename": "",
"lastname": "LASTNAME",
"batch": "075",
"prog": "BCT",
"roll": "456"
},
{
"firstname": "FIRSTNAME",
"middlename": "MIDDLENAME",
"lastname": "LASTNAME",
"batch": "075",
"prog": "BCT",
"roll": "789"
},
...
]
You want to get data of specific student. Don't worry. We got you covered.
The usage is listed below.
The base URL of the API is provides as https://pulchowkserver.vercel.com/api/
.
The request parameters are to be used with following values
prog
=> To input Program Code, values can be BCT, BEI, BEX, BEL, BME, BAR, BAE, BAS, BCE or BCHbatch
=> To input Batch, values can be 074 or 075 or so on.group
=> To input Group, values can be A, B, C or D or so on.
/students
Returns all the students according to
prog
,batch
andgroup
// with axios
axios.post('https://pulchowkserver.vercel.com/api/students/', {
prog: "BCT",
batch: "075",
group: "C",
})
...
// with fetch
await fetch('https://pulchowkserver.vercel.com/api/students/', {
method: 'POST',
headers: {
'Content-Type': 'application/json',
},
body: JSON.stringify({
prog: 'BCT',
batch: '075',
group: 'C',
}),
})
...
/students/<roll-number>
Returns the student according to
prog
,batch
andgroup
byroll
// with axios
axios.post('https://pulchowkserver.vercel.com/api/students/012', {
prog: "BCT",
batch: "075",
group: "C",
})
...
// with fetch
await fetch('https://pulchowkserver.vercel.com/api/students/345', {
method: 'POST',
headers: {
'Content-Type': 'application/json',
},
body: JSON.stringify({
prog: 'BCT',
batch: '075',
group: 'C',
}),
})
...
Make sure you have Node installed on your PC. We recommend using the LTS version.
Run the following script to install all the dependencies.
npm install
# or
yarn
# development
yarn start
# watch mode
yarn start:dev
# build
yarn build
# production mode
yarn start:prod
-the end -