Skip to content

API Documentation

Alberto Gusmeroli edited this page Aug 25, 2025 · 16 revisions

If case of errors, or unless otherwise specified in the documentation, the response format is always {"message": <message>} where message describes what happened or what error occurred, excluding Server Error 500 cases.

Canteen

  • POST /notify/?time=<time>

    • Send menu to all users with notifications enabled at
    • Sent automatically by the Updater service
    • No response body
  • POST /update/

    • Fetch the menu for the following weeks
    • Sent automatically by the Updater service
    • No response body
  • POST /<id>/notification/ body json: {"time":<time>}

    • Sets the notification time for the user at
    • If is "disable" this disables menu notifications for the user
  • GET/menu/lunch?date=<date> /menu/dinner?date=<date>

    • Returns either the lunch or dinner menu for the date specified as markdown
    • response format: {"menu": <makrdown formatted string>, "date": <iso8601 string>}

Exams

  • POST /update/
    • Fetch all exams for the following sessions
    • Sent automatically by the Updater service
    • No response body
  • GET /exams/search/?query=<query>&page=<page>
    • Searches all future exams matching the <query> in either course or professor name
    • If the response is too large, it will be paginated, further pages can be accessed by using the query param
    • Response format: NOTE: Exams are formatted as tuples NOT json objects for easier handling
    {
        "exams": [
            {
                "exam_id": <id>,
                "faculty": <str>,
                "name": <str>,
                "date": <str>,
                "registration_start": <iso8601 string>,
                "registration_end": <str>,
                "partition": <str>
                "link": <str>,
                "professors": <str>,
                "is_oral": <bool>,
                "is_partial": <bool>
            },
            ...
        ],
        "n_items": <int>,
        "n_pages": <int>,
        "page": <int>,
    }
  • GET /exams/user/<id>?page=<page>

    • Gets exams the user is subscribed to
    • Exact same format as for the previous endpoint
  • POST /exams/user/<id> body json: {"courses": [ <id>, ...]}

    • Subscribes the user to a list of courses in the id

Lectures

  • POST /notify/?time=<time>

    • Send lectures to all users with notifications enabled at
    • Sent automatically by the Updater service
  • POST /update/

    • Fetch the lectures for the following weeks
    • Sent automatically by the Updater service
    • No response body
  • POST /bus_notify/?time=<time>

    • Sends a notification with the next bus time to anyone who's last lecture in povo is about to end (within 20 min of <time>)
    • Current time is used if it's not provided in the query params
    • Sent automatically by the Updater service
    • No response body
  • POST /<id>/notification/ body json: {"time":<time>}

    • Sets the notification time for the user at
    • If is "disable" this disables lecture notifications for the user
  • POST /lectures/<id> body json: {"token": <token>}

    • Sync lectures with UniTrentoApp
    • The token passed in the json body is the one you get by exporting the calendar in the app
  • GET /lectures/<id>/?date=<date>

    • Fets all lectures for the user with <id> at the specified <date>, if unspecified it is assumed today
    • Response format:
        {
            "lectures": [
                {
                    "id": <str>, #unique id for this exact lecture
                    "course_id": <str>, 
                    "event_name": <str>,
                    "lecturer": <str>,
                    "start": <iso8601 string>,
                    "end": <iso8601 string>,
                    "room": <str>, 
                    "is_cancelled": <bool>
                },
                ...
            ]
        }

  • GET /lectures/<id>/next/
    • Gets the next lecture for the user, this will return multiple values if the user has more than one concurrent lecture starting at the same time.
    • Also returns a boolean is_today flag which is true only if we are past the starting time for the last lecture of today
    • Response format is the same as for the previous, with the added "is_today" flag

Maps

  • GET /maps/<building_id>/<room_id>/
    • Shows on a map where a room is located in the floor where it's in
    • Currently only supports Povo1, Povo2 and the main building in Mesiano
    • <building_id>/ and <room_id> are in the format used internally by easyroom e.g. E0503/A102
    • Response type: PNG format image of the map.
  • GET /maps/multi/?rooms=[]
    • Returns one or more maps with all the rooms present in the query param "rooms" are highlighted
    • It will create one map per floor or building as necessary.
    • Response type: MULTIPART response of PNG images

Rooms

  • GET /rooms/<building_id>/
    • Returns the occupation state of all rooms in the building ID
    • Response format:
    {
        "building_name": <str>,
        "time": <HH:MM str>, # time of last update
        "rooms": [
            {
                "name": <str>,
                "capacity": <int>, # number of seats in room, if 0 it means the capacity is unknown
                "is_free": <bool>,
                "event": <str>, # The name of the professor or event that is happening in the room
                "time": <UNIX time int> # the time the room will change state (from busy become free or viceversa) if 0 it means the room will be free all day
            },
            ...
        ]

    }
  • GET /rooms/<building_id>/<room>/
    • get the events happening in a specific room from the current time onwards.
    • response format:
    {
        "building_name": <str>, # formatted name, not just id
        "room_name": <str>,
        "room_code": <str>,
        "capacity": <int>, # number of seats in room, if 0 it means the capacity is unknown
        "time": <HH:MM str>,
        "room_data": [
            {
                "event": <str>  # The name of the professor or event that is happening in the room
                "time": <int>  # The time when the room changes from free to busy or viceversa
                "is_free": <bool>
            },
            ...
        ]
    }

Transit

  • GET /<route_id>/<sequence>/
    • Returns information about the bus status for the selected route
    • <route_id> is an ID used internally not the route number, it also includes direction information, so for example the id 400 is the 5 line going from Povo to Trento
    • <sequence> lets you view the next scheduled busses in order, so /400/0 will return the next number 5 bus going from Povo to Trento, /400/1 will show the one after, and so on
    • Response format:
    {
         "delay": <float>, # the delay in minutes of the bus. Is null when live data is unavailable 
         "lastUpdate": <iso8601 UTC string>, # the time of the last location update from the bus. Is null when live data is unavailable 
         "currentStopIndex": <int>, # the index in the following "stop" list where the bus currently. Is null when live data is unavailable 
         "totalRoutesCount": <int>, # the number of routes for today
         "stops": [
              { 
                  "arrivalTime": <str>, # HH:MM format
                  "stopName": <str>
              },
              ...
         ]
    }

Clone this wiki locally