Bmycharity API

About

This is a 3rd party API providing data for bmycharity pages

Data provided via the API include variables such as, Donation amount, Gift Aid amount, Charity logo, Charity info, Donations (including messages, names, dates & amounts from users)... more details in the API section.

For any queries about how to use this, or any other comments/suggestions/feedback please contact me at jo@easyjo.com. or follow me @easyjo

Usage

The main URL for getting data for a user is: http://bmycharity-api.heroku.com/data/sallyclimbskilli2011

http://bmycharity-api.heroku.com/data/PAGE_NAME

This provides a json feed in the following format:

	{
	   "charity":"Breakthrough Breast Cancer",
	   "charity_details":"Breakthrough Breast Cancer is a pioneering charity dedicated to the prevention, treatment and ultimate eradication of breast cancer. We fight on three fronts: research, campaigning and education. Our aim is to bring together the best minds and rally the support of all those whose lives have been, or may one day be, affected by the disease. The result will save lives and change futures \u2013 by removing the fear of breast cancer for good.To find out more visit www.breakthrough.org.uk",
	   "charity_image":"http://www.bmycharity.com/asset/get/179407",
	   "details":"I am giving up the wine and fags to take part in the Windsor Half Marathon on Sep 25. I will be doing this to raise money for Breakthrough Breast Cancer (the dedicated research centre). Breast cancer effects 1 in 9 woman and you never know when it will\r\n strike. This cause is very close to my heart as one of my truly wonderful closest friend Shelley was diagnosed recently (although she is doing brilliantly and still looking stunningly gorgeous) and I would like to raise as much money as possible. The Windsor\r\n Half Marathon takes place in the great park and although it is a lovely location it unfortunately has lots of hills so I have started my training and am now regretting my debaucherous lifestyle! Thankyou all in advance for any donations that you make and lets\r\n hope I will raise lots of money (and get extremely thin!) xxxxxxxxxx",
	   "donations":[
	      {
	         "person":"Fiona Wingate",
	         "amount":"\u00a330.00",
	         "gift_aid":"0.00",
	         "message":"well done - Paul & Fiona Wingate again",
	         "date":"15/10/2005"
	      }
	   ],
	   "gift_aid":"\u00a3295.00",
	   "donations_total":"\u00a31,450.00",
	   "donations_online":"\u00a31,450.00",
	   "donations_offline":"\u00a30.00",
	   "has_target":false,
	   "target":0,
	   "percentage_complete":0,
	   "page_creator":"Emily Armstrong"
	}

JSONP version for loading data remotely, via JS

http://bmycharity-api.heroku.com/data/jsonp/PAGE_NAME/?callback=X

Example 1

This simple demo shows how you can use JQuery and the JSONP feed to display data on your domain:

<!DOCTYPE html>
<html>
<head>
        <script src="http://code.jquery.com/jquery-latest.min.js"></script>
        <script type='text/javascript'>
 		$(function() {
		     $.getJSON('http://bmycharity-api.heroku.com/data/jsonp/sallyclimbskilli2011/?callback=?', {},  function (data) {          
		            $('#raised').html(data.donations_total);
		       })
		});
        </script>
</head>
<body>
        Total raised: <span id='raised'></span>
</body>
</html>
Preview of the above
Total raised: Loading..

Example 2, Demo with donation messages

Another example, using a few more fields

<!DOCTYPE html>
<html>
<head>
        <script src="http://code.jquery.com/jquery-latest.min.js"></script>
        <script type='text/javascript'>
 		$(function() {
		     $.getJSON('http://bmycharity-api.heroku.com/data/jsonp/sallyclimbskilli2011/?callback=?', {},  function (data) {          
		            $('#raised2').html(data.donations_total);
					var donations = "";
					            $.each(data.donations, function(index, value) {                        
					                    if (index < 4)
					                    {
					                            donations  = donations + "<strong>" + value.person + "</strong> " + value.message + "<br />";
					                    }
					            });            
					            $('#donations').html(donations);
		       })
		});
        </script>
</head>
<body>
        Total raised: <span id='raised'></span>
</body>
</html>
Preview of the above

Total raised: Loading..