Skip to content

pennlabs/labs-api-server

Repository files navigation

Labs API Server

CircleCI Coverage Status

Redis-backed caching server for the Open Data APIs. Intended for internal use at Penn Labs to speed up queries to Open Data.

Setup

  • Install redis
  • Install mysql
    • Mac OS X: brew install mysql and these instructions
      • If you have trouble installing mysqlclient, follow the accepted answer here, except replace the pip with pipenv
    • Debian/Ubuntu: apt-get install libmysqlclient-dev
  • Install pipenv: pip install --user --upgrade pipenv
  • Install requirements using pipenv install -d
    • If on macOS and mysql is throwing errors, try this
  • Add environment secrets to .env in the root directory
  • Enter the virtual environment using pipenv shell
  • Run mobile API server with./runserver.py

Buildings

Search

Use a word or phrase to search for a Penn building

URL https://api.pennlabs.org/buildings/search
HTTP Methods GET
Response Formats JSON
Parameters
Name Default Description Example Values
q Required The building search query Harrison, Levine Hall

By Building Code

Return the building corresponding to the given code

URL https://api.pennlabs.org/buildings/{building_code}
HTTP Methods GET
Response Formats JSON
Parameters None

Dining

Venues

Return a list of all dining venues

URL https://api.pennlabs.org/dining/venues
HTTP Methods GET
Response Formats JSON
Parameters None

Hours

Return the week's hours for the venue with venue_id

URL https://api.pennlabs.org/dining/hours/{venue_id}
HTTP Methods GET
Response Formats JSON
Parameters None

Weekly Menu

Return the week's menus for the venue with venue_id

URL https://api.pennlabs.org/dining/weekly_menu/{venue_id}
HTTP Methods GET
Response Formats JSON
Parameters None

Daily Menu

Return the daily menu for the venue with venue_id

URL https://api.pennlabs.org/dining/daily_menu/{venue_id}
HTTP Methods GET
Response Formats JSON
Parameters None

Directory

Search

Search by name in the Penn Directory

URL https://api.pennlabs.org/directory/search
HTTP Methods GET
Response Formats JSON
Parameters
Name Default Description Example Values
name Required The name to be searched for in the directory. This value is parsed into compontent parts and searched in different reasonable configurations. Alex, John Doe

Example

GET: https://api.pennlabs.org/directory/search?name=Alex%20Wissmann

Person By ID

Return the person with person_id

URL https://api.pennlabs.org/directory/person/{person_id}
HTTP Methods GET
Response Formats JSON
Parameters None

Registrar

Search

Search for courses by Department, Course Number, and Section

URL https://api.pennlabs.org/registrar/search
HTTP Methods GET
Response Formats JSON
Parameters
Name Default Description Example Values
q Required The search query for the course. cis, cis-110

Example

GET: https://api.pennlabs.org/registrar/search?q=cis-110

Laundry

All Halls

Return information on all laundry rooms

URL https://api.pennlabs.org/laundry/halls
HTTP Methods GET
Response Formats JSON
Parameters None

Hall id name location mapping

Return a list of hall names, and their corresponding ids and locations.

URL https://api.pennlabs.org/laundry/halls/ids
HTTP Methods GET
Response Formats JSON
Parameters None

Hall by hall_no

Get information for a specific room by the hall_no. hall_no is given in the All Halls response.

URL https://api.pennlabs.org/laundry/hall/{hall_no}
HTTP Methods GET
Response Formats JSON
Parameters None

Two halls by hall_no

Get information for two rooms by the hall_nos. hall_no is given in the All Halls response.

URL https://api.pennlabs.org/laundry/hall/{hall_no}/{hall_no_2}
HTTP Methods GET
Response Formats JSON
Parameters None

Multiple halls by hall_no

Get information for multiple rooms by the hall_nos. hall_no is given in the All Halls response.

URL https://api.pennlabs.org/laundry/rooms/{hall_no},{hall_no_2},{hall_no_3}
HTTP Methods GET
Response Formats JSON
Parameters None

Laundry Usage

Get information about the usage of laundry machines in a certain hall. If no date is specified, the current date is used.

URL https://api.pennlabs.org/laundry/usage/{hall_no}/{year}-{month}-{day}
HTTP Methods GET
Response Formats JSON
Parameters None

Study Spaces

All Buildings

Lists all the buildings with study rooms along with their corresponding IDs and services.

URL https://api.pennlabs.org/studyspaces/locations
HTTP Methods GET
Response Formats JSON
Parameters None

Available Rooms in One Building

Returns all the available rooms on a given date range given a building id. Dates are in the format 2018-01-28T14:00:00-0500.

URL https://api.pennlabs.org/studyspaces/availability/{building}
HTTP Methods GET
Response Formats JSON
Parameters
Name Default Description
start The current day. Range Start (YYYY-MM-DD)
end The current day. Range End (YYYY-MM-DD)

Book Room

Books a room given the room information and the user's contact information.

URL https://api.pennlabs.org/studyspaces/book
HTTP Methods POST
Response Formats JSON
Headers
Name Default Description
X-Device-ID Optional The UUID of the user booking the room.
Parameters
Name Default Description
room Required The room id.
start Required Range Start
end Required Range End
firstname Required The user's first name.
lastname Required The user's last name.
email Required The user's email.
groupname Required The purpose of the group meeting.
phone Optional The user's phone number.
size Optional The size of the meeting (ex: 2-3).

Get Reservations

Returns all the reservations for a given email and/or Wharton Session ID.

URL https://api.pennlabs.org/studyspaces/reservations
HTTP Methods GET
Response Formats JSON
Parameters
Name Default Description Example Values
email Optional The email associated with the libcal reservation(s) [email protected]
sessionid Optional A valid sessionid for the Wharton student abcdefghijklimnopqrstuvwxyz12345

Cancel Room

Cancels a room given a booking id or a list of booking ids.

URL https://api.pennlabs.org/studyspaces/cancel
HTTP Methods POST
Response Formats JSON
Headers
Name Default Description
X-Device-ID Required A valid UUID on the server. If room booked with API, must match the UUID that was used.
Parameters
Name Default Description
booking_id Required The booking id of the reservation to cancel.

Weather

Current Weather

Retrieves the current weather in Philly via the Open Weather Map API.

URL https://api.pennlabs.org/weather
HTTP Methods GET
Response Formats JSON
Parameters None

Calendar

2-Week Calendar from Current Date

Returns all events occurring 2 weeks from the current date.

URL https://api.pennlabs.org/calendar/
HTTP Methods GET
Response Formats JSON
Parameters None

2-Week Calendar from Given Date

Given a date in YYYY-MM-DDformat, returns all events occurring 2 weeks from that date.

URL https://api.pennlabs.org/calendar/{date}
HTTP Methods GET
Response Formats JSON
Parameters None

Transit

Routing

Finds a route, from all Penn Transit routes, which provides the shortest total walking distance to get from (latFrom, lonFrom) to (latTo, lonTo). If there is no path which shortens the travelers walking distance, an error is returned.

URL https://api.pennlabs.org/transit/routing
HTTP Methods GET
Response Formats JSON
Parameters
Name Default Description
latFrom Required Starting Latitude
lonFrom Required Starting Longitude
latTo Required Ending Latitude
lonTo Required Ending Longitude

Example

GET: https://api.pennlabs.org/transit/routing?latFrom=39.9533568&lonFrom=-75.2161194&latTo=39.9495731&lonTo=-75.12924031

Stops

Get information on all stops

URL https://api.pennlabs.org/transit/stops
HTTP Methods GET
Response Formats JSON
Parameters None

Routes

Get information on all routes. This has the same information as the stops endpoint, but is indexed by route.

URL https://api.pennlabs.org/transit/routes
HTTP Methods GET
Response Formats JSON
Parameters None

Fitness

Get Usage

Get approximate usage data for locations in various fitness centers.

URL https://api.pennlabs.org/fitness/usage
HTTP Methods GET
Response Formats JSON
Parameters None

Get Schedule

Get the schedule for the open hours of various fitness centers.

URL https://api.pennlabs.org/fitness/schedule
HTTP Methods GET
Response Formats JSON
Parameters None

Athletics

Documentation for the athletics endpoints is located at the Labs pennathletics library SDK repository README

Authentication

Register a user

Register a UUID on the server and create a user account

URL https://api.pennlabs.org/device/register
HTTP Methods POST
Response Formats JSON
Parameters
Name Default Description
auth_secret Required The secret key to register a user
device_id Required The UUID associated with the user's device

Validate token

Validate whether token is valid. Note: You must access this endpoint over TLS/SSL (https).

URL https://api.pennlabs.org/validate/{token}
HTTP Methods GET
Response Formats JSON
Parameters None

About

server for search for registrar, etc

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages