Skip to content

Latest commit

 

History

History
69 lines (58 loc) · 2.99 KB

V1.md

File metadata and controls

69 lines (58 loc) · 2.99 KB

Patreon V1 API

This page contains information and code samples on how to access Patreon V1 API using this library.

Notes

By default V1 API will return all properties with some top level includes. Setting top level includes manually will override top level include set by default.

When requesting some of resources in V1 API they will have sensible defaults for what attributes are included. But you can request optional attributes manually.

Code samples will show all available possible top level includes and optional fields.

Prerequisites

var httpClient = new HttpClient();
var tokenManager = new PatreonSimpleTokenManager("access_token");
var patreonAPIv1 = new PatreonAPIv1(httpClient, tokenManager);

API endpoint code samples

var response = await PatreonAPIv1.CurrentUser()
  .IncludeField(_ => _.LikeCount)
  .IncludeField(_ => _.CommentCount)
  .Include(PatreonTopLevelIncludes.V1.CurrentUser.Campaign)
  .Include(PatreonTopLevelIncludes.V1.CurrentUser.Pledges)
  .ExecuteAsync();
var user = new PatreonUserV1Response(response);
var response = await PatreonAPIv1.CurrentUserCampaigns()
  .Include(PatreonTopLevelIncludes.V1.CurrentUserCampaigns.Creator)
  .Include(PatreonTopLevelIncludes.V1.CurrentUserCampaigns.Goals)
  .Include(PatreonTopLevelIncludes.V1.CurrentUserCampaigns.Rewards)
  .Include(PatreonTopLevelIncludes.V1.CurrentUserCampaigns.Pledges)
  .ExecuteAsync();
var campaigns = new PatreonCampaignsV1Response(response);
var campaignId = 0;
var response = await PatreonAPIv1.CampaignPledges(campaignId)
  .Include(PatreonTopLevelIncludes.V1.CampaignPledges.Address)
  .Include(PatreonTopLevelIncludes.V1.CampaignPledges.Creator)
  .Include(PatreonTopLevelIncludes.V1.CampaignPledges.Patron)
  .Include(PatreonTopLevelIncludes.V1.CampaignPledges.Reward)
  .ExecuteAsync();
var pledges = new PatreonPledgesV1Response(response);

Additional code samples

Using custom endpoint url

To use custom endpoint url you will need to know what resource type will be returned. You can do that by checking return type of predefined API endpoints in PatreonAPIv1 class. Down below is code sample on how to get list of pledges using custom url with parameters.

var campaignId = 0;
var url = $"https://patreon.com/api/oauth2/api/campaigns/{campaignId}/pledges?page%5Bcount%5D=10&sort=created&page%5Bcursor%5D=2017-08-21T20%3A16%3A49.258893%2B00%3A00";
var query = new PatreonAPIv1Query<PatreonResponseMulti<PatreonPledgeV1Attributes, PatreonPledgeV1Relationships>, PatreonPledgeV1Attributes, PatreonPledgeV1Relationships>(url, httpClient, tokenManager);
var response = await query.ExecuteAsync();
var pledges = new PatreonPledgesV1Response(response);