{ "cells": [ { "cell_type": "markdown", "metadata": {}, "source": [ "## Exercise 3 - Rest API" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "In the first task section, an interface about the services of the capital region. This interface is also used in the examples.\n", "\n", "Information about the service can be found at: https://www.hel.fi/palvelukarttaws/restpages/palvelurekisteri_en.html\n", "\n", "---\n", "\n", "In the second task section, Digitraffic's rest interface is used, to which the skills are to be applied.\n", "\n", "Information about the service can be found at: https://rata.digitraffic.fi/swagger/" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "### Tasks of the interface of the capital region's services" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Url for the interface: http://www.hel.fi/palvelukarttaws/rest/vpalvelurekisteri" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "1 Add the libraries to be used and create the interface url with `/description/`." ] }, { "cell_type": "code", "execution_count": 1, "metadata": {}, "outputs": [], "source": [ "#" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "2 Make a get request to the address and make sure that the search is successful and the response code is 200." ] }, { "cell_type": "code", "execution_count": 2, "metadata": {}, "outputs": [], "source": [ "#" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "3 Save the answer to the variable as a list whose elements are in json format." ] }, { "cell_type": "code", "execution_count": 3, "metadata": {}, "outputs": [], "source": [ "#" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "4 From the list object, select the latest json record whose `service_id` key value is 10473 (10473 has three values) and place the `id` key value of that json record in the variable." ] }, { "cell_type": "code", "execution_count": 4, "metadata": {}, "outputs": [], "source": [ "#" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "5 Make a new get request to the same address as before (also the endpoint remains the same), but take into account the variable selected in the previous point (the variable that contains the value of `id`) in the request." ] }, { "cell_type": "code", "execution_count": 5, "metadata": {}, "outputs": [], "source": [ "#" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "6 Print the value of the `title` key from the response message." ] }, { "cell_type": "code", "execution_count": 6, "metadata": {}, "outputs": [], "source": [ "#" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "---" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "### Tasks of the Digitraffic interface" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "7 Search the Digitraffic interface according to the service instructions for the train from 06.06.2018 with the trainnumber of 1." ] }, { "cell_type": "code", "execution_count": 7, "metadata": {}, "outputs": [], "source": [ "#" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "8 Create a DataFrame from the result of the get request of the previous task (from the entire data of train 1 at date 06.06.2018), if even one value of the `scheduledTime` key is before the timestamp '2018-06-06T06:00:00.000Z'." ] }, { "cell_type": "code", "execution_count": 8, "metadata": {}, "outputs": [], "source": [ "#" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "9 Print the only row from the generated DataFrame object, if one is created." ] }, { "cell_type": "code", "execution_count": 10, "metadata": {}, "outputs": [], "source": [ "#" ] } ], "metadata": { "kernelspec": { "display_name": "Python 3", "language": "python", "name": "python3" }, "language_info": { "codemirror_mode": { "name": "ipython", "version": 3 }, "file_extension": ".py", "mimetype": "text/x-python", "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", "version": "3.7.3" } }, "nbformat": 4, "nbformat_minor": 2 }