GuideStar API Sandbox - Code Examples

Document created by communitymanager Administrator on Feb 26, 2016Last modified by communitymanager Administrator on Jan 17, 2018
Version 7Show Document
  • View in full screen mode

Example Data Classes for API Return Data

Use these classes to deserialize API return data.


Test an API URL in a Browser

GuideStar APIs can be tested by entering the URL in the address bar of any Browser. A prompt will be displayed to enter the user Name (or API Key) and password :




cURL API Example

cURL is a program that provides a library and command-line tool for transferring data using various protocols. The cURL project produces two products, libcurl and cURL. It was first released in 1997. The name originally stood for "see URL". cURL - Wikipedia

curl -3 -u username:password 



C# .NET API Example      (Text version for copying the example is here: C# .NET Code Example )




Java API Example

This example makes use of the Apache HttpClient library 4.1 to simplify http requests. To use this library, download the binaries with dependencies from and add them to your project classpath. Include your GuideStar credentials in place of the user:password.






import org.apache.http.HttpEntity;

import org.apache.http.client.ClientProtocolException;

import org.apache.http.client.methods.CloseableHttpResponse;

import org.apache.http.client.methods.HttpGet;

import org.apache.http.impl.client.CloseableHttpClient;

import org.apache.http.impl.client.HttpClients;

import org.apache.http.util.EntityUtils;

import org.apache.commons.codec.binary.Base64;


public class TestAPI


  //this is the request string that calls the API. The Sandbox API is being used for this example.

  //Search for Organizations in the 23188 zip code and return 25 results.

  private static String request = ""; 

  public static void main(String[] args) throws ClientProtocolException, IOException


       //encode login credentials

       byte[] encodedBytes = Base64.encodeBase64(<username> + ":" + <password>.getBytes()); 

       CloseableHttpClient httpclient = HttpClients.createDefault();

       HttpGet httpget = new HttpGet(request); 

       httpget.setHeader("Authorization","Basic " + new String(encodedBytes));  //Set the authorization header with the GuideStar API credentials

       CloseableHttpResponse response = httpclient.execute(httpget); 


      try //We want to try and get an entity back from the response to our request


            HttpEntity entity = response.getEntity(); 

            if (entity != null)





       catch(Exception e)




       finally //close the response object and client object







1 person found this helpful