Groovy Example

The following code calls the Get Regions API method that retrieves all regions under which GlobalGiving projects are categorized.

The code example makes use of the Jakarta Commons HttpClient library which can be downloaded here.

Sample Request

import org.apache.commons.httpclient.HttpClient;
import org.apache.commons.httpclient.methods.GetMethod;

def getResponseText(url) {
   def get = new GetMethod(url)
   new HttpClient().executeMethod(get)
   BufferedInputStream bis = new BufferedInputStream(get.getResponseBodyAsStream())
   return bis.getText('UTF-8')
}

def host = 'https://api.globalgiving.org'
def operation = '/api/public/projectservice/regions'
def api_key = 'YOUR_API_KEY'
def url = "${host}${operation}?api_key=${api_key}"
println getResponseText(url)

Sample Response

<?xml version="1.0" encoding="utf-8" standalone="yes"?>
<regions>
   <region>
      <name>Africa</name>
   </region>
   <region>
      <name>Asia and Oceania</name>
   </region>
   <region>
      <name>Europe and Russia</name>
   </region>
   <region>
      <name>Middle East</name>
   </region>
   <region>
      <name>North America</name>
   </region>
   <region>
      <name>South/Central America and the Caribbean</name>
   </region>
</regions>
WARNING: Javascript is currently disabled or is not available in your browser. GlobalGiving makes extensive use of Javascript and will not function properly with Javascript disabled. Please enable Javascript and refresh this page.