项目作者: CandidOrg

项目描述 :
This library provides simplified access to the GuideStar APIs
高级语言: C#
项目地址: git://github.com/CandidOrg/Candid.GuideStarAPI.SDK.git
创建时间: 2020-05-26T18:44:52Z
项目社区:https://github.com/CandidOrg/Candid.GuideStarAPI.SDK

开源协议:MIT License

下载


Candid.GuideStarAPI.SDK

This library provides simplified access to the GuideStar APIs.

API Getting Started Guide

Here
is our getting started guide. This will help you get your API Account and Subscription keys which are necessary to use the SDK.

Installation

GuideStar SDK is available on NuGet:

  1. PM> Install-Package Candid.GuideStarAPI

or if using .NET Core:

  1. dotnet add package Candid.GuideStarAPI

SDK Setup

At the most simple level, calling an API requires initializing the system with an API key, then calling
the correct method from the resource you are interested in.

The majority of our resources use an EIN (Employer Identification Number) as a key for documents.

To use Premier

The following code will return the Premier JSON document of an EIN as a string.

  1. GuideStarClient.SubscriptionKeys.Add(Domain.PremierV3, PREMIER_KEY);
  2. var premier = PremierResource.GetOrganization(EIN);

All request methods have an asynchronous and synchronous version.

  1. GuideStarClient.SubscriptionKeys.Add(Domain.PremierV3, PREMIER_KEY);
  2. var premier = await PremierResource.GetOrganizationAsync(EIN);

All Premier responses are defined in our API documentation found here.

To use Charity Check

Similarly, the following code will return the Charity Check JSON document of an EIN as a string.

  1. GuideStarClient.SubscriptionKeys.Add(Domain.CharityCheckV1, CHARITYCHECK_KEY);
  2. var charitycheck = CharityCheckResource.GetOrganization(EIN);

All Charity Check responses are defined in the API documentation found here.

To use Essentials

The Essentials resource takes a search payload as input and then behaves similarly to our other resources. For all realtive search filters allowed in the payload, please refer to the code example below and refer to the API documentation found here.

  1. string searchterms = "";
  2. int from = 1;
  3. int size = 25;
  4. string sortby = "organization_name";
  5. string[] state = { "ny" };
  6. string zip = "";
  7. int radius = 50;
  8. string[] msa = { "" };
  9. string[] city = { "" };
  10. string[] county = { "" };
  11. string[] profilelevel = { "Platinum", "Bronze" };
  12. string[] nteemajor = { "" };
  13. string[] nteeminor = { "" };
  14. string[] subsection = { "" };
  15. string[] foundation = { "" };
  16. bool bmfstatus = true;
  17. bool pub78verified = true;
  18. int minemployees = 0;
  19. int maxemployees = 1000000000;
  20. int minrevenue = 0;
  21. int maxrevenue = 1000000000;
  22. int minexpenses = 0;
  23. int maxexpesnes = 1000000000;
  24. int minassets = 0;
  25. int maxassets = 100000000;
  26. string ESSENTIALS_KEY = "Your key here";
  27. var payload = SearchPayloadBuilder.Create()
  28. .WithSearchTerms(searchterms) //search terms is a string used as a keyword search
  29. .From(from) //from is an integer to specify which record to start at for pagination
  30. .Size(size) //size is an integer to specify how many records to return
  31. .Sort(SortBuilder =>
  32. {
  33. SortBuilder.SortBy(sortby); //sortby is a string to specify how to sort the records
  34. SortBuilder.SortByAscending(); //sortbyascending is used to sort the records alphabectically. The sort is set to true when this is present in the form.
  35. //SortBuilder.SortByDescending(); //sortbydescending is used to sort the records reverse alphabectically. The sort is set to true when this is present in the form.
  36. }
  37. )
  38. .Filters(filterBuilder =>
  39. {
  40. filterBuilder.Geography(geographyBuilder =>
  41. {
  42. geographyBuilder.HavingState(state); //state is a string array to filter on multiple states
  43. //geographyBuilder.HavingZipCode(zip); //zip is a string to filter on 1 zip code
  44. geographyBuilder.WithinZipRadius(radius); //radius is an integer to include up to 50 miles from the zip
  45. geographyBuilder.HavingMSA(msa); //msa is an string array to filter on multiple msa codes
  46. geographyBuilder.HavingCity(city); //city is a string array to filter on multiple cities
  47. geographyBuilder.HavingCounty(county); //county is a string array to filter on multiple counties
  48. }
  49. );
  50. filterBuilder.Organization(OrganizationBuilder =>
  51. {
  52. OrganizationBuilder.HavingProfileLevel(profilelevel); //profilelevel is a string array to filter on the seal of transparency level
  53. OrganizationBuilder.HavingNTEEMajorCode(nteemajor); //nteemajor is a string array to filter on major ntee codes
  54. OrganizationBuilder.HavingNTEEMinorCode(nteeminor); //nteeminor is a string array to filter on minor ntee codes
  55. OrganizationBuilder.HavingSubsectionCode(subsection); //subsection is a string array to filer on subsection codes
  56. OrganizationBuilder.HavingFoundationCode(foundation); //foundation is a string array to filer on foundation codes
  57. OrganizationBuilder.IsOnBMF(bmfstatus); //bmfstatus is a boolean to filter on bmf status
  58. OrganizationBuilder.IsPub78Verified(pub78verified); //pub78verified is a boolean to filter on verification on pub 78
  59. OrganizationBuilder.AffiliationType(AffiliationTypeBuilder =>
  60. {
  61. //AffiliationTypeBuilder.OnlyParents(); //only parents is used to filter parent organizations. The search is set to true when this is present in the form.
  62. //AffiliationTypeBuilder.OnlySubordinate(); //only subordinate is used to filter subordinate organizations. The search is set to true when this is present in the form.
  63. //AffiliationTypeBuilder.OnlyIndependent(); //only independent is used to filter independent organizations. The search is set to true when this is present in the form.
  64. //AffiliationTypeBuilder.OnlyHeadquarters(); //only headquarters is used to filter headquarter organizations. The search is set to true when this is present in the form.
  65. }
  66. );
  67. OrganizationBuilder.SpecificExclusions(SpecificExclusionBuilder =>
  68. {
  69. SpecificExclusionBuilder.ExcludeRevokedOrganizations(); //exclude revoked organizations is used to filter out any revoked organizations. The search is set to true when this is present in the form.
  70. SpecificExclusionBuilder.ExcludeDefunctOrMergedOrganizations(); //exclude defunct or merged organizations is used to filter out any defunct or merged organizations. the search is set to true when this is present in the form.
  71. }
  72. );
  73. OrganizationBuilder.NumberOfEmployees(MinMaxBuilder =>
  74. {
  75. MinMaxBuilder.HavingMaximum(maxemployees); //maxemployees is an integer to include organizations with the number of employees less than the specified amount
  76. MinMaxBuilder.HavingMinimum(minemployees); //minemployees is an integer to include organizations with the number of employees more than the specified amount
  77. }
  78. );
  79. OrganizationBuilder.FormTypes(FormTypeBuilder =>
  80. {
  81. FormTypeBuilder.OnlyF990(); //only f990 is used to filter organizations who filed a form 990. The search is set to true when this is present in the form.
  82. //FormTypeBuilder.OnlyF990PF(); //only f990pf is used to filter organizations who filed a form 990-pf. The search is set to true when this is present in the form.
  83. //FormTypeBuilder.Only990tRequired(); //only f990t required is used to filter organizations who are required to filed a form 990-t. The search is set to true when this is present in the form.
  84. }
  85. );
  86. OrganizationBuilder.Audits(AuditBuilder =>
  87. {
  88. AuditBuilder.HavingA133Audit(); // having a133 audit is used to filter organizations who have completed an a133 audit. The search is set to true when this is present in the form.
  89. }
  90. );
  91. }
  92. );
  93. filterBuilder.Financials(finBuilder =>
  94. {
  95. finBuilder.Form990Assets(assets =>
  96. {
  97. assets.HavingMaximum(maxassets); //maxassets is an integer to include organizations with assets less than the specified amount
  98. assets.HavingMinimum(minassets); //minassets is an integer to include organizations with assets more than the specified amount
  99. }
  100. );
  101. finBuilder.Form990Expenses(expenses =>
  102. {
  103. expenses.HavingMaximum(maxexpesnes); //maxexpenses is an integer to include organizations with expenses less than the specified amount
  104. expenses.HavingMinimum(minexpenses); //minexpenses is an integer to include organizations with expenses more than the specified amount
  105. }
  106. );
  107. finBuilder.Form990Revenue(revenue =>
  108. {
  109. revenue.HavingMaximum(maxrevenue); //maxrevenue is an integer to include organizations with revenue less than the specified amount
  110. revenue.HavingMinimum(minrevenue); //minrevenue is an integer to include organizations with revenue more than the specified amount
  111. }
  112. );
  113. }
  114. );
  115. }
  116. )
  117. .Build();
  118. GuideStarClient.SubscriptionKeys.Add(Domain.EssentialsV2, ESSENTIALS_KEY);
  119. var essentials = EssentialsResource.GetOrganization(payload);

The return is a JSON collection of organization info that matches the payload parameters. All Essentials responses are defined in the API Documention found here.

SDK Demonstration Repo

There is a demonstration website in ASP.NET Core MVC to show example usage of the SDK.