Budgetpedia

About the API

The Budgetpedia API allows third party developers to access financial data for Toronto through a RESTful API interface. The example below allows generates charts for City expenses through HTTP GET requests.

To view city expenses, select a budget category below:

Example Request

The above example was generated by accessing the Budgetpedia API JSON endpoint and extracting object data into arrays. The arrays were used as series data in the charting framework Highcharts. Some example code is shown below.

More Extensive Documentation will be available soon!

GET Request

//DECLARE VARIABLES
var i;
function dropdownSelectVariable(){
var dropdownSelect = document.getElementById("exp-categories").value;
var newArray = new Array();
var datesArray = new Array();

//ACCESS API ENDPOINT
$.getJSON('https://getbridgeapp.co/api/budgetpedia/torontoexpenses19982016', function(result) {
console.log(result)
// CONVERT DATA TO ARRAYS
for (var i = 0; i < result.length; i++){
if (result[i].category == dropdownSelect){
 newArray.push(result[i].amount_thousands);
datesArray.push(result[i].year);    
};
});
	

Example JSON

	[
	    {
	        "category": "ENVIRONMENT",
	        "subcategory": "Environmental services",
	        "amount_thousands": 587061,
	        "year": 1998,
	        "definitions": null
	    },
	    {
	        "category": "GOVERNMENT",
	        "subcategory": "General government",
	        "amount_thousands": 593671,
	        "year": 1998,
	        "definitions": null
	    }
	]