Socket
Book a DemoInstallSign in
Socket

institute-courses-api

Package Overview
Dependencies
Maintainers
1
Versions
3
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

institute-courses-api

A fully async API written in ES6 for fetching courses from various sources

latest
Source
npmnpm
Version
1.0.2
Version published
Maintainers
1
Created
Source

Institute courses API for Node JS

A fully async API written in ES6 for fetching courses from various sources

npm badge

Setting up

Installing
npm install institute-courses-api
Quickstart
CLI
# Install
> npm install -g institute-courses-api
# Use
> institute-courses-api --help

Fetch courses

Options:
  --help                  Show help                                    [boolean]
  --version               Show version number                          [boolean]
  --parallel-sources      The number of sources to process simultaneously
                                                                    [default: 1]
  --parallel-requests     The number of requests to send simultaneously
                                                                    [default: 3]
  --minimum-delay         The minimum number of milliseconds to wait between
                          requests                                [default: 100]
  --maximum-delay         The maximum number of milliseconds to wait between
                          requests                               [default: 1000]
  --courses-to-fetch, -n  The amount of courses to fetch from each source (0
                          means all). Rounds up to nearest batch    [default: 0]
  --output, -o            Path to the output file
  -d, --debug             Run in debugging mode                        [boolean]

Library
const {BTH, fetchCourses} = require('institute-courses-api');

// Fetch courses from all institutes
const bth = new BTH();
fetchCourses(bth).then(courses => {
  console.log(courses[0]);
});
{
  "other": {
    "appliable": false,
    "applicationCode": "S5531",
    "start": "SOM18",
    "points": 15,
    "topic": "Medieteknik"
  },
  "name": "Idé- och konceptutveckling för entreprenörskap",
  "url": "url-to-course-page",
  "code": "ME1595",
  "books": [],
  "source": "bth"
}

Documentation

The documentation is currently a bit sparse. For more information, refer to the source and issues on GitHub.

Methods

The module exposes the following

const {
  BTH, // Source
  sources, // Enumerable array of the sources above
  fetchCourses // Convenience method for fetching courses from a source
} = require('institute-courses-api');

Convenience methods

/**
* Fetch courses from all sources asynchronously.
* @param {Source} source - The source (institute) to fetch courses from.
* @param {Object} options - Optional options
* @param {Number} options.parallelRequests - The number of requests to send simultaneously.
* @param {Number} options.minimumDelay - The minimum number of milliseconds to wait between requests.
* @param {Number} options.maximumDelay - The maximum number of milliseconds to wait between requests.
* @param {Number} options.coursesToFetch - The amount of courses to fetch from each source (0 means all). Rounds up to nearest batch.
* @returns {Array} Array of courses.
*/
async function fetchCourses(source, options) {
  ...
}

Course schema

Each courses generated by this API follows the format as explained in src/course.js as shown below.

class Course {
  constructor() {
    // Information that's not expected to always be available from all sources
    this.other = {};

    // Whether or not the course can be applied to
    this.other.appliable = null;

    // The course code to apply to on antagning.se
    this.other.applicationCode = null;

    // The semester the course starts (such as 'VT-19')
    this.other.start = null;

    // The amount of "Högskolepoäng (HP)" the course consists of
    this.other.points = null;

    // The topic of the course, such as 'Mathematics'
    this.other.topic = null;

    // Name of the course
    this.name = null;

    // URL to the course page
    this.url = null;

    // The course code, such as 'MA1445'
    this.code = null;

    // Book ISBNs included in the course
    this.books = [];

    // The source institute (such as BTH)
    this.source = null;
  }
}

Contributing

Any contribution is welcome. If you're not able to code it yourself, perhaps someone else is - so post an issue if there's anything on your mind.

Development

Clone the repository:

git clone https://github.com/AlexGustafsson/institute-courses-api.git && cd institute-courses-api

Set up for development:

npm install

Follow the conventions enforced:

npm run lint
npm run test
npm run coverage
npm run check-duplicate-code

Disclaimer

Although the project is very capable, it is not built with production in mind. Therefore there might be complications when trying to use the API for large-scale projects meant for the public. The API was created to easily fetch information about books programmatically and as such it might not promote best practices nor be performant. This project is not in any way affiliated with BTH.

FAQs

Package last updated on 05 Nov 2019

Did you know?

Socket

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.

Install

Related posts

SocketSocket SOC 2 Logo

Product

About

Packages

Stay in touch

Get open source security insights delivered straight into your inbox.

  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc

U.S. Patent No. 12,346,443 & 12,314,394. Other pending.