npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

mashov-api

v1.0.0

Published

MashovApi

Downloads

9

Readme

mashov-api

The unofficial mashov-api, created by Ofiz.
Interact with the Mashov app freely and easly via node.js!

Installation

npm i mashov-api

Basic Examples

Login

Syntax

const mashov = require('mashov-api');
mashov.loginToMashov(semel, year, username, password).then(async (loginInfo) => {})

How to use?

semel - get it in HERE,
year - Current year is 2021,
username - ID \ other mashov username,
password - mashov password.

Returns

The "mashov.loginToMashov()" method returns an array with login information.

Get Grades.

Code

const mashov = require('mashov-api');
// login to the mashov 
mashov.loginToMashov(semel, year, username, password).then(async (loginInfo) => {

//get all of the user's grades
grades = await mashov.get(loginInfo, "grades");

//and just print all of the grades
console.log(grades)
})

Output Head Example (With my user connected)

{
    studentGuid: '###',
    gradingEventId: Number,
    grade: Number,
    rangeGrade: '###',
    rate: 0,
    timestamp: '###',
    teacherName: '###',
    groupId: Number,
    groupName: '###',
    subjectName: '###',
    eventDate: '###',
    id: Number,
    gradingPeriod: Number,
    gradingEvent: '###',
    gradeRate: Number,
    gradeTypeId: Number,
    gradeType: '###',
  }

Get Timetable.

Code

const mashov = require('mashov-api');
// login to the mashov 
mashov.loginToMashov(semel, year, username, password).then(async (loginInfo) => {

//get all of the user's timetable.
timetable = await mashov.get(loginInfo, "timetable");

//and just print the timetable.
console.log(timetable)
})

Output Head Example (With my user connected)

{
    timeTable: {
      groupId: Number,
      day: Number,
      lesson: Number,
      roomNum: '###',
      weeks: Number
    },
    groupDetails: {
      groupId: Number,
      groupName: '###',
      subjectName: '###',
      groupTeachers: [Array],
      groupInactiveTeachers: []
    }
  },

Get 5 last mails.

Code

const mashov = require('mashov-api');
// login to the mashov 
mashov.loginToMashov(semel, year, username, password).then(async (loginInfo) => {

//get all of the user's mails.
mails = await mashov.getMail(loginInfo, 5); // "5" is the amount of the mails.

//and just print the mails.
console.log(mails)
})

Output Head Example (With my user connected)

  {
    conversationId: '###',
    subject: '###',
    sendTime: '###',
    isNew: false,
    hasDrafts: false,
    hasAttachments: true,
    messages: [ [Object] ],
    labels: [],
    preventReply: true
  }

Advanced Examples

Average grades.

Code

const mashov = require('mashov-api');
// login to the mashov 
mashov.loginToMashov(semel, year, username, password).then(async (loginInfo) => {

    //get all of the user's grades
    grades = await mashov.get(loginInfo, "grades");

    //creates a map that will fill up with grades 
    //and general average and per class average.
    let mapGrades = new Map()
    mapGrades["general"] = {}
    mapGrades["general"]["total"] = 0
    mapGrades["general"]["count"] = 0
    mapGrades["general"]["name"] = "general"
    mapGrades["general"]["average"] = 0
    grades.forEach(async element => {
        if (element["grade"] != undefined) {
            mapGrades["general"]["total"] = 
            mapGrades["general"]["total"] + element["grade"];
            mapGrades["general"]["count"] = 
            mapGrades["general"]["count"] + 1
            mapGrades["general"]["average"] =
                 mapGrades["general"]["total"] /
                  mapGrades["general"]["count"]

            if (mapGrades[element["subjectName"]]) {
                mapGrades[element["subjectName"]]["total"] =
                 mapGrades[element["subjectName"]]["total"] +
                  element["grade"]
                mapGrades[element["subjectName"]]["count"] =
                 mapGrades[element["subjectName"]]["count"] + 1
                mapGrades[element["subjectName"]]["average"] =
                 mapGrades[element["subjectName"]]["total"] /
                  mapGrades[element["subjectName"]]["count"]
            }
            else {
                mapGrades[element["subjectName"]] = {}
                mapGrades[element["subjectName"]]["total"] =
                 element["grade"]
                mapGrades[element["subjectName"]]["count"] = 1
                mapGrades[element["subjectName"]]["name"] =
                 element["subjectName"]
                mapGrades[element["subjectName"]]["average"] =
                 element["grade"]
            }
        }

    })
    // then lets just print the map.
    console.log(mapGrades)
})

Output (With my user connected)

Map {
  general: {total: Number, count: Number, name: '###', average: Number},
  '###': {total: Number, count: Number, name: '###', average: Number},
  '###': { total: Number, count: Number, name: '###', average: Number},
  '###': { total: Number, count: Number, name: '###', average: Number },
  '###': { total: Number, count: Number, name: '###', average: Number },
  '###': { total: Number, count: Number, name: '###', average: Number }      
}

Timetable of the day map.

Code

const mashov = require('mashov-api');
// login to the mashov 
mashov.loginToMashov(semel, year, username, password).then(async (loginInfo) => {

    //get user's timetable.
    timetable = await mashov.get(loginInfo, "timetable");

    //creates a map that will fill up with timetable by lessons.
    var day = new Date().getDay() + 1
    timeTableArray = {}
    timetable.forEach(element => {
        if (element["timeTable"]["day"] == day) {
            if (timeTableArray[element["timeTable"]["lesson"]] == undefined) {
                timeTableArray[element["timeTable"]["lesson"]] = {}
                timeTableArray[element["timeTable"]["lesson"]]["lesson"] =
                    element["timeTable"]["lesson"]
                timeTableArray[element["timeTable"]["lesson"]]["name"] =
                    element["groupDetails"]["subjectName"]
                timeTableArray[element["timeTable"]["lesson"]]["teacher"] =
                    element["groupDetails"]["groupTeachers"]["teacherName"]

                if (element["timeTable"]["roomNum"] != '') {
                    timeTableArray[element["timeTable"]["lesson"]]["place"] =
                        element["timeTable"]["roomNum"]
                }
            } else {
                timeTableArray[element["timeTable"]["lesson"]]["lesson"] =
                    element["timeTable"]["lesson"]
                timeTableArray[element["timeTable"]["lesson"]]["name"] =
                    element["groupDetails"]["subjectName"]
                timeTableArray[element["timeTable"]["lesson"]]["teacher"] =
                    element["groupDetails"]["groupTeachers"][0]["teacherName"]
                if (element["timeTable"]["roomNum"] != '') {
                    timeTableArray[element["timeTable"]["lesson"]]["place"] =
                        element["timeTable"]["roomNum"]
                }
            }

        }
    })

    // then lets just print the map.
    console.log(timeTableArray)
})

Output (With my user connected)

{
  '1': {
    lesson: 1, name: '###', teacher: '###', place: '###'
  },
  '2': {
    lesson: 2, name: '###', teacher: '###', place: '###'
  },
  '3': {
    lesson: 3, name: '###', teacher: '###', place: '###'
  },
  '4': {
    lesson: 4, name: '###', teacher: '###', place: '###'
  },
  '5': {
    lesson: 5, name: '###', teacher: '###', place: '###'
  },
  '7': {
    lesson: 7, name: '###', teacher: '###', place: '###'
  }
}

Basic docs (Under construction)

Login

Syntax

const mashov = require('mashov-api');
mashov.loginToMashov(semel, year, username, password).then(async (loginInfo) => {})

How to use?

semel - get it in HERE,
year - Current year is 2021,
username - ID \ other mashov username,
password - mashov password.

Returns

The "mashov.loginToMashov()" method returns an array with login information.

Methods Syntax

const mashov = require('mashov-api');
// login to the mashov 
mashov.loginToMashov(semel, year, username, password).then(async (loginInfo) => {

    school = await mashov.getSchools(loginInfo);
    //returns list of all schools with years and "semel".

    gradesRaw = await mashov.getRaw(loginInfo, "grades");
    //returns grades response raw.

    grades = await mashov.get(loginInfo, "grades");
    //returns grades json

    behavior = await mashov.get(loginInfo, "behave");
    //returns behavior json

    timeTable = await mashov.get(loginInfo, "timetable");
    //returns timetable json

    //This template can also work with 
    // "outBehave", "homework", "justificationrequests", "reportCards" and etc.


    mails = await mashov.getMail(loginInfo, 5);
    //returns 5 last mails in json

    notifications = await mashov.getNotifications(loginInfo, 5);
    //returns 5 last notifications in json

    picture = await mashov.getPicture(loginInfo);
    //returns student picture in buffer
});

Roadmap

  1. Expand the docs, the api can do way more then what is showing in the docs.
  2. Add more methods.
  3. More error handling.

Support or contact.

You can contact me via discord - "Ofiz#6414"

License

MIT

Credits

Created, developed and published by Ofiz.
Requested by "Melech HaTichnot".