Val Town SDK
The Val Town TypeScript SDK lets you interact with our REST API from the comfort of a typed client that works well with editor autocomplete.
The Val Town SDK supports:
- Node.js 18 LTS or later
- Deno v1.28.0 or higher, using
import ValTown from "npm:@valtown/sdk"
- Bun 1.0 or later
- Cloudflare Workers
- Vercel Edge Runtime
Installing the SDK
The latest version of the SDK is always available on NPM.
To use the SDK with Node.js, install it with NPM or your preferred package manager:
In Deno, it isn’t necessary to install NPM packages explicitly: you can import the module and Deno will download it on the fly:
Getting started in Node.js
Here is how to get started with the SDK, with Node.js, writing ESM. You should have Node.js already installed, version 18 or newer. There are many ways to set up JavaScript and TypeScript projects, and it’s likely that you already have a project you intend to integrate against, so we don’t document every approach.
Create a file named index.mjs
. Note that it needs to end
with .mjs
, not .js
, because this file is using ESM import
syntax. Alternatively, you can add "type": "module"
to your package.json file.
Finally, the API expects to be authenticated with an API token, so create an API token on Val Town, and set it in your terminal environment:
Now you should be able to run index.mjs
and get your profile
information:
Documentation
The SDK’s documentation can be found in its repository and code snippets for each endpoint are included in the Val Town OpenAPI reference