Giter Club home page Giter Club logo

nusmods-gem's Introduction

A ruby wrapper for the NUSModsAPI (v0.0.4)

Disclaimer

This gem is not maintained by the creator of NUSMods.

NUSModsAPI repository: https://github.com/nusmodifications/nusmods-api


Installation

gem install nusmods

or add this line into your Gemfile

gem 'nusmods'

then, run bundle install.

Changes in 0.0.4

  • Switched Faraday to HTTParty.

Usage

require 'nusmods' # => true
client = NUSMods::Client.new #  => #<NUSMods::Client:0x007f85928efb10 @base_url="http://api.nusmods.com/">

Endpoints

All methods are set to retrieve the current AY's records if you do not provide any parameters for year or semester.

Every response is either an Array or a Hash object.

Example:

client.get_module_details("MA1101R").keys
 => ["ModuleCode", "ModuleTitle", "Department", "ModuleDescription",
"ModuleCredit", "Workload", "Prerequisite", "Preclusion", "ExamDate", "Types",
"Lecturers", "IVLE", "Timetable", "CorsBiddingStats", "LecturePeriods",
"TutorialPeriods"]

Faculty Departments

Retrieves the list of faculty departments/sub-departments in a Hash.

client.get_faculty_departments(year = 2014, semester = 1)

# => {"Arts & Social Sciences"=>["Centre For Language Studies", "Chinese Studies", "Communications And New Media", "Dean's Office (Arts & Social Sc.)", ...

Lesson Types

Retrieves a list of the types of lessons in a Hash. This API call is not tied to a specific AY or semester.

client.get_lesson_types
# => {"DESIGN LECTURE"=>"Tutorial", "LABORATORY"=>"Tutorial", "LECTURE"=>"Lecture" ... 

Module codes

Retrieves a list of all module codes offered in the semester in an Array.

client.get_module_codes(year = 2014, semester = 1)
# => ["ACC1002", "ACC1002X", "ACC2002", "ACC3601", "ACC3602", ...

Module codes with names

Retrieves a list of all module codes accompanied by their names in an Array.

client.get_module_codes_with_names(year = 2014, semester = 1)
# => {"ACC1002"=>"Financial Accounting", "ACC1002X"=>"Financial Accounting", "ACC2002"=>"Managerial Accounting" ...

Module details

Retrieves all information about a specific module in a Hash

client.get_module_details("MA1101R", year = 2014, semester = 1)
# => {"ModuleCode"=>"MA1101R", "ModuleTitle"=>"Linear Algebra I", "Department"=>"Mathematics", ...

All modules

Retrieves all information about every module in an Array. Note: This retrieves a large dataset, so it will take a while. It is highly suggested that you download a copy from the API directly and store it locally.

client.get_modules(year = 2014, semester = 1)
# => [{ "ModuleCredit" => "4", "ModmavenTree" => { "name" => "ACC1002", "children" => [] }, "LockedModules" => [ "FIN3113", "ACC2002", "IS5116", "FIN2004", ...

For exact response examples or more details, see NUSMods API's README.

Tests:

gem install rspec
rspec spec/nusmods.rb

License

http://opensource.org/licenses/MIT

nusmods-gem's People

Contributors

jin avatar yangshun avatar

Stargazers

 avatar  avatar  avatar

Watchers

 avatar  avatar

nusmods-gem's Issues

NUSMods API v2

Hi there, not sure if you're still maintaining this, but we're updating API. This is because CORS is closing down at the end of this academic year, and we are working with a new data source. API v1's data will still be there, but it will not be updated anymore at the end of this year.

The API is still largely the same, though we're adding, removing and renaming some fields in the new version.

Feel free to ask if you need data that we're removing from the API

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.