How to create a graph of Validations per line

Example tutorial to query CITIO Analytics APIs and make use of the KPI API.

Steps require to get data and know what do they correspond to are

  1. Authentification
  2. Query the Agency Lines Referential
  3. Query available Service Dates
  4. Query the Validations/Ticketing KPI

1. Authentification

For Authentification, please follow the instructions on this page.

This step is required to access all of CITiO APIs.

Please note that the session_id cookie written during step 1 will be required for all following request.

2. Query the Agency Lines Referential

For Line Referential request and response details, please check out this page.

This allow to map the line ids within the Ticketing KPI return with everything we need to know about the related lines.

Sample request

Demonstrator: https://irigo_demonstrateur.api.cit.io/rest/lines

https://test_network.api.cit.io/rest/lines

Sample response content

[
{
"colour": "#ff0000",
"id": 0,
"short_name": "A",
"name": "Nouveau tram A",
"vehicle_type": "TRAM",
"line_type": "Ligne Metropole",
},
{
"colour": "#00ff00",
"id": 1,
"short_name": "11",
"name": "Bus 11",
"vehicle_type": "BUS",
"line_type": "Centre-ville",
},
{
"colour": "#0000ff",
"id": 2,
"short_name": "12",
"name": "Bus 12",
"vehicle_type": "BUS",
"line_type": "Centre-ville",
}
]

3. Query available Service Dates

For Service Date request and response details, please check out this page.

This allow to directly request to KPI API dates that we know will return data. Here, for Validation kpis, the concerned Service Date field is num_validations.

Sample request

Demonstrator: https://irigo_demonstrateur.api.cit.io/rest/service_date

https://test_network.api.cit.io/rest/service_date

Sample response content

[[
{
"num_controls": 0,
"num_courses": 185,
"num_courses_with_counting_cells": 103,
"num_validations": 4613,
"service_date": "2021-01-04",
},
{
"num_controls": 0,
"num_courses": 184,
"num_courses_with_counting_cells": 100,
"num_validations": 4588,
"service_date": "2021-01-05",
},
{
"num_controls": 0,
"num_courses": 185,
"num_courses_with_counting_cells": 102,
"num_validations": 3231,
"service_date": "2021-01-06",
},
{
"num_controls": 0,
"num_courses": 183,
"num_courses_with_counting_cells": 100,
"num_validations": 4601,
"service_date": "2021-01-07",
},
{
"num_controls": 0,
"num_courses": 184,
"num_courses_with_counting_cells": 103,
"num_validations": 4365,
"service_date": "2021-01-08",
},
{
"num_controls": 0,
"num_courses": 130,
"num_courses_with_counting_cells": 89,
"num_validations": 0,
"service_date": "2021-01-09",
},
{
"num_controls": 0,
"num_courses": 128,
"num_courses_with_counting_cells": 87,
"num_validations": 0,
"service_date": "2021-01-10",
},
]

4. Query the Validations/Ticketing KPI

API name for Validations indicator is Ticketing.

For Ticketing KPI request and response details, please check out this page.

Sample request

  • Here we'd like the ticketing data for the whole agency, aggregated by lines: those will be our filter_level and aggregation_level.
  • We can see in the service dates that only 5 days of the week of data do have validations: this will be our included_date_perimeters.
  • We can limit the size of the API response with the use of aggregated_by_day=true, that will give us only one ticketing value for each day & line.
  • We don't need additional filter parameters.

Demonstrator: https://irigo_demonstrator.api.cit.io/kpis/ticketing/agency/line?included_date_perimeters=2021-01-04_2021-01-08_1111111&aggregated_by_day=true

https://test_network.api.cit.io/kpis/ticketing/agency/line?included_date_perimeters=2021-01-04_2021-01-08_1111111&aggregated_by_day=true

Sample response content

Note that in this situation, the filter_level_id field is not really relevant, as it corresponds only to the agency id used by the API.

[[
{
"service_date": "2021-01-04",
"filter_level_id": 86,
"aggregation_level_id": 0,
"tickets_in": 56,
"tickets_out": 52,
},
{
"service_date": "2021-01-04",
"filter_level_id": 86,
"aggregation_level_id": 1,
"tickets_in": 5,
"tickets_out": 5,
},
{
"service_date": "2021-01-04",
"filter_level_id": 86,
"aggregation_level_id": 2,
"tickets_in": 48,
"tickets_out": 47,
},
{
"service_date": "2021-01-05",
"filter_level_id": 86,
"aggregation_level_id": 0,
"tickets_in": 53,
"tickets_out": 50,
},
{
"service_date": "2021-01-05",
"filter_level_id": 86,
"aggregation_level_id": 1,
"tickets_in": 6,
"tickets_out": 5,
},
{
"service_date": "2021-01-05",
"filter_level_id": 86,
"aggregation_level_id": 2,
"tickets_in": 45,
"tickets_out": 44,
},
{
"service_date": "2021-01-06",
"filter_level_id": 86,
"aggregation_level_id": 0,
"tickets_in": 56,
"tickets_out": 52,
},
{
"service_date": "2021-01-06",
"filter_level_id": 86,
"aggregation_level_id": 2,
"tickets_in": 48,
"tickets_out": 47,
},
{
"service_date": "2021-01-07",
"filter_level_id": 86,
"aggregation_level_id": 0,
"tickets_in": 53,
"tickets_out": 50,
},
{
"service_date": "2021-01-07",
"filter_level_id": 86,
"aggregation_level_id": 1,
"tickets_in": 6,
"tickets_out": 5,
},
{
"service_date": "2021-01-07",
"filter_level_id": 86,
"aggregation_level_id": 2,
"tickets_in": 45,
"tickets_out": 44,
},
{
"service_date": "2021-01-08",
"filter_level_id": 86,
"aggregation_level_id": 0,
"tickets_in": 53,
"tickets_out": 50,
},
{
"service_date": "2021-01-08",
"filter_level_id": 86,
"aggregation_level_id": 1,
"tickets_in": 6,
"tickets_out": 5,
},
{
"service_date": "2021-01-08",
"filter_level_id": 86,
"aggregation_level_id": 2,
"tickets_in": 45,
"tickets_out": 44,
},
]

Go back to API main page.

Avez-vous trouvé ce que vous cherchiez ?

/rest/service_date

Contact