Climate Change API
Firstly, to interact with our API you need to add the following PHP code
1
<?php
2
$contents = file_get_contents("https://api.tylermwise.com/climatechange");
3
$data = json_decode($contents);
4
?>
Copied!
After you have done that, you can use any of the following lines of code to get that specific data
1
<?php echo $data->credit; ?>
2
<?php echo $data->co2_intensity; ?>
3
<?php echo $data->biomass; ?>
4
<?php echo $data->coal; ?>
5
<?php echo $data->gas; ?>
6
<?php echo $data->nuclear; ?>
7
<?php echo $data->other; ?>
8
<?php echo $data->hydro; ?>
9
<?php echo $data->solar; ?>
10
<?php echo $data->wind; ?>
Copied!

CO2 Intensity

If you are needing to get data about the current CO2 levels, then use the following piece of code. This will either say low, medium or high:
1
<?php echo $data->co2_intensity; ?>
Copied!

Current Energy Usage

If you are needing to get the current Energy Usage, then the following code will get the percentage of the current amount of energy:
1
<?php echo $data->biomass; ?>
2
<?php echo $data->coal; ?>
3
<?php echo $data->gas; ?>
4
<?php echo $data->nuclear; ?>
5
<?php echo $data->other; ?>
6
<?php echo $data->hydro; ?>
7
<?php echo $data->solar; ?>
8
<?php echo $data->wind; ?>
Copied!

API Credit

If you would like to tell users where you got our free API from, please use the following line of code, so we can easily update it when we need too :)
1
<?php echo $data->credit; ?>
Copied!