Skip to content

Commit e4671df

Browse files
committed
feat: implement full SDK with REST API and WebSocket support
- Add client with public/authenticated endpoint routing - Add Ed25519 signature authentication - Add all REST resources: events, markets, orders, portfolio, account, search, series, sports - Add typed error classes with HTTP status mapping - Add private and markets WebSocket clients with typed events - Add dual CJS/ESM build with tsup - Add comprehensive test suite (131 tests) - Add CI workflow, issue templates, PR template - Add runtime fetch guard for Node <18
1 parent b64bce9 commit e4671df

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

59 files changed

+8092
-30
lines changed

.github/CODEOWNERS

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
* @polymarket/sdk-team
Lines changed: 80 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,80 @@
1+
name: Bug Report
2+
description: Report a bug in the SDK
3+
labels: ["bug"]
4+
body:
5+
- type: markdown
6+
attributes:
7+
value: |
8+
Thanks for taking the time to report a bug!
9+
10+
- type: input
11+
id: sdk-version
12+
attributes:
13+
label: SDK Version
14+
description: What version of the SDK are you using?
15+
placeholder: "0.0.3"
16+
validations:
17+
required: true
18+
19+
- type: input
20+
id: node-version
21+
attributes:
22+
label: Node.js Version
23+
description: What version of Node.js are you using?
24+
placeholder: "20.10.0"
25+
validations:
26+
required: true
27+
28+
- type: dropdown
29+
id: os
30+
attributes:
31+
label: Operating System
32+
options:
33+
- macOS
34+
- Linux
35+
- Windows
36+
validations:
37+
required: true
38+
39+
- type: textarea
40+
id: description
41+
attributes:
42+
label: Description
43+
description: A clear description of the bug
44+
validations:
45+
required: true
46+
47+
- type: textarea
48+
id: reproduction
49+
attributes:
50+
label: Steps to Reproduce
51+
description: Steps to reproduce the behavior
52+
placeholder: |
53+
1. Initialize client with...
54+
2. Call method...
55+
3. See error
56+
validations:
57+
required: true
58+
59+
- type: textarea
60+
id: expected
61+
attributes:
62+
label: Expected Behavior
63+
description: What did you expect to happen?
64+
validations:
65+
required: true
66+
67+
- type: textarea
68+
id: actual
69+
attributes:
70+
label: Actual Behavior
71+
description: What actually happened?
72+
validations:
73+
required: true
74+
75+
- type: textarea
76+
id: code
77+
attributes:
78+
label: Code Sample
79+
description: Minimal code to reproduce the issue
80+
render: typescript

.github/ISSUE_TEMPLATE/config.yml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
blank_issues_enabled: false
2+
contact_links:
3+
- name: Documentation
4+
url: https://docs.polymarket.us
5+
about: Check the documentation for usage guides
6+
- name: Discord
7+
url: https://discord.gg/polymarket
8+
about: Ask questions in our Discord community
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
name: Feature Request
2+
description: Suggest a new feature
3+
labels: ["enhancement"]
4+
body:
5+
- type: markdown
6+
attributes:
7+
value: |
8+
Thanks for suggesting a feature!
9+
10+
- type: textarea
11+
id: description
12+
attributes:
13+
label: Description
14+
description: A clear description of the feature you'd like
15+
validations:
16+
required: true
17+
18+
- type: textarea
19+
id: use-case
20+
attributes:
21+
label: Use Case
22+
description: Why do you need this feature? What problem does it solve?
23+
validations:
24+
required: true
25+
26+
- type: textarea
27+
id: alternatives
28+
attributes:
29+
label: Alternatives Considered
30+
description: Any alternative solutions or workarounds you've considered
31+
32+
- type: textarea
33+
id: additional
34+
attributes:
35+
label: Additional Context
36+
description: Any other context, screenshots, or code samples

.github/pull_request_template.md

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
## Changes
2+
3+
<!-- What does this PR do? -->
4+
5+
## Testing
6+
7+
<!-- How was this tested? -->
8+
9+
## Checklist
10+
11+
- [ ] Tests pass (`pnpm test`)
12+
- [ ] Linting passes (`pnpm lint`)
13+
- [ ] Types check (`pnpm build`)

.github/workflows/ci.yml

Lines changed: 72 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,72 @@
1+
name: CI
2+
3+
on:
4+
push:
5+
branches: [main]
6+
pull_request:
7+
branches: [main]
8+
9+
jobs:
10+
lint:
11+
runs-on: ubuntu-latest
12+
steps:
13+
- uses: actions/checkout@v4
14+
15+
- uses: pnpm/action-setup@v4
16+
17+
- uses: actions/setup-node@v4
18+
with:
19+
node-version: '20'
20+
cache: 'pnpm'
21+
22+
- run: pnpm install --frozen-lockfile
23+
24+
- run: pnpm lint
25+
26+
typecheck:
27+
runs-on: ubuntu-latest
28+
steps:
29+
- uses: actions/checkout@v4
30+
31+
- uses: pnpm/action-setup@v4
32+
33+
- uses: actions/setup-node@v4
34+
with:
35+
node-version: '20'
36+
cache: 'pnpm'
37+
38+
- run: pnpm install --frozen-lockfile
39+
40+
- run: pnpm typecheck
41+
42+
build:
43+
runs-on: ubuntu-latest
44+
steps:
45+
- uses: actions/checkout@v4
46+
47+
- uses: pnpm/action-setup@v4
48+
49+
- uses: actions/setup-node@v4
50+
with:
51+
node-version: '20'
52+
cache: 'pnpm'
53+
54+
- run: pnpm install --frozen-lockfile
55+
56+
- run: pnpm build
57+
58+
test:
59+
runs-on: ubuntu-latest
60+
steps:
61+
- uses: actions/checkout@v4
62+
63+
- uses: pnpm/action-setup@v4
64+
65+
- uses: actions/setup-node@v4
66+
with:
67+
node-version: '20'
68+
cache: 'pnpm'
69+
70+
- run: pnpm install --frozen-lockfile
71+
72+
- run: pnpm test

.gitignore

Lines changed: 32 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,32 @@
1-
/node_modules
2-
/dist
3-
/test
1+
# Dependencies
2+
node_modules/
3+
4+
# Build output
5+
dist/
6+
7+
# Test coverage
8+
coverage/
9+
10+
# IDE
11+
.idea/
12+
.vscode/
13+
*.swp
14+
*.swo
15+
16+
# OS
17+
.DS_Store
18+
Thumbs.db
19+
20+
# Logs
21+
*.log
22+
npm-debug.log*
23+
yarn-debug.log*
24+
yarn-error.log*
25+
26+
# Environment
27+
.env
28+
.env.local
29+
.env.*.local
30+
31+
# Package tarballs
32+
*.tgz

CONTRIBUTING.md

Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
# Contributing
2+
3+
## Environment Setup
4+
5+
This project uses [`pnpm`](https://pnpm.io/) as its package manager.
6+
7+
```sh
8+
pnpm install
9+
pnpm build
10+
```
11+
12+
## Development
13+
14+
```sh
15+
# Build the SDK
16+
pnpm build
17+
18+
# Run tests
19+
pnpm test
20+
21+
# Type check
22+
pnpm typecheck
23+
24+
# Lint
25+
pnpm lint
26+
27+
# Format
28+
pnpm format
29+
```
30+
31+
## Running Tests
32+
33+
```sh
34+
pnpm test
35+
```
36+
37+
Tests use Jest with mocked fetch calls. No API credentials are required for running tests.
38+
39+
## Linting and Formatting
40+
41+
This project uses [Biome](https://biomejs.dev/) for linting and formatting.
42+
43+
```sh
44+
# Check for lint errors
45+
pnpm lint
46+
47+
# Fix lint errors and format
48+
pnpm lint:fix
49+
```
50+
51+
## Making Changes
52+
53+
1. Create a new branch for your changes
54+
2. Make your changes
55+
3. Run `pnpm test` and `pnpm lint` to ensure everything passes
56+
4. Submit a pull request
57+
58+
## Publishing
59+
60+
Releases are automated via GitHub Actions. When a PR is merged to `main`, the CI will automatically publish to npm based on conventional commit messages:
61+
62+
- `feat!:` or `BREAKING CHANGE` → major version bump
63+
- `feat:` → minor version bump
64+
- All other commits → patch version bump

LICENSE

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
MIT License
2+
3+
Copyright (c) 2026 Polymarket
4+
5+
Permission is hereby granted, free of charge, to any person obtaining a copy
6+
of this software and associated documentation files (the "Software"), to deal
7+
in the Software without restriction, including without limitation the rights
8+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
copies of the Software, and to permit persons to whom the Software is
10+
furnished to do so, subject to the following conditions:
11+
12+
The above copyright notice and this permission notice shall be included in all
13+
copies or substantial portions of the Software.
14+
15+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21+
SOFTWARE.

0 commit comments

Comments
 (0)