{"_id":"5499615f9da9390b00cffadb","__v":13,"category":{"_id":"5499610f0195cc0b00dc32e2","pages":["549961290195cc0b00dc32e3","549961320195cc0b00dc32e5","5499613c0195cc0b00dc32e7","549961499da9390b00cffad7","549961549da9390b00cffad9","5499615f9da9390b00cffadb","5499646c0195cc0b00dc32fb","549a60225b50c21400fae6b8","54cbbea561698d0d00baf85d"],"project":"54995cb59da9390b00cffac6","version":"54995cb59da9390b00cffac9","__v":9,"sync":{"url":"","isSync":false},"reference":false,"createdAt":"2014-12-23T12:33:19.815Z","from_sync":false,"order":9999,"slug":"api-reference","title":"API Reference"},"githubsync":"","version":{"_id":"54995cb59da9390b00cffac9","__v":3,"project":"54995cb59da9390b00cffac6","createdAt":"2014-12-23T12:14:45.422Z","releaseDate":"2014-12-23T12:14:45.422Z","categories":["54995cb59da9390b00cffaca","54995e289da9390b00cffad0","5499610f0195cc0b00dc32e2"],"is_deprecated":false,"is_hidden":false,"is_beta":true,"is_stable":true,"codename":"","version_clean":"1.0.0","version":"1.0"},"project":"54995cb59da9390b00cffac6","user":"54995c979da9390b00cffac5","metadata":{"title":"","description":"","image":[]},"updates":[],"next":{"pages":[],"description":""},"createdAt":"2014-12-23T12:34:39.931Z","link_external":false,"link_url":"","sync_unique":"","hidden":false,"api":{"results":{"codes":[]},"settings":"","auth":"required","params":[],"url":""},"isReference":false,"order":7,"body":"The `vehicle_locations` endpoint provides real-time information on the position of all buses and trams that are currently in service.\n[block:callout]\n{\n  \"type\": \"info\",\n  \"title\": \"Limitations\",\n  \"body\": \"This endpoint uses the on-board Wi-Fi routers on each vehicle to determine the vehicle's location. If the Wi-Fi router is unavailable, no information will be given for that bus.\\n\\nThere can be a noticeable lag time (up to 60 seconds) between the vehicle broadcasting it's latest location and that location appearing within this endpoint.\\n\\nSometimes, the API will be unable to determine a vehicle's current service and destination, only the vehicle's fleet ID, speed and location. `service_name` and `destination` will be returned as null.\"\n}\n[/block]\n## Update frequency\n\nEvery 15 seconds\n\n## Resource\n\n    GET /v1/vehicle_locations\n\n## Authorisation\n\nAPI Authentication Token\n\n## Response\n\n    Status-Code: 200 OK\n[block:code]\n{\n  \"codes\": [\n    {\n      \"code\": \"{\\n    \\\"last_updated\\\": 1419342676,\\n    \\\"vehicles\\\": [\\n        {\\n            \\\"vehicle_id\\\": \\\"173\\\",\\n            \\\"last_gps_fix\\\": 1419342659,\\n            \\\"latitude\\\": 55.949443,\\n            \\\"longitude\\\": -2.867246,\\n            \\\"speed\\\": 26,\\n            \\\"heading\\\": 74,\\n            \\\"service_name\\\": \\\"104\\\",\\n            \\\"destination\\\": \\\"West End\\\"\\n        },\\n        {\\n            \\\"vehicle_id\\\": \\\"171\\\",\\n            \\\"last_gps_fix\\\": 1419342634,\\n            \\\"latitude\\\": 55.943604,\\n            \\\"longitude\\\": -3.116166,\\n            \\\"speed\\\": 5,\\n            \\\"heading\\\": 265,\\n            \\\"service_name\\\": \\\"104\\\",\\n            \\\"destination\\\": \\\"Haddington\\\"\\n        },\\n        ...\\n    ]\\n}\",\n      \"language\": \"json\"\n    }\n  ]\n}\n[/block]\n\n[block:parameters]\n{\n  \"data\": {\n    \"0-0\": \"`last_updated`\",\n    \"0-1\": \"int\",\n    \"0-2\": \"The time that this endpoint was last updated\",\n    \"1-0\": \"`vehicle_id`\",\n    \"1-1\": \"string\",\n    \"1-2\": \"The fleet ID of the vehicle\",\n    \"2-0\": \"`last_gps_fix`\",\n    \"2-1\": \"int\",\n    \"2-2\": \"The last time the vehicle broadcasted its location\",\n    \"3-0\": \"`latitude`\",\n    \"3-1\": \"float\",\n    \"3-2\": \"The most recently broadcasted latitude of the vehicle\",\n    \"4-0\": \"`longitude`\",\n    \"4-1\": \"float\",\n    \"4-2\": \"The most recently broadcasted longitude of the vehicle\",\n    \"5-0\": \"`speed`\",\n    \"5-1\": \"int\",\n    \"5-2\": \"The speed (in miles per hour) of the vehicle\",\n    \"6-0\": \"`heading`\",\n    \"6-1\": \"int\",\n    \"6-2\": \"The heading (in degrees, 0-360) of the vehicle\",\n    \"7-0\": \"`service_name`\",\n    \"7-1\": \"string\",\n    \"7-2\": \"The service that the vehicle is currently operating on\",\n    \"8-0\": \"`destination`\",\n    \"8-1\": \"string\",\n    \"8-2\": \"The destination displayed on the vehicle's destination board\",\n    \"h-0\": \"Name\",\n    \"h-1\": \"Type\",\n    \"h-2\": \"Description\",\n    \"9-0\": \"`journey_id`\",\n    \"9-1\": \"int\",\n    \"9-2\": \"The vehicle's current `journeyId` as used by the MyBusTracker API\",\n    \"10-0\": \"`reference_stop_id`\",\n    \"10-1\": \"int\",\n    \"10-2\": \"The stop used to get the vehicle's `service_name`, `destination` and `journey_id` - useful when requesting data from the MyBusTracker API\"\n  },\n  \"cols\": 3,\n  \"rows\": 11\n}\n[/block]","excerpt":"","slug":"live-bus-positions","type":"basic","title":"Live vehicle locations"}

Live vehicle locations


The `vehicle_locations` endpoint provides real-time information on the position of all buses and trams that are currently in service. [block:callout] { "type": "info", "title": "Limitations", "body": "This endpoint uses the on-board Wi-Fi routers on each vehicle to determine the vehicle's location. If the Wi-Fi router is unavailable, no information will be given for that bus.\n\nThere can be a noticeable lag time (up to 60 seconds) between the vehicle broadcasting it's latest location and that location appearing within this endpoint.\n\nSometimes, the API will be unable to determine a vehicle's current service and destination, only the vehicle's fleet ID, speed and location. `service_name` and `destination` will be returned as null." } [/block] ## Update frequency Every 15 seconds ## Resource GET /v1/vehicle_locations ## Authorisation API Authentication Token ## Response Status-Code: 200 OK [block:code] { "codes": [ { "code": "{\n \"last_updated\": 1419342676,\n \"vehicles\": [\n {\n \"vehicle_id\": \"173\",\n \"last_gps_fix\": 1419342659,\n \"latitude\": 55.949443,\n \"longitude\": -2.867246,\n \"speed\": 26,\n \"heading\": 74,\n \"service_name\": \"104\",\n \"destination\": \"West End\"\n },\n {\n \"vehicle_id\": \"171\",\n \"last_gps_fix\": 1419342634,\n \"latitude\": 55.943604,\n \"longitude\": -3.116166,\n \"speed\": 5,\n \"heading\": 265,\n \"service_name\": \"104\",\n \"destination\": \"Haddington\"\n },\n ...\n ]\n}", "language": "json" } ] } [/block] [block:parameters] { "data": { "0-0": "`last_updated`", "0-1": "int", "0-2": "The time that this endpoint was last updated", "1-0": "`vehicle_id`", "1-1": "string", "1-2": "The fleet ID of the vehicle", "2-0": "`last_gps_fix`", "2-1": "int", "2-2": "The last time the vehicle broadcasted its location", "3-0": "`latitude`", "3-1": "float", "3-2": "The most recently broadcasted latitude of the vehicle", "4-0": "`longitude`", "4-1": "float", "4-2": "The most recently broadcasted longitude of the vehicle", "5-0": "`speed`", "5-1": "int", "5-2": "The speed (in miles per hour) of the vehicle", "6-0": "`heading`", "6-1": "int", "6-2": "The heading (in degrees, 0-360) of the vehicle", "7-0": "`service_name`", "7-1": "string", "7-2": "The service that the vehicle is currently operating on", "8-0": "`destination`", "8-1": "string", "8-2": "The destination displayed on the vehicle's destination board", "h-0": "Name", "h-1": "Type", "h-2": "Description", "9-0": "`journey_id`", "9-1": "int", "9-2": "The vehicle's current `journeyId` as used by the MyBusTracker API", "10-0": "`reference_stop_id`", "10-1": "int", "10-2": "The stop used to get the vehicle's `service_name`, `destination` and `journey_id` - useful when requesting data from the MyBusTracker API" }, "cols": 3, "rows": 11 } [/block]