async User(districtName, state, username, password)

Class representing an authenticated Infinite Campus user

new async User(districtName, state, username, password)

Authenticates a user. Fires ready event when the user is logged in

Example:
const InfiniteCampus = require('infinite-campus')
const user = new InfiniteCampus('New York District', 'NY', 'JDoe12', 'XXXXXX')

user.on('ready', () => {
  // user is authenticated, now we can make API calls
})
Parameters:
Name Type Description
districtName string

the name of the district the user belongs to (ex: 'New York School Districts', 'New York')

state string

two letter state code ('NY', 'MN')

username username

the user's username

password password

the user's password

Fires:

Methods

async getCourses() → {Array.<Term>}

Fetches data for all courses a user is enrolled in. This method returns information about all terms, all courses, all grades for those courses, as well as all time placement data for those courses. See documentation for the Term and Course types for more information on what this method specifically returns.

Returns:
Array.<Term> -

array of terms containing courses

Example
const InfiniteCampus = require('infinite-campus')
const user = new InfiniteCampus('New York District', 'NY', 'JDoe12', 'XXXXXX')

// wait until we are done logging in
user.on('ready', () => {
  // now that we are logged in, fetch courses
  user.getCourses().then((courses) => {
    console.log(courses)
  })
})

async getNotificationCount() → {integer}

gets current number of unseen notifications
note: the unseen notification count is different from the read status of an individual notification

Returns:
integer -

number of unseen notifications

Example
const InfiniteCampus = require('infinite-campus')
const user = new InfiniteCampus('New York District', 'NY', 'JDoe12', 'XXXXXX')

// wait until we are done logging in
user.on('ready', () => {
  // now that we are logged in, get the notification count
  user.getNotificationCount().then((count) => {
    console.log(count) // returns: 7
  })
})

async getNotifications(limitopt) → {Array.<Notification>}

Returns a list of notifications.

notification types:

keep in mind mind that that this data may not be 100% accurate, more research needs to be done

  • 2 - attendance updated (eg. you get marked tardy)
  • 3 - course grade updated (eg. your class grade changes after an assignment is graded)
  • 4 - assignment updated (eg. an assignment is graded or its state is updated as missing, late, etc )
Parameters:
Name Type Attributes Default Description
limit integer <optional>
200

number of notifications to return

Returns:
Array.<Notification> -

array of notifications

Example
// this example will mark all notifications before certain date as read

// first we log in
const InfiniteCampus = require('infinite-campus')
const user = new InfiniteCampus('New York District', 'NY', 'JDoe12', 'XXXXXX')

// wait until we are done logging in
user.on('ready', () => {
  // now that we are logged in, get notifications
  user.getNotifications().then((notifications) => {
    console.log(notifications)
  })
})

async markAllNotificationsRead()

marks all notifications as read
note: this is different from the unread count, see User.getNotificationCount() and User.resetNotificationCount()

Example
const InfiniteCampus = require('infinite-campus')
const user = new InfiniteCampus('New York District', 'NY', 'JDoe12', 'XXXXXX')

// wait until we are done logging in
user.on('ready', () => {
  // now that we are logged in, mark all notifications as read
  user.markAllNotificationsRead().then(() => {
    // ...
  })
})

async resetNotificationCount()

resets the unseen notification count. This is what happens when you click on the bell icon in Infinite Campus
note: this is different from the read status of individual notifications, see User.markAllNotificationsRead() and Notification.toggleRead()

Example
const InfiniteCampus = require('infinite-campus')
const user = new InfiniteCampus('New York District', 'NY', 'JDoe12', 'XXXXXX')

// wait until we are done logging in
user.on('ready', () => {
  // now that we are logged in, reset the notification count
  user.resetNotificationCount().then(() => {
    // ...
  })
})

Events

error

Fired when the login process has failed

ready

Fired when the user is authenticated and ready to make API calls