Skip to content

Instantly share code, notes, and snippets.

@diyfr
Last active March 9, 2018 11:01
Show Gist options
  • Save diyfr/019a6428d32f0f6e9fae1d3b1ae61395 to your computer and use it in GitHub Desktop.
Save diyfr/019a6428d32f0f6e9fae1d3b1ae61395 to your computer and use it in GitHub Desktop.
Rechercher un train avec les Apis SNCF https://www.digital.sncf.com/startup/api
{
"vehicle_journeys" : [{
"codes" : [],
"name" : "866324",
"journey_pattern" : {
"id" : "journey_pattern:5756",
"name" : "journey_pattern:5756"
},
"disruptions" : [{
"internal" : true,
"type" : "disruption",
"id" : "661a7e6d-8261-4244-b70b-01ca616f3dee",
"rel" : "disruptions",
"templated" : false
}, {
"internal" : true,
"type" : "disruption",
"id" : "bbdfeeec-6a2c-4667-9225-5a1767ca5628",
"rel" : "disruptions",
"templated" : false
}, {
"internal" : true,
"type" : "disruption",
"id" : "ee9d11fd-843c-4755-9ea7-92c00d02921a",
"rel" : "disruptions",
"templated" : false
}
],
"calendars" : [{
"active_periods" : [{
"begin" : "20170603",
"end" : "20170702"
}
],
"week_pattern" : {
"monday" : true,
"tuesday" : true,
"friday" : true,
"wednesday" : true,
"thursday" : true,
"sunday" : true,
"saturday" : true
}
}
],
"stop_times" : [{
"stop_point" : {
"name" : "Arcachon",
"links" : [],
"coord" : {
"lat" : "44.658905",
"lon" : "-1.165389"
},
"label" : "Arcachon (Arcachon)",
"equipments" : [],
"id" : "stop_point:OCE:SP:TrainTER-87582668"
},
"headsign" : "866324",
"departure_time" : "120400",
"arrival_time" : "120400"
}, {
"stop_point" : {
"name" : "La Teste",
"links" : [],
"coord" : {
"lat" : "44.636947",
"lon" : "-1.143"
},
"label" : "La Teste (La Teste-de-Buch)",
"equipments" : [],
"id" : "stop_point:OCE:SP:TrainTER-87582643"
},
"headsign" : "866324",
"departure_time" : "120800",
"arrival_time" : "120700"
}, {
"stop_point" : {
"name" : "La Hume",
"links" : [],
"coord" : {
"lat" : "44.639893",
"lon" : "-1.116086"
},
"label" : "La Hume (Gujan-Mestras)",
"equipments" : [],
"id" : "stop_point:OCE:SP:TrainTER-87582635"
},
"headsign" : "866324",
"departure_time" : "121200",
"arrival_time" : "121100"
}, {
"stop_point" : {
"name" : "Gujan-Mestras",
"links" : [],
"coord" : {
"lat" : "44.640502",
"lon" : "-1.069105"
},
"label" : "Gujan-Mestras (Gujan-Mestras)",
"equipments" : [],
"id" : "stop_point:OCE:SP:TrainTER-87582619"
},
"headsign" : "866324",
"departure_time" : "121600",
"arrival_time" : "121500"
}, {
"stop_point" : {
"name" : "Le Teich",
"links" : [],
"coord" : {
"lat" : "44.632425",
"lon" : "-1.025587"
},
"label" : "Le Teich (Le Teich)",
"equipments" : [],
"id" : "stop_point:OCE:SP:TrainTER-87582601"
},
"headsign" : "866324",
"departure_time" : "122000",
"arrival_time" : "121900"
}, {
"stop_point" : {
"name" : "Biganos-Facture",
"links" : [],
"coord" : {
"lat" : "44.63747",
"lon" : "-0.966042"
},
"label" : "Biganos-Facture (Biganos)",
"equipments" : [],
"id" : "stop_point:OCE:SP:TrainTER-87582478"
},
"headsign" : "866324",
"departure_time" : "122600",
"arrival_time" : "122500"
}, {
"stop_point" : {
"name" : "Marcheprime",
"links" : [],
"coord" : {
"lat" : "44.690558",
"lon" : "-0.853822"
},
"label" : "Marcheprime (Marcheprime)",
"equipments" : [],
"id" : "stop_point:OCE:SP:TrainTER-87582445"
},
"headsign" : "866324",
"departure_time" : "123300",
"arrival_time" : "123200"
}, {
"stop_point" : {
"name" : "Gazinet-Cestas",
"links" : [],
"coord" : {
"lat" : "44.772222",
"lon" : "-0.699447"
},
"label" : "Gazinet-Cestas (Cestas)",
"equipments" : [],
"id" : "stop_point:OCE:SP:TrainTER-87582403"
},
"headsign" : "866324",
"departure_time" : "124200",
"arrival_time" : "124100"
}, {
"stop_point" : {
"name" : "Alouette-France",
"links" : [],
"coord" : {
"lat" : "44.793491",
"lon" : "-0.659632"
},
"label" : "Alouette-France (Pessac)",
"equipments" : [],
"id" : "stop_point:OCE:SP:TrainTER-87581793"
},
"headsign" : "866324",
"departure_time" : "124600",
"arrival_time" : "124500"
}, {
"stop_point" : {
"name" : "Pessac",
"links" : [],
"coord" : {
"lat" : "44.804586",
"lon" : "-0.631767"
},
"label" : "Pessac (Pessac)",
"equipments" : [],
"id" : "stop_point:OCE:SP:TrainTER-87581751"
},
"headsign" : "866324",
"departure_time" : "125000",
"arrival_time" : "124900"
}, {
"stop_point" : {
"name" : "Bordeaux-St-Jean",
"links" : [],
"coord" : {
"lat" : "44.826529",
"lon" : "-0.556211"
},
"label" : "Bordeaux-St-Jean (Bordeaux)",
"equipments" : [],
"id" : "stop_point:OCE:SP:TrainTER-87581009"
},
"headsign" : "866324",
"departure_time" : "125500",
"arrival_time" : "125500"
}
],
"validity_pattern" : {
"beginning_date" : "20170602",
"days" : "000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000111111111111111111111111111110"
},
"id" : "vehicle_journey:OCE:SN866324F01002",
"trip" : {
"id" : "OCE:SN866324F01002",
"name" : "866324"
}
}
],
"disruptions" : [{
"disruption_id" : "661a7e6d-8261-4244-b70b-01ca616f3dee",
"status" : "past",
"severity" : {
"color" : "#000000",
"priority" : 42,
"name" : "trip delayed",
"effect" : "SIGNIFICANT_DELAYS"
},
"impact_id" : "661a7e6d-8261-4244-b70b-01ca616f3dee",
"application_periods" : [{
"begin" : "20170623T120400",
"end" : "20170623T125459"
}
],
"updated_at" : "20170624T001740",
"uri" : "661a7e6d-8261-4244-b70b-01ca616f3dee",
"impacted_objects" : [{
"impacted_stops" : [{
"amended_arrival_time" : "120400",
"stop_point" : {
"name" : "Arcachon",
"links" : [],
"coord" : {
"lat" : "44.658905",
"lon" : "-1.165389"
},
"label" : "Arcachon (Arcachon)",
"equipments" : [],
"id" : "stop_point:OCE:SP:TrainTER-87582668"
},
"stop_time_effect" : "unchanged",
"departure_status" : "unchanged",
"amended_departure_time" : "120400",
"base_arrival_time" : "120400",
"cause" : "",
"base_departure_time" : "120400",
"arrival_status" : "unchanged"
}, {
"amended_arrival_time" : "121200",
"stop_point" : {
"name" : "La Teste",
"links" : [],
"coord" : {
"lat" : "44.636947",
"lon" : "-1.143"
},
"label" : "La Teste (La Teste-de-Buch)",
"equipments" : [],
"id" : "stop_point:OCE:SP:TrainTER-87582643"
},
"stop_time_effect" : "delayed",
"departure_status" : "delayed",
"amended_departure_time" : "121300",
"base_arrival_time" : "120700",
"cause" : "",
"base_departure_time" : "120800",
"arrival_status" : "delayed"
}, {
"amended_arrival_time" : "121600",
"stop_point" : {
"name" : "La Hume",
"links" : [],
"coord" : {
"lat" : "44.639893",
"lon" : "-1.116086"
},
"label" : "La Hume (Gujan-Mestras)",
"equipments" : [],
"id" : "stop_point:OCE:SP:TrainTER-87582635"
},
"stop_time_effect" : "delayed",
"departure_status" : "delayed",
"amended_departure_time" : "121700",
"base_arrival_time" : "121100",
"cause" : "",
"base_departure_time" : "121200",
"arrival_status" : "delayed"
}, {
"amended_arrival_time" : "122000",
"stop_point" : {
"name" : "Gujan-Mestras",
"links" : [],
"coord" : {
"lat" : "44.640502",
"lon" : "-1.069105"
},
"label" : "Gujan-Mestras (Gujan-Mestras)",
"equipments" : [],
"id" : "stop_point:OCE:SP:TrainTER-87582619"
},
"stop_time_effect" : "delayed",
"departure_status" : "delayed",
"amended_departure_time" : "122100",
"base_arrival_time" : "121500",
"cause" : "",
"base_departure_time" : "121600",
"arrival_status" : "delayed"
}, {
"amended_arrival_time" : "122400",
"stop_point" : {
"name" : "Le Teich",
"links" : [],
"coord" : {
"lat" : "44.632425",
"lon" : "-1.025587"
},
"label" : "Le Teich (Le Teich)",
"equipments" : [],
"id" : "stop_point:OCE:SP:TrainTER-87582601"
},
"stop_time_effect" : "delayed",
"departure_status" : "delayed",
"amended_departure_time" : "122500",
"base_arrival_time" : "121900",
"cause" : "",
"base_departure_time" : "122000",
"arrival_status" : "delayed"
}, {
"amended_arrival_time" : "123000",
"stop_point" : {
"name" : "Biganos-Facture",
"links" : [],
"coord" : {
"lat" : "44.63747",
"lon" : "-0.966042"
},
"label" : "Biganos-Facture (Biganos)",
"equipments" : [],
"id" : "stop_point:OCE:SP:TrainTER-87582478"
},
"stop_time_effect" : "delayed",
"departure_status" : "delayed",
"amended_departure_time" : "123100",
"base_arrival_time" : "122500",
"cause" : "",
"base_departure_time" : "122600",
"arrival_status" : "delayed"
}, {
"amended_arrival_time" : "123700",
"stop_point" : {
"name" : "Marcheprime",
"links" : [],
"coord" : {
"lat" : "44.690558",
"lon" : "-0.853822"
},
"label" : "Marcheprime (Marcheprime)",
"equipments" : [],
"id" : "stop_point:OCE:SP:TrainTER-87582445"
},
"stop_time_effect" : "delayed",
"departure_status" : "delayed",
"amended_departure_time" : "123800",
"base_arrival_time" : "123200",
"cause" : "",
"base_departure_time" : "123300",
"arrival_status" : "delayed"
}, {
"amended_arrival_time" : "124600",
"stop_point" : {
"name" : "Gazinet-Cestas",
"links" : [],
"coord" : {
"lat" : "44.772222",
"lon" : "-0.699447"
},
"label" : "Gazinet-Cestas (Cestas)",
"equipments" : [],
"id" : "stop_point:OCE:SP:TrainTER-87582403"
},
"stop_time_effect" : "delayed",
"departure_status" : "delayed",
"amended_departure_time" : "124700",
"base_arrival_time" : "124100",
"cause" : "",
"base_departure_time" : "124200",
"arrival_status" : "delayed"
}, {
"amended_arrival_time" : "125000",
"stop_point" : {
"name" : "Alouette-France",
"links" : [],
"coord" : {
"lat" : "44.793491",
"lon" : "-0.659632"
},
"label" : "Alouette-France (Pessac)",
"equipments" : [],
"id" : "stop_point:OCE:SP:TrainTER-87581793"
},
"stop_time_effect" : "delayed",
"departure_status" : "delayed",
"amended_departure_time" : "125100",
"base_arrival_time" : "124500",
"cause" : "",
"base_departure_time" : "124600",
"arrival_status" : "delayed"
}, {
"amended_arrival_time" : "125400",
"stop_point" : {
"name" : "Pessac",
"links" : [],
"coord" : {
"lat" : "44.804586",
"lon" : "-0.631767"
},
"label" : "Pessac (Pessac)",
"equipments" : [],
"id" : "stop_point:OCE:SP:TrainTER-87581751"
},
"stop_time_effect" : "delayed",
"departure_status" : "delayed",
"amended_departure_time" : "125500",
"base_arrival_time" : "124900",
"cause" : "",
"base_departure_time" : "125000",
"arrival_status" : "delayed"
}, {
"amended_arrival_time" : "125500",
"stop_point" : {
"name" : "Bordeaux-St-Jean",
"links" : [],
"coord" : {
"lat" : "44.826529",
"lon" : "-0.556211"
},
"label" : "Bordeaux-St-Jean (Bordeaux)",
"equipments" : [],
"id" : "stop_point:OCE:SP:TrainTER-87581009"
},
"stop_time_effect" : "delayed",
"departure_status" : "delayed",
"amended_departure_time" : "130000",
"base_arrival_time" : "125500",
"cause" : "",
"base_departure_time" : "125500",
"arrival_status" : "unchanged"
}
],
"pt_object" : {
"embedded_type" : "trip",
"id" : "OCE:SN866324F01002",
"quality" : 0,
"name" : "OCE:SN866324F01002",
"trip" : {
"id" : "OCE:SN866324F01002",
"name" : "866324"
}
}
}
],
"id" : "661a7e6d-8261-4244-b70b-01ca616f3dee",
"contributor" : "",
"cause" : "",
"disruption_uri" : "661a7e6d-8261-4244-b70b-01ca616f3dee"
}, {
"disruption_id" : "ee9d11fd-843c-4755-9ea7-92c00d02921a",
"status" : "past",
"severity" : {
"color" : "#000000",
"priority" : 42,
"name" : "trip delayed",
"effect" : "SIGNIFICANT_DELAYS"
},
"impact_id" : "ee9d11fd-843c-4755-9ea7-92c00d02921a",
"application_periods" : [{
"begin" : "20170625T120400",
"end" : "20170625T125959"
}
],
"updated_at" : "20170625T123151",
"uri" : "ee9d11fd-843c-4755-9ea7-92c00d02921a",
"impacted_objects" : [{
"impacted_stops" : [{
"amended_arrival_time" : "120400",
"stop_point" : {
"name" : "Arcachon",
"links" : [],
"coord" : {
"lat" : "44.658905",
"lon" : "-1.165389"
},
"label" : "Arcachon (Arcachon)",
"equipments" : [],
"id" : "stop_point:OCE:SP:TrainTER-87582668"
},
"stop_time_effect" : "unchanged",
"departure_status" : "unchanged",
"amended_departure_time" : "120400",
"base_arrival_time" : "120400",
"cause" : "",
"base_departure_time" : "120400",
"arrival_status" : "unchanged"
}, {
"amended_arrival_time" : "120700",
"stop_point" : {
"name" : "La Teste",
"links" : [],
"coord" : {
"lat" : "44.636947",
"lon" : "-1.143"
},
"label" : "La Teste (La Teste-de-Buch)",
"equipments" : [],
"id" : "stop_point:OCE:SP:TrainTER-87582643"
},
"stop_time_effect" : "unchanged",
"departure_status" : "unchanged",
"amended_departure_time" : "120800",
"base_arrival_time" : "120700",
"cause" : "",
"base_departure_time" : "120800",
"arrival_status" : "unchanged"
}, {
"amended_arrival_time" : "121100",
"stop_point" : {
"name" : "La Hume",
"links" : [],
"coord" : {
"lat" : "44.639893",
"lon" : "-1.116086"
},
"label" : "La Hume (Gujan-Mestras)",
"equipments" : [],
"id" : "stop_point:OCE:SP:TrainTER-87582635"
},
"stop_time_effect" : "unchanged",
"departure_status" : "unchanged",
"amended_departure_time" : "121200",
"base_arrival_time" : "121100",
"cause" : "",
"base_departure_time" : "121200",
"arrival_status" : "unchanged"
}, {
"amended_arrival_time" : "121500",
"stop_point" : {
"name" : "Gujan-Mestras",
"links" : [],
"coord" : {
"lat" : "44.640502",
"lon" : "-1.069105"
},
"label" : "Gujan-Mestras (Gujan-Mestras)",
"equipments" : [],
"id" : "stop_point:OCE:SP:TrainTER-87582619"
},
"stop_time_effect" : "unchanged",
"departure_status" : "unchanged",
"amended_departure_time" : "121600",
"base_arrival_time" : "121500",
"cause" : "",
"base_departure_time" : "121600",
"arrival_status" : "unchanged"
}, {
"amended_arrival_time" : "121900",
"stop_point" : {
"name" : "Le Teich",
"links" : [],
"coord" : {
"lat" : "44.632425",
"lon" : "-1.025587"
},
"label" : "Le Teich (Le Teich)",
"equipments" : [],
"id" : "stop_point:OCE:SP:TrainTER-87582601"
},
"stop_time_effect" : "unchanged",
"departure_status" : "unchanged",
"amended_departure_time" : "122000",
"base_arrival_time" : "121900",
"cause" : "",
"base_departure_time" : "122000",
"arrival_status" : "unchanged"
}, {
"amended_arrival_time" : "122500",
"stop_point" : {
"name" : "Biganos-Facture",
"links" : [],
"coord" : {
"lat" : "44.63747",
"lon" : "-0.966042"
},
"label" : "Biganos-Facture (Biganos)",
"equipments" : [],
"id" : "stop_point:OCE:SP:TrainTER-87582478"
},
"stop_time_effect" : "unchanged",
"departure_status" : "unchanged",
"amended_departure_time" : "122600",
"base_arrival_time" : "122500",
"cause" : "",
"base_departure_time" : "122600",
"arrival_status" : "unchanged"
}, {
"amended_arrival_time" : "123700",
"stop_point" : {
"name" : "Marcheprime",
"links" : [],
"coord" : {
"lat" : "44.690558",
"lon" : "-0.853822"
},
"label" : "Marcheprime (Marcheprime)",
"equipments" : [],
"id" : "stop_point:OCE:SP:TrainTER-87582445"
},
"stop_time_effect" : "delayed",
"departure_status" : "delayed",
"amended_departure_time" : "123800",
"base_arrival_time" : "123200",
"cause" : "",
"base_departure_time" : "123300",
"arrival_status" : "delayed"
}, {
"amended_arrival_time" : "124600",
"stop_point" : {
"name" : "Gazinet-Cestas",
"links" : [],
"coord" : {
"lat" : "44.772222",
"lon" : "-0.699447"
},
"label" : "Gazinet-Cestas (Cestas)",
"equipments" : [],
"id" : "stop_point:OCE:SP:TrainTER-87582403"
},
"stop_time_effect" : "delayed",
"departure_status" : "delayed",
"amended_departure_time" : "124700",
"base_arrival_time" : "124100",
"cause" : "",
"base_departure_time" : "124200",
"arrival_status" : "delayed"
}, {
"amended_arrival_time" : "125000",
"stop_point" : {
"name" : "Alouette-France",
"links" : [],
"coord" : {
"lat" : "44.793491",
"lon" : "-0.659632"
},
"label" : "Alouette-France (Pessac)",
"equipments" : [],
"id" : "stop_point:OCE:SP:TrainTER-87581793"
},
"stop_time_effect" : "delayed",
"departure_status" : "delayed",
"amended_departure_time" : "125100",
"base_arrival_time" : "124500",
"cause" : "",
"base_departure_time" : "124600",
"arrival_status" : "delayed"
}, {
"amended_arrival_time" : "125400",
"stop_point" : {
"name" : "Pessac",
"links" : [],
"coord" : {
"lat" : "44.804586",
"lon" : "-0.631767"
},
"label" : "Pessac (Pessac)",
"equipments" : [],
"id" : "stop_point:OCE:SP:TrainTER-87581751"
},
"stop_time_effect" : "delayed",
"departure_status" : "delayed",
"amended_departure_time" : "125500",
"base_arrival_time" : "124900",
"cause" : "",
"base_departure_time" : "125000",
"arrival_status" : "delayed"
}, {
"amended_arrival_time" : "130000",
"stop_point" : {
"name" : "Bordeaux-St-Jean",
"links" : [],
"coord" : {
"lat" : "44.826529",
"lon" : "-0.556211"
},
"label" : "Bordeaux-St-Jean (Bordeaux)",
"equipments" : [],
"id" : "stop_point:OCE:SP:TrainTER-87581009"
},
"stop_time_effect" : "delayed",
"departure_status" : "delayed",
"amended_departure_time" : "130000",
"base_arrival_time" : "125500",
"cause" : "",
"base_departure_time" : "125500",
"arrival_status" : "delayed"
}
],
"pt_object" : {
"embedded_type" : "trip",
"id" : "OCE:SN866324F01002",
"quality" : 0,
"name" : "OCE:SN866324F01002",
"trip" : {
"id" : "OCE:SN866324F01002",
"name" : "866324"
}
}
}
],
"id" : "ee9d11fd-843c-4755-9ea7-92c00d02921a",
"contributor" : "",
"cause" : "",
"disruption_uri" : "ee9d11fd-843c-4755-9ea7-92c00d02921a"
}, {
"disruption_id" : "bbdfeeec-6a2c-4667-9225-5a1767ca5628",
"status" : "past",
"severity" : {
"color" : "#000000",
"priority" : 42,
"name" : "trip delayed",
"effect" : "SIGNIFICANT_DELAYS"
},
"impact_id" : "bbdfeeec-6a2c-4667-9225-5a1767ca5628",
"application_periods" : [{
"begin" : "20170615T120400",
"end" : "20170615T125959"
}
],
"updated_at" : "20170624T001740",
"uri" : "bbdfeeec-6a2c-4667-9225-5a1767ca5628",
"impacted_objects" : [{
"impacted_stops" : [{
"amended_arrival_time" : "120400",
"stop_point" : {
"name" : "Arcachon",
"links" : [],
"coord" : {
"lat" : "44.658905",
"lon" : "-1.165389"
},
"label" : "Arcachon (Arcachon)",
"equipments" : [],
"id" : "stop_point:OCE:SP:TrainTER-87582668"
},
"stop_time_effect" : "unchanged",
"departure_status" : "unchanged",
"amended_departure_time" : "120400",
"base_arrival_time" : "120400",
"cause" : "",
"base_departure_time" : "120400",
"arrival_status" : "unchanged"
}, {
"amended_arrival_time" : "120700",
"stop_point" : {
"name" : "La Teste",
"links" : [],
"coord" : {
"lat" : "44.636947",
"lon" : "-1.143"
},
"label" : "La Teste (La Teste-de-Buch)",
"equipments" : [],
"id" : "stop_point:OCE:SP:TrainTER-87582643"
},
"stop_time_effect" : "unchanged",
"departure_status" : "unchanged",
"amended_departure_time" : "120800",
"base_arrival_time" : "120700",
"cause" : "",
"base_departure_time" : "120800",
"arrival_status" : "unchanged"
}, {
"amended_arrival_time" : "121100",
"stop_point" : {
"name" : "La Hume",
"links" : [],
"coord" : {
"lat" : "44.639893",
"lon" : "-1.116086"
},
"label" : "La Hume (Gujan-Mestras)",
"equipments" : [],
"id" : "stop_point:OCE:SP:TrainTER-87582635"
},
"stop_time_effect" : "unchanged",
"departure_status" : "unchanged",
"amended_departure_time" : "121200",
"base_arrival_time" : "121100",
"cause" : "",
"base_departure_time" : "121200",
"arrival_status" : "unchanged"
}, {
"amended_arrival_time" : "121500",
"stop_point" : {
"name" : "Gujan-Mestras",
"links" : [],
"coord" : {
"lat" : "44.640502",
"lon" : "-1.069105"
},
"label" : "Gujan-Mestras (Gujan-Mestras)",
"equipments" : [],
"id" : "stop_point:OCE:SP:TrainTER-87582619"
},
"stop_time_effect" : "unchanged",
"departure_status" : "unchanged",
"amended_departure_time" : "121600",
"base_arrival_time" : "121500",
"cause" : "",
"base_departure_time" : "121600",
"arrival_status" : "unchanged"
}, {
"amended_arrival_time" : "121900",
"stop_point" : {
"name" : "Le Teich",
"links" : [],
"coord" : {
"lat" : "44.632425",
"lon" : "-1.025587"
},
"label" : "Le Teich (Le Teich)",
"equipments" : [],
"id" : "stop_point:OCE:SP:TrainTER-87582601"
},
"stop_time_effect" : "unchanged",
"departure_status" : "unchanged",
"amended_departure_time" : "122000",
"base_arrival_time" : "121900",
"cause" : "",
"base_departure_time" : "122000",
"arrival_status" : "unchanged"
}, {
"amended_arrival_time" : "122500",
"stop_point" : {
"name" : "Biganos-Facture",
"links" : [],
"coord" : {
"lat" : "44.63747",
"lon" : "-0.966042"
},
"label" : "Biganos-Facture (Biganos)",
"equipments" : [],
"id" : "stop_point:OCE:SP:TrainTER-87582478"
},
"stop_time_effect" : "unchanged",
"departure_status" : "unchanged",
"amended_departure_time" : "122600",
"base_arrival_time" : "122500",
"cause" : "",
"base_departure_time" : "122600",
"arrival_status" : "unchanged"
}, {
"amended_arrival_time" : "123700",
"stop_point" : {
"name" : "Marcheprime",
"links" : [],
"coord" : {
"lat" : "44.690558",
"lon" : "-0.853822"
},
"label" : "Marcheprime (Marcheprime)",
"equipments" : [],
"id" : "stop_point:OCE:SP:TrainTER-87582445"
},
"stop_time_effect" : "delayed",
"departure_status" : "delayed",
"amended_departure_time" : "123800",
"base_arrival_time" : "123200",
"cause" : "",
"base_departure_time" : "123300",
"arrival_status" : "delayed"
}, {
"amended_arrival_time" : "124600",
"stop_point" : {
"name" : "Gazinet-Cestas",
"links" : [],
"coord" : {
"lat" : "44.772222",
"lon" : "-0.699447"
},
"label" : "Gazinet-Cestas (Cestas)",
"equipments" : [],
"id" : "stop_point:OCE:SP:TrainTER-87582403"
},
"stop_time_effect" : "delayed",
"departure_status" : "delayed",
"amended_departure_time" : "124700",
"base_arrival_time" : "124100",
"cause" : "",
"base_departure_time" : "124200",
"arrival_status" : "delayed"
}, {
"amended_arrival_time" : "125000",
"stop_point" : {
"name" : "Alouette-France",
"links" : [],
"coord" : {
"lat" : "44.793491",
"lon" : "-0.659632"
},
"label" : "Alouette-France (Pessac)",
"equipments" : [],
"id" : "stop_point:OCE:SP:TrainTER-87581793"
},
"stop_time_effect" : "delayed",
"departure_status" : "delayed",
"amended_departure_time" : "125100",
"base_arrival_time" : "124500",
"cause" : "",
"base_departure_time" : "124600",
"arrival_status" : "delayed"
}, {
"amended_arrival_time" : "125400",
"stop_point" : {
"name" : "Pessac",
"links" : [],
"coord" : {
"lat" : "44.804586",
"lon" : "-0.631767"
},
"label" : "Pessac (Pessac)",
"equipments" : [],
"id" : "stop_point:OCE:SP:TrainTER-87581751"
},
"stop_time_effect" : "delayed",
"departure_status" : "delayed",
"amended_departure_time" : "125500",
"base_arrival_time" : "124900",
"cause" : "",
"base_departure_time" : "125000",
"arrival_status" : "delayed"
}, {
"amended_arrival_time" : "130000",
"stop_point" : {
"name" : "Bordeaux-St-Jean",
"links" : [],
"coord" : {
"lat" : "44.826529",
"lon" : "-0.556211"
},
"label" : "Bordeaux-St-Jean (Bordeaux)",
"equipments" : [],
"id" : "stop_point:OCE:SP:TrainTER-87581009"
},
"stop_time_effect" : "delayed",
"departure_status" : "delayed",
"amended_departure_time" : "130000",
"base_arrival_time" : "125500",
"cause" : "",
"base_departure_time" : "125500",
"arrival_status" : "delayed"
}
],
"pt_object" : {
"embedded_type" : "trip",
"id" : "OCE:SN866324F01002",
"quality" : 0,
"name" : "OCE:SN866324F01002",
"trip" : {
"id" : "OCE:SN866324F01002",
"name" : "866324"
}
}
}
],
"id" : "bbdfeeec-6a2c-4667-9225-5a1767ca5628",
"contributor" : "",
"cause" : "",
"disruption_uri" : "bbdfeeec-6a2c-4667-9225-5a1767ca5628"
}
],
"pagination" : {
"start_page" : 0,
"items_on_page" : 1,
"items_per_page" : 25,
"total_result" : 1
},
"links" : [{
"href" : "https:\/\/api.sncf.com\/v1\/coverage\/sncf\/stop_points\/{stop_point.id}",
"type" : "stop_point",
"rel" : "stop_points",
"templated" : true
}, {
"href" : "https:\/\/api.sncf.com\/v1\/coverage\/sncf\/journey_patterns\/{journey_pattern.id}",
"type" : "journey_pattern",
"rel" : "journey_patterns",
"templated" : true
}, {
"href" : "https:\/\/api.sncf.com\/v1\/coverage\/sncf\/disruptions\/{disruptions.id}",
"type" : "disruptions",
"rel" : "disruptions",
"templated" : true
}, {
"href" : "https:\/\/api.sncf.com\/v1\/coverage\/sncf\/disruptions\/{disruption.id}",
"type" : "disruption",
"rel" : "disruptions",
"templated" : true
}, {
"href" : "https:\/\/api.sncf.com\/v1\/coverage\/sncf\/vehicle_journeys\/{vehicle_journeys.id}",
"type" : "vehicle_journeys",
"rel" : "vehicle_journeys",
"templated" : true
}, {
"href" : "https:\/\/api.sncf.com\/v1\/coverage\/sncf\/trips\/{trip.id}",
"type" : "trip",
"rel" : "trips",
"templated" : true
}, {
"href" : "https:\/\/api.sncf.com\/v1\/coverage\/sncf\/vehicle_journeys?since=20170626T000000&until=20170626T235959&headsign=866324",
"type" : "first",
"templated" : false
}
],
"feed_publishers" : []
}
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<meta http-equiv="cache-control" content="max-age=0" />
<meta http-equiv="cache-control" content="no-cache" />
<meta http-equiv="expires" content="0" />
<meta http-equiv="expires" content="Tue, 01 Jan 1980 1:00:00 GMT" />
<meta http-equiv="pragma" content="no-cache" />
<title>Train Api fo Angular</title>
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.6.4/angular.min.js"></script>
</head>
<body>
<div ng-app="app" ng-controller="VehicleJourneysCtrl">
<h5>Affiche les horaires d'un train</h5>
Saisissez votre numéro de train puis votre clé API et appuyez sur entrée <br/>
Numéro de train :
<input type="text" name="numeroTrain" ng-model="numeroTrain" required placeholder="saisissez votre numéro de train"><br/>
Clé API (<a href="https://data.sncf.com/api">https://data.sncf.com/api</a>)
<input type="text" name="apiKey" ng-model="apiKey" required ng-keypress="($event.charCode==13)? search() : return" placeholder="<Entrée> pour valider">
<br/> <span style="color:red">{{error}}</span>
<pre>
{{vehicleJourney.name}} : {{vehicleJourney.from}}({{vehicleJourney.fromDeparture}}) -> {{vehicleJourney.to}}({{vehicleJourney.toArrival}})
</pre>
<ul>
<li ng-repeat="stopTime in vehicleJourney.stop_times">
{{stopTime.stop_point.label}} - <em>{{stopTime.arrival_time}}:{{stopTime.departure_time}}</em>
<!-- SAMPLE stoptime value
"stop_times" : [{
"arrival_time" : "111800",
"headsign" : "860006",
"departure_time" : "111800",
"stop_point" : {
"name" : "Nantes",
"links" : [],
"coord" : {
"lat" : "47.217516",
"lon" : "-1.541943"
},
"label" : "Nantes (Nantes)",
"equipments" : [],
"id" : "stop_point:OCE:SP:TrainTER-87481002"
}
}
-->
</li>
</ul>
</div>
<script>
// since et until correspondant au jour courant
var d = new Date();
var since = d.getFullYear()+("00" + (d.getMonth() + 1)).slice(-2)+ ("00" + d.getDate()).slice(-2) + "T000000";
var until = d.getFullYear()+("00" + (d.getMonth() + 1)).slice(-2)+ ("00" + d.getDate()).slice(-2) + "T235959";
// exemple de recherche du 860006
var urlBase ="https://api.sncf.com/v1/coverage/sncf/vehicle_journeys?headsign={NUMERO_TRAIN}&since="+since+"&until="+until;
// ANGULAR....
var app = angular.module('app', []);
app.controller("VehicleJourneysCtrl", function($scope, $http) {
$scope.search= function(){
$scope.vehicleJourney =undefined;
var url=urlBase.replace("{NUMERO_TRAIN}",$scope.numeroTrain);
console.log("url:"+ typeof urlResult);
authorizationHeader = "Basic "+btoa($scope.apiKey);
$http({method:"GET", url, headers:{"Authorization":authorizationHeader, "Accept":"application/json"}}
).then(function(res){
if (res.data.vehicle_journeys){
$scope.vehicleJourney = res.data.vehicle_journeys[0];
$scope.vehicleJourney.from = $scope.vehicleJourney.stop_times[0].stop_point.name;
$scope.vehicleJourney.fromDeparture = $scope.vehicleJourney.stop_times[0].departure_time;
$scope.vehicleJourney.to = $scope.vehicleJourney.stop_times[$scope.vehicleJourney.stop_times.length-1].stop_point.name;
$scope.vehicleJourney.toArrival = $scope.vehicleJourney.stop_times[$scope.vehicleJourney.stop_times.length-1].arrival_time;
$scope.error=undefined;
}else{
$scope.error="Erreur dans la réponse";
}
},
function(error){
$scope.error="Introuvable";
}
);
};
});
</script>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment