Important: This documentation covers Yarn 1 (Classic).
For Yarn 2+ docs and migration guide, see yarnpkg.com.

Package detail

ftc-api

efraim-andrade17ISC1.0.6TypeScript support: included

Travis branch npm

readme

fatec-api

Travis branch npm

API for SIGA from Centro Paula Souza made for students to create scripts based in their profile data.

Usage

Install the package:

npm install fatec-api --save

Check the documentation at: https://filipemeneses.gitbooks.io/fatec-api/

Getting Started

A quick example will show how to use it, scrapping the user name. And will cover the usage with Node.js using ES6 syntax.

const fatecApi = require('fatec-api')
const myAccount = new fatecApi.Account('LOGIN', 'PASSWORD')

myAccount.login().then(() => {
  return myAccount.getName().then(name => {
    console.log(name)
    // <- 'YOUR FULL NAME WITH CAPSLOCK'
  })
})

How it works

This library scrap data using HTTP requests with request and parses the HTML with cheerio library.

The auth/Account class does the heavy lifting, making the requests using core/Network. The scrapped data is later available at the attribute student of the auth/Account instance.

Here's the flow of account.getName():

Check out the documentation for more info.

Documentation

Available at: https://filipemeneses.gitbooks.io/fatec-api/

Discussion

Available at: https://discord.gg/RUv5Kxw

Development

  1. Clone:
    git clone https://github.com/filipemeneses/fatec-api.git
    cd fatec-api
  2. Install:
    npm i
  3. Test:

    Create the .env file in the root with the required values to test.

    LOGIN=TEST
    PASSWORD=TEST
    NAME=TEST

    There is two important test files to keep track with:

    • tests/FatecApi.test.ts to test the library features

      npm run test:api
    • tests/Siga.test.ts to test the integrity of SIGA (check if scrapped tags remains the same)

      npm run test:siga

    To test all:

    npm run test

changelog

1.3.2 (2019-03-02)

  • SIGA removed iframe from home, it is no longer needed to access iframe to get user registered emails

1.3.1 (2019-02-18)

  • Caching by cookie and route instead only route

1.3.0 (2018-10-22)

  • Added profile picture scrappig, account.getPicture() returns a base64 PNG image if exists, returns an empty string otherwise.
  • Student class now have picture property which contains the base64 PNG image.

1.2.0 (2018-08-23)

  • Updating scrap of month events in the academic calendar due SIGA modification.

1.1.0 (2018-03-16)

  • Depreciating getRegisteredEmails due SIGA modification. The table were e-mails were extracted is removed.

1.0.0 (2017-12-20)

  • Added History
  • Added Schedule
  • Added SchoolGrade
  • account.login() will throw error if credentials are wrong or any other SIGA's error
  • account.getSchoolGrade() returns SchoolGrade instance now
  • account.getHistory() returns History instance now
  • account.setSchedules() changed the return JSON and startAt, endAt date are relative to the current day
  • account.getPartialGrades() removed approved attribute and added to discipline instance
  • Added state checks to Discipline class and some missing getters/setters
  • Changed account.setclassroomCode to account.setClassroomCode

0.9.0 (2017-12-18)

  • Adding profile method scrapper

0.8.0 (2017-12-18)

  • Solving #9 by adding academic calendar method scrapper

0.7.2 (2017-12-17)

  • Account.login() is no longer mandatory to call other methods

0.7.0 (2017-12-16)

  • Added state to Discipline
  • Solving #6 by adding school grade method scrapper

0.6.0 (2017-12-16)

  • Solving #5 by adding complete history method scrapper

0.5.0 (2017-12-16)

  • Solving #3 by adding schedules method scrapper

0.4.0 (2017-12-16)

  • Removing multiple requests, now has a queue with 1s delay
  • Adding 5 minutes cache to every request
  • Adding partial absenses scrapper
  • Solving #4 by adding partial enrolled disciplines method scrapper

0.3.0 (2017-12-15)

  • Solved #2 by adding partial grades scrapper

0.2.0 (2017-12-15)

  • Solved #1 by adding registered emails scrapper