orghunter logo
Home
Charity API Key

Building a Charity Search App in C# Using the OrgHunter Charity API

Learn how to use the OrgHunter Charity API to build a C# app that searches for charities by name, city, or state, with easy setup and integration steps.
Title Image

Here’s a guide on how to use the OrgHunter Charity API to create a C# charity search application:

Step-by-Step Guide

  1. Get an API Key: Sign up at OrgHunter Charity API to obtain your API key, required for accessing the API.
  2. Set Up the Project:
    • Open Visual Studio and create a new Console Application.
    • Add System.Net.Http for HTTP requests.
  3. Create the Charity Search Function: Define a function to send a POST request to the API endpoint:

using System;
using System.Net.Http;
using System.Threading.Tasks;

namespace CharitySearchApp
{
class Program
{
private static async Task SearchCharities(string searchTerm)
{
string apiKey = "yourKey";
string url = $"http://data.orghunter.com/v1/charitysearch?user_key={apiKey}&searchTerm={searchTerm}";

using (HttpClient client = new HttpClient())
{
HttpResponseMessage response = await client.PostAsync(url, null);
if (response.IsSuccessStatusCode)
{
string responseBody = await response.Content.ReadAsStringAsync();
Console.WriteLine(responseBody);
}
else
{
Console.WriteLine($"Error: {response.StatusCode}");
}
}
}

static async Task Main(string[] args)
{
await SearchCharities("humane society");
}
}
}

  1. Test the Application:
    • Run the application and view the output.
    • Modify parameters like searchTerm, city, and state for different searches.

This basic implementation demonstrates how to call the OrgHunter Charity API in C#. For detailed parameter options, visit the Charity API Search Documentation.


orghunter logo
Home
API Key
© OrgHunter 2024. All rights reserved.

When you visit or interact with our sites, services or tools, we or our authorised service providers may use cookies for storing information to help provide you with a better, faster and safer experience and for marketing purposes.