A node.js wrapper for Mashov API.
Note that:
- This wrapper focuses on student accounts, so don't expect for parental/teacher accounts support.
- I was too scared to test messages sending, so there isn't such feature here.
- I am not affiliated with Mashov in any way.
For a full list of features, consult the API section.
Install it from npm:
npm install --save node-mashov
Or import it in the browser (from unpkg
, for example):
<script src="https://unpkg.com/node-mashov/dist/node-mashov.min.js"></script>
<script>
const { fetchSchools, Client} = window.nodeMashov;
// ...
</script>
import { fetchSchools, Client } from 'node-mashov';
(async () => {
const schools = await fetchSchools();
const school = schools.find(s => s.name.includes('myschool'));
const client = new Client();
client.login({
username: 'username',
password: 'supersecret',
year: school.years[school.years.length - 1],
school
}).then(client.getGrades)
.then((grades) => {
console.log(grades);
});
})();
Sample reponses from the API can be found here.
Returns a Promise
for an Array
of schools.
Create a new client instance.
After a successful login, an authDetails
object is created, containing the required information
for the client to authenticate with the API. You should store those details for future use.
Type: Object
The API lets you specify time range for records. Those methods allows you to utilize this feture.
Type: string
, null
Format: YYYY-MM-DD
All of the following methods return a Promise
Authenticate using the details provided in the constructor.
Type: Object
Deauthenticate and destroy authentication details.
Getting the user's conversations.
Type: Object
, string
Default: 'inbox'
Mashov's API lets you query conversations. This wrapper does include support for that.
If query
is a string
, it'll fetch all of the messages matched the type. It could be one of the following:
'inbox'
- Inbox'archive'
- Archived messages'unread'
- Unread messages'deleted'
- Deleted messages'sent'
- Messages sent'draft'
- Drafts
Otherwise, you can use a more complex query by making query
into an object,
with the following properties:
Type: string
Default: 'all'
'all'
- All conversations'inbox'
- Inbox'unread'
- Unread messages
Type: string
Type: boolean
Default: false
If true
, will query all the conversations that has an attachment. If false
, it'll query
conversations with or without attachments.
Type: string
Format: YYYY-MM-DD
An example for a valid query:
{ in: 'unread', sender: 'teacher', receiver: 'student', subject: 'Bring your books tomorrow', attachment: true, dromDate: '2017-05-01' }
Type: number
Default: 20
Number of messages to fetch (from start).
Type: number
Default: 0
Number of messages to skip. Can be useful for pagination.
Fetch a single conversation.
Example usage:
client.getAllConversations() .then(convs => convs[0].id) .then(client.getConversation) .then((conv) => { console.log(conv); });
Will fetch the user's school's bell schedule.
Will fetch the user's files (aka study materials)
Example usage:
client.getGroups() .then(groups => groups[0].id) .then(client.getGroupContacts) .then((contacts) => { console.log(contacts); });
- mashov-api - Mashov API for JVM platform
MIT © Yarden Sod-Moriah