LibrusAPI
This is Librus Rest API coded in Java for usage in mobile and web aplications
Install / Use
/learn @RegiZz/LibrusAPIREADME
LibrusApi
Docs
url/login -> params: login, password
url/timetables -> params: token, from(date), to(date)
url/grades -> params: token
url/grades/getAverage/allSubjects -> params: token
url/grades/getAverage/specificSubject -> params: token, subject(string)
url/absences/{id} -> params: token, id(in url)
url/absences -> params: token
Usage/Examples
First you need to host it on server and then you can use it like in this example:
import axios from 'axios';
const handleLogin = async () => {
try {
const response = await axios.post('https://your-server-ip/api/librus/login', {
login: login,
password: password,
});
if (response.status === 200) {
setToken(response.data);
Alert.alert('Succesfully logged in');
} else {
Alert.alert('Login error');
}
} catch (error) {
Alert.alert('Error', error.message);
}
};
const getTimetable = async () => {
if (!token) {
Alert.alert('You must to login first!');
return;
}
try {
const response = await axios.get('https://your-server-ip/api/librus/timetables', {
headers: {
Authorization: `Bearer ${token}`,
},
params: {
// Date examples
from: '2024-01-01',
to: '2024-01-07',
},
});
if (response.status === 200) {
setTimetable(response.data);
} else {
Alert.alert('Error while fetching the timetable');
}
} catch (error) {
Alert.alert('Error', error.message);
}
};
