@somewhere-somehow/swsh-public-api
v0.1.2
Published
Official TypeScript SDK and OpenAPI schema for the swsh public API.
Maintainers
Readme
@somewhere-somehow/swsh-public-api
Official TypeScript SDK and OpenAPI schema for the swsh public API.
For full documentation, see https://docs.joinswsh.com.
This package ships:
- A typed
fetch-based client (SwshApiClient) with no runtime dependencies. - All request / response types under the
SwshApinamespace. - The raw OpenAPI 3.1 spec (
openapi.yaml) and rendered introduction (introduction.md).
The npm version is the same as the info.version field of openapi.yaml, so
upgrading the package upgrades you to a known spec version.
Install
npm install @somewhere-somehow/swsh-public-apiRequires Node.js 18+ (native fetch).
Usage
import { SwshApiClient, SwshApiError, type SwshApi } from "@somewhere-somehow/swsh-public-api";
const client = new SwshApiClient({ apiKey: process.env.SWSH_API_KEY! });
try {
const { albums }: SwshApi.ResponseAlbumsCursor = await client.album.getAlbums();
console.log(albums);
} catch (err) {
if (err instanceof SwshApiError) {
console.error(err.statusCode, err.body);
}
throw err;
}Accessing the raw OpenAPI spec
import openapiPath from "@somewhere-somehow/swsh-public-api/openapi.yaml";The ./openapi.yaml and ./introduction.md subpath exports point at the
unmodified spec files, suitable for building documentation sites or generating
clients in other languages.
License
ISC
