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

institute-courses-api

v1.0.2

Published

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

Downloads

4

Readme

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.