Product
Introducing SSO
Streamline your login process and enhance security by enabling Single Sign-On (SSO) on the Socket platform, now available for all customers on the Enterprise plan, supporting 20+ identity providers.
piazza.js
Advanced tools
Readme
A nodeJS module for interfacing with piazza.com.
NOTE: Do not use this repo! It is in development. Please use https://github.com/dyhwong/piazza-api from which this is based.
This repo originally started as a fork of dyhwong/piazza-api, but will be taken in a different direction.
Old readme docs.
This is an npm module so you can install it in the normal way.
$ npm install piazza-api
Login with a valid username and password:
var P = require('piazza-api');
P.login('<username>', '<password>').then(function(user) {
console.log('Hi', user.name);
});
The client returns with User object associated with the username and can be used to call the methods listed below. After logging in, the client stores a session token from the remote server so future API calls are automatically authenticated.
Most of the calls to the Piazza API are done asynchronously via Javascript Promises. Use the then
and catch
methods to handled returned data.
someAsyncCall().then(function(data) {
console.log('I got the data!');
}).catch(function(error) {
console.log('Uh oh, there was an error:', error);
});
This client will likely include synchronous methods for interacting with the API at some point in the future.
User fields include
Users can find Classes they are enrolled in by class ID or by their role in the Class. They can also check whether or not they are enrolled in a class.
> user.getClassById('gptvhze2ToY').name
Introduction to Computers
> user.getClassesByRole('student')[0].name // this method returns an array
Introduction to Computers
> user.isTakingClass('gptvhze2ToY')
true
School fields include
Each class belongs to one School which can be found school field. Schools currently have no methods and only have access to their name and ID.
> school.name
Stanford University
Class fields include
Classes have access to useful stats such as the response time through the getStats()
method and the number of users online through the getOnlineUsersCount()
method.
To access posts in the Class, use getContentByid
and either pass in the Content ID or an integer. The integer must be between 1 and the number of total posts in the class, inclusive. For example calling getContentById(97)
would be equivalent to using @97
in a post on the website. This method returns a Content object.
Filtering posts can be done via filterByFolder
which accepts a String parameter or filterByProperty
which accepts a property name such as 'unread', 'unresolved', 'hidden' (for Archived posts), 'updated', 'following', or 'instructors' (for instructor posts).
Searching can be done through the search
method which takes a query in the form of a String. All three methods return an Array of Content objects that satisfy the query.
Content fields include
Content objects have access to all other Content objects related to time like their parent and children. The getParent
method returns the parent Content object (or none if its type is 'question' or 'note'). Both getStudentResponse
and getInstructorResponse
return the corresponding child Content object while getFollowups
returns an array of all children Content objects that are followups of the current post.
Content objects can also get the names of their authors and editors through getAuthor
and getEditors
respectively.
> content.getAuthor()
John Smith
> content.getEditors()
['John Smith', 'Jane Doe']
Feed item fields include
Feed items can be converted to Content objects when necessary using the toContent
method.
> item.toContent()
FAQs
A module for interfacing with an unofficial Piazza API
The npm package piazza.js receives a total of 1 weekly downloads. As such, piazza.js popularity was classified as not popular.
We found that piazza.js demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Product
Streamline your login process and enhance security by enabling Single Sign-On (SSO) on the Socket platform, now available for all customers on the Enterprise plan, supporting 20+ identity providers.
Security News
Tea.xyz, a crypto project aimed at rewarding open source contributions, is once again facing backlash due to an influx of spam packages flooding public package registries.
Security News
As cyber threats become more autonomous, AI-powered defenses are crucial for businesses to stay ahead of attackers who can exploit software vulnerabilities at scale.