@pbvision/partner-sdk 0.1.2 → 0.1.4

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.
Files changed (3) hide show
  1. package/README.md +41 -36
  2. package/package.json +1 -1
  3. package/src/index.js +3 -2
package/README.md CHANGED
@@ -1,7 +1,7 @@
1
1
  # PB Vision Partner Documentation <!-- omit in toc -->
2
2
 
3
3
  The easiest way to use the PB Vision AI Engine is to simply share a link to
4
- your video file. Our AI usually works on each video for about an hour for a
4
+ your video file. Our AI usually works on each video for about 30 minutes for a
5
5
  standard length game, so we'll notify your servers when the results are ready.
6
6
 
7
7
  - [Installation](#installation)
@@ -31,8 +31,8 @@ account. We'll send you an API Key.
31
31
  4. Initialize the SDK:
32
32
 
33
33
  ```javascript
34
- import { PBVision } from '@pbvision/partner-sdk'
35
- const pbv = new PBVision(YOUR_API_KEY)
34
+ import { PBVision } from '@pbvision/partner-sdk';
35
+ const pbv = new PBVision(YOUR_API_KEY);
36
36
  ```
37
37
 
38
38
  5. Use its methods as described to [send us video URLs](#send-videos) to
@@ -47,10 +47,10 @@ an HTTP POST request to a URL ("webhook") of your choice. You can use our SDK
47
47
  to tell our servers where you want us to notify your servers like this:
48
48
 
49
49
  ```javascript
50
- import { PBVision } from '@pbvision/partner-sdk'
50
+ import { PBVision } from '@pbvision/partner-sdk';
51
51
 
52
- const pbv = new PBVision(YOUR_API_KEY)
53
- await pbv.setWebhook(YOUR_WEBHOOK_URL)
52
+ const pbv = new PBVision(YOUR_API_KEY);
53
+ await pbv.setWebhook(YOUR_WEBHOOK_URL);
54
54
  ```
55
55
 
56
56
  Alternatively, you can just use `curl`:
@@ -65,7 +65,7 @@ curl -X POST \
65
65
 
66
66
  ### Send Videos
67
67
 
68
- #### Option 1: PBV Downloads your video from a URL
68
+ #### Option 1: PBV downloads your video from a URL
69
69
 
70
70
  First, upload a video to a _publicly_ accessible URL on your server. For best
71
71
  results, videos should follow our [guidelines](#video-guidelines).
@@ -73,17 +73,17 @@ results, videos should follow our [guidelines](#video-guidelines).
73
73
  Next, tell us to download and work on the video. You can do this using our SDK:
74
74
 
75
75
  ```javascript
76
- import { PBVision } from '@pbvision/partner-sdk'
76
+ import { PBVision } from '@pbvision/partner-sdk';
77
77
 
78
- const pbv = new PBVision(YOUR_API_KEY)
79
- // you can omit this metadata, or provide some or all of this object-- whatever you'd like!
78
+ const pbv = new PBVision(YOUR_API_KEY);
79
+ // you can omit this metadata, or provide some or all of this object—whatever you'd like!
80
80
  const optionalMetadata = {
81
81
  userEmails: [],
82
82
  name: 'Dink Championship 2024',
83
83
  desc: 'A longer description, if you want',
84
- gameStartEpoch: 1711393200 // when the game was played
85
- }
86
- await pbv.sendVideoUrlToDownload(YOUR_VIDEO_URL, optionalMetadata)
84
+ gameStartEpoch: 1711393200, // when the game was played
85
+ };
86
+ await pbv.sendVideoUrlToDownload(YOUR_VIDEO_URL, optionalMetadata);
87
87
  ```
88
88
 
89
89
  Alternatively, you can just use `curl`:
@@ -96,43 +96,46 @@ curl -X POST \
96
96
  https://api-ko3kowqi6a-uc.a.run.app/partner/add_video_by_url
97
97
  ```
98
98
 
99
+ To use the production server instead of the test server, change `ko3kowqi6a` to `2o2klzx4pa`.
100
+
99
101
  #### Option 2: Upload your video
100
102
 
101
103
  You can directly upload your video from a file using the SDK too:
102
104
 
103
105
  ```javascript
104
- import { PBVision } from '@pbvision/partner-sdk'
106
+ import { PBVision } from '@pbvision/partner-sdk';
105
107
 
106
- const pbv = new PBVision(YOUR_API_KEY)
107
- // you can omit this metadata, or provide some or all of this object-- whatever you'd like!
108
+ const pbv = new PBVision(YOUR_API_KEY, { useProdServer: false });
109
+ // you can omit this metadata, or provide some or all of this object—whatever you'd like!
108
110
  const optionalMetadata = {
109
111
  userEmails: [],
110
112
  name: 'Dink Championship 2024',
111
113
  desc: 'A longer description, if you want',
112
- gameStartEpoch: 1711393200 // when the game was played
113
- }
114
- await pbv.uploadVideo(YOUR_VIDEO_FILENAME, optionalMetadata)
114
+ gameStartEpoch: 1711393200, // when the game was played
115
+ };
116
+ await pbv.uploadVideo(YOUR_VIDEO_FILENAME, optionalMetadata);
115
117
  ```
116
118
 
117
119
  ## After Video Processing is Done
118
120
 
119
121
  When our AI is done processing your video, we will email the players in the
120
- game (_if_ their email addresses were provided).
122
+ game (_if_ their email addresses were provided via `userEmails`).
121
123
 
122
124
  If you [provided a webhook](#webhook-setup), then we'll send
123
125
  an HTTP POST request to your server. Your server should acknowledge this
124
126
  callback with a standard 200 (OK) response. If it does not, we will attempt to
125
127
  retry sending this request later (up to some maximum number of attempts).
126
128
 
127
- The HTTP POST body will contain JSON which looks like this:
129
+ The HTTP POST body will contain JSON which looks like this (depending on which
130
+ data is enabled for your API key, only some of these fields may be present):
128
131
 
129
132
  ```json
130
133
  {
131
134
  "from_url": "https://example.com/my-video.mp4",
132
- "webpage": "https://app.pb.vision/video/xyz",
135
+ "webpage": "https://pb.vision/video/tvgz3pqij0ll",
133
136
  "cutVideo": "https://storage.googleapis.com/pbv-pro/xyz/f50272db-69a8-49ed-9d92-3a4d067af87c/rallies.mp4",
134
- "events": EVENTS_DATA,
135
137
  "insights": INSIGHTS_DATA,
138
+ "stats": STATS_DATA,
136
139
  "error": {
137
140
  "reason": "some explanation here..."
138
141
  }
@@ -142,30 +145,32 @@ The HTTP POST body will contain JSON which looks like this:
142
145
  - `from_url` is the video url you sent us in [step 3](#send-videos)
143
146
  - `webpage` is a link to our web app where the stats can be explored
144
147
  - `error` is only present if your video could not be processed
145
- - `events` - describes the pickleball game in detailed, low-level events
146
- - Explore the _events_ schema at <https://pbv-public.github.io/events/dev>
147
- - Schema changes and diffs are in our [`pbv-public/events` repo](https://github.com/pbv-public/events/blob/dev/CHANGELOG.md)
148
- - `insights` - a summary of high-level stats about the video
149
- - Explore the _insights_ schema at <https://pbv-public.github.io/insights/dev>
148
+ - `insights` describes the pickleball game in a detailed, shot-by-shot format
149
+ - Explore the _insights_ schema at <https://pbv-public.github.io/insights?s=~insights~game>
150
150
  - Schema changes and diffs are in our [`pbv-public/insights` repo](https://github.com/pbv-public/insights/blob/dev/CHANGELOG.md)
151
+ - `stats` various stats about the game for advanced players
152
+ - Explore the _stats_ schema at <https://pbv-public.github.io/stats?s=~stats~game>
153
+ - Schema changes and diffs are in our [`pbv-public/stats` repo](https://github.com/pbv-public/stats/blob/dev/CHANGELOG.md)
154
+ - `cutVideo` contains a link to the rally-sliced (dead time removed) .mp4.
151
155
 
152
156
  ## Video Guidelines
153
157
 
154
158
  Requirements:
155
159
 
156
- - Video Encoding: **H.264** codec
157
- - Frame Rate: **30 or 60 FPS**
158
- - File Extension: `.mp4`
160
+ - Comply with [PB Vision's framing guidelines](https://help.pb.vision/en/help/articles/1108176-video-recording-and-framing-tips)
161
+ - Video Encoding: H.264 codec
162
+ - Frame Rate: 30 or 60 FPS
163
+ - Max Duration: 30 minutes
159
164
 
160
165
  For best results, we also recommend:
161
166
 
162
- - Follow our [**video framing** guidelines](https://www.pb.vision/video-tips)
167
+ - File Extension: .mp4
163
168
  - Audio Encoding: MPEG-4 AAC
164
169
  - Resolution: 1080p
165
- - Max bitrate: 2 Mbps
166
- - Max file size: 1GB
167
- - Max duration: 30 minutes
170
+ - Frame Rate: 30 FPS
171
+ - Max Bitrate: 2 Mbps
172
+ - Max File Size: 2GB
168
173
 
169
174
  ## Reference Guide
170
175
 
171
- - [JSDocs](https://pbv-public.github.io/partner-sdk-nodejs/)
176
+ - [JSDocs](https://pbv-public.github.io/partner-sdk-nodejs/)
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@pbvision/partner-sdk",
3
3
  "description": "SDK for interacting with the PB Vision pickleball AI engine.",
4
- "version": "0.1.2",
4
+ "version": "0.1.4",
5
5
  "license": "MIT",
6
6
  "type": "module",
7
7
  "engines": {
package/src/index.js CHANGED
@@ -25,11 +25,12 @@ const ENVIRONMENTS = {
25
25
 
26
26
  /** @public */
27
27
  export class PBVision {
28
- constructor (apiKey, config = ENVIRONMENTS.test) {
29
- assert(apiKey && apiKey.length === 31 && apiKey.indexOf('_') === 10,
28
+ constructor (apiKey, { useProdServer = false } = {}) {
29
+ assert(apiKey && apiKey.indexOf('_') !== -1,
30
30
  `invalid API key: ${apiKey}`)
31
31
 
32
32
  this.apiKey = apiKey
33
+ const config = useProdServer ? ENVIRONMENTS.prod : ENVIRONMENTS.test
33
34
  this.server = config.apiServer
34
35
  this.isDev = config === ENVIRONMENTS.test
35
36
  }