Skip to main content

Python API Wrapper for the Nikel API

Project description

nikel-py

PyPI Versions Build Status

A modern, easy to use, async and sync API wrapper for the nikel API written in Python.

Key Features

  • Gather Data about UofT Courses, Programs, Textbooks, Services, and more
  • Gather Data asynchronously so main event loop isn't blocked

Installation

Python 3.6 or higher is required

#Linux/macOS
python3 -m pip install -U nikel-py

#Windows
py -3 -m pip install -U nikel-py

Current list of endpoints

  • Courses
  • Programs
  • Textbooks
  • Examples
  • Evals
  • Food
  • Services
  • Buildings
  • Parking

Methods

  • get(query : Dict, limit : int=10) Synchronous
  • async_get(query : Dict, limit : int=10) Asynchronous

Basic Examples

Synchronous

from nikel_py import Courses

'''
Creates a list (limited to 1) of courses that have the name "Introduction to Computer 
Programming"
'''

x = Courses.get({'name' : 'Introduction to Computer Programming'}, limit=1)

print(x[0].code)

# >> CSC108H1

Asynchronous

import asyncio
from nikel_py import Textbooks

async def main():
    
    #Creates a list (limited to 1) of Textbooks that have the ID '10552179'
    x = await Textbooks.async_get({'id' : '10552179'}, limit=1)
    print(x[0].name)
    

asyncio.run(main())

# >> Where The Wild Things Are

Advanced Examples (Filtering & Extra Fields)

Synchronous

from nikel_py import Foods

query = {
    'coordinates.latitude' : 43.66332,
    'attributes' : '~Gluten Free'
}

'''
Creates a list (limited to 10) of Restaurants that provide Gluten Free Foods and have 
a latitude of 43.66332
'''

x = Foods.get(query, limit=10)

print(x[0].name)

# >> Second Cup Kiosk

Asynchronous

import asyncio
from nikel_py import Programs

async def main():
    
    query = {
        'campus' : 'St. George',
        'name' : '(Computer Science'
    }
    
    '''
    Creates a list (limited to 1) of Programs that start with Computer Science and 
    are done at the St. George Campus
    '''
    
    x = await Programs.async_get(query, limit=1)
    print(x[0].type)
    

asyncio.run(main())

# >> major

Filters

Operator String Numerical/Boolean
Fuzzy Search Equality
= Equality Equality
! Inequality Inequality
< N/A Less than
<= N/A Less than or equal to
> N/A Greater than
>= N/A Greater than or equal to
( Starts with N/A
) Ends with N/A
~ Serialization N/A

Note: the ~ operator essentially "yolos" and tries to search within nested arrays and hard to navigate nested structures.

For more information. Please go Here

Query & Properties Lookup Table

Note: All Objects listed below have an all_data property which returns every property in JSON format.

Courses Programs Textbooks Exams Evals Food Services Buildings Parking
id id id id id id id id id
code name isbn course_id name name name code name
name type title course_code campus description alias tags alias
description campus edition campus terms tags building_id name building_id
division description author date last_updated campus description short_name description
department enrollment image start address campus address campus
prerequisites completion price end coordinates address coordinates address
corequisites last_updated url duration hours image last_updated coordinates
exclusions courses sections image coordinates last_updated
recommended_preparation last_updated last_updated url tags
level twitter attributes
campus facebook last_updated
term attributes
arts_and_science_breadth last_updated
arts_and_science_distribution
utm_distribution
utsc_breadth
apsc_electives
meeting_sections
last_updated

For more info please refer to the Schemas of each Endpoint Here

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

nikel-py-0.1.8.tar.gz (8.9 kB view hashes)

Uploaded source

Supported by

AWS AWS Cloud computing Datadog Datadog Monitoring Facebook / Instagram Facebook / Instagram PSF Sponsor Fastly Fastly CDN Google Google Object Storage and Download Analytics Huawei Huawei PSF Sponsor Microsoft Microsoft PSF Sponsor NVIDIA NVIDIA PSF Sponsor Pingdom Pingdom Monitoring Salesforce Salesforce PSF Sponsor Sentry Sentry Error logging StatusPage StatusPage Status page