@gugu910/pi-slack-api
v0.1.0
Published
Typed Slack Web API client and CLI generated from Slack's OpenAPI spec
Readme
slack-api
Typed Slack Web API client + CLI generated from Slack's OpenAPI spec with
@hey-api/openapi-ts.
What it includes
generated/— generated type-safe Slack Web API SDKcli.ts— CLI wrapper for calling generated SDK methodsscripts/generate.ts— re-downloads the Slack spec and regenerates the client
Regenerate the client
pnpm --filter @gugu910/pi-slack-api run generateThe generator currently tries these sources in order:
- Official Slack GitHub spec
https://raw.githubusercontent.com/slackapi/slack-api-specs/master/web-api/slack_web_openapi_v2.json
- Community fallback
https://raw.githubusercontent.com/api-evangelist/slack/main/openapi/slack-web-api-openapi.yml
CLI usage
List all generated Slack methods:
pnpm --filter @gugu910/pi-slack-api exec node --experimental-strip-types cli.ts listCall a method with repeated key/value params:
pnpm --filter @gugu910/pi-slack-api exec node --experimental-strip-types cli.ts conversations.list \
--token "$SLACK_TOKEN" \
--param limit=50Call a method with JSON input:
pnpm --filter @gugu910/pi-slack-api exec node --experimental-strip-types cli.ts chat.postMessage \
--token "$SLACK_TOKEN" \
--input '{"channel":"C123","text":"hello from slack-api"}'Or use the package-local bin wrapper directly:
cd slack-api
./bin/slack-api auth.test --token "$SLACK_TOKEN"Notes
- The CLI accepts Slack method names like
auth.testandchat.postMessage. - Flat
--paramand--inputfields are automatically routed intoheaders,query,path, orbodybased on the OpenAPI parameter location for the selected method. --tokenis injected astokenwhen the method input does not already define one, then routed to the correct request section.- If you need an escape hatch, you can pass explicit nested sections like
{ "headers": { "token": "..." } }. - Generated imports are rewritten from
.jsto.tsso the SDK can run directly via Node's--experimental-strip-typesmode without a separate build step.
