@polar-sh/sdk 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md ADDED
@@ -0,0 +1,100 @@
1
+ # Polar SDK
2
+
3
+ The Polar SDK is a JavaScript library with capabilities to interact with the Polar API.
4
+
5
+ The SDK is compatible with both browser & server-side runtimes. It is automatically generated from our OpenAPI implementation, making it up-to-date with the server-side API at any time.
6
+
7
+ [Read more about our OpenAPI Schema & documentation](https://docs.polar.sh/api)
8
+
9
+
10
+ ## Usage
11
+
12
+ The SDK is available from NPM.
13
+
14
+ `npm install @polar-sh/sdk`
15
+
16
+ Once installed, you may import the SDK like you usually would:
17
+
18
+ ```typescript
19
+ import { Configuration, PolarAPI } from '@polar-sh/sdk';
20
+
21
+ const api = new PolarAPI();
22
+
23
+ const authedApi = new PolarAPI(
24
+ new Configuration({
25
+ accessToken: '<MY_ACCESS_TOKEN>'
26
+ })
27
+ );
28
+ ```
29
+
30
+ ### Access Tokens
31
+
32
+ You can acquire an access token through your [Settings page](https://polar.sh/settings). This can be used to authenticate yourself with the API for create/update/delete actions.
33
+
34
+ ## Examples
35
+
36
+ ### Issues looking for funding
37
+
38
+ You can easily retrieve issues looking for funding using the Funding-service.
39
+
40
+ ```typescript
41
+ import { Configuration, PolarAPI, Platforms, ListFundingSortBy } from '@polar-sh/sdk';
42
+
43
+ const api = new PolarAPI(new Configuration());
44
+
45
+ const issuesFunding = await api.funding.search(
46
+ {
47
+ platform: Platforms.GITHUB,
48
+ organizationName: '<MY_GITHUB_ORGANIZATION_NAME>',
49
+ badged: true,
50
+ closed: false,
51
+ sorting: [
52
+ ListFundingSortBy.MOST_FUNDED,
53
+ ListFundingSortBy.MOST_ENGAGEMENT,
54
+ ListFundingSortBy.NEWEST,
55
+ ],
56
+ limit: 20,
57
+ }
58
+ );
59
+
60
+ ```
61
+
62
+ ### Issue data from GitHub Issue
63
+
64
+ Retrieve Polar data about a given GitHub issue.
65
+
66
+ ```typescript
67
+ import { Configuration, PolarAPI } from '@polar-sh/sdk';
68
+
69
+ const api = new PolarAPI(new Configuration());
70
+
71
+ const params = {
72
+ organization: 'polarsource',
73
+ repo: 'polar',
74
+ number: 900
75
+ }
76
+
77
+ const issue = await api.issues.lookup(
78
+ {
79
+ externalUrl: `https://github.com/${params.organization}/${params.repo}/issues/${params.number}`,
80
+ }
81
+ );
82
+ ```
83
+
84
+ ### Add Polar badge to a GitHub issue
85
+
86
+ Adds a Polar badge to a given GitHub issue.
87
+
88
+ ```typescript
89
+ import { Configuration, PolarAPI } from '@polar-sh/sdk';
90
+
91
+ const api = new PolarAPI(
92
+ new Configuration({
93
+ accessToken: '<MY_ACCESS_TOKEN>'
94
+ })
95
+ );
96
+
97
+ await api.issues.addPolarBadge({
98
+ id: '<ISSUE_ID>'
99
+ });
100
+ ```