Val Town
Last updated
Last updated
Val Town is a service for running lightweight Javascript/Typescript code blocks in the cloud.
Val Town’s Web API lets you expose Vals as standard API endpoints.
In Val Town, click the Val’s three-dot menu and copy the web endpoint:
In PixieBrix, add the HTTP Request and call the Val’s Web API endpoint as a standard API:
URL: the Web API endpoint
Method: refer to the Val for allowed methods
Search Parameters: refer to the Val for available search/query parameters
Headers: refer to the Val for the required/optional headers
JSON Data: refer to the Val for the JSON payload
Val Town’s Run API lets you run any Val as an API
In Val Town, use the three-dot menu to Endpoints > Copy run endpoint
If your Val expected arguments, you must construct the arguments for the call. The Run Endpoint expects an array of arguments.
In PixieBrix, there are two bricks available for creating a JSON array payload:
Parse JSON
jq - JSON processor brick
For example, to construct a hard-coded payload with the jq brick:
Constructing a hard-coded payload with the jq brick
To make a request to the Run endpoint for a Val, add the HTTP Request. Configure the HTTP Request brick:
URL: the URL for the Run endpoint for your val
Method: post
JSON Data: add an args
property, and pass the array of arguments
Passing arguments to the Val Run API
📚 For general information on configuring integrations, see Configuring Integrations
To make a request to a private Val, you must pass your Val Town API Token with the request.
To set up a cloud integration that your team can access, head to the Admin Console. (If you'd rather set up something locally, use the Extension Console. Learn more about Configuring Integrations.)
From the Integrations section in the Admin or Extension Console, click the + Add Integration button in the top right corner.
Search for and select the Val Town integration.
Configure the Val Town integration, providing your Val Town API Token from https://docs.val.town/api/authentication
In Val Town, copy the run fetch or express fetch endpoint for the val
From the copied endpoint, note the:
URL
Method
In the PixieBrix Page Editor, add the HTTP Request brick, and provide the following information:
URL: the URL for the Val
Integration Configuration: the integration you configured
Method: the HTTP method copied from the endpoint