Skip to content

My resources

When using the Val Town API, some of the most common functions operate on things that you own. For these kinds of operations, there are the “me” routes.

GET /v1/me

ExampleRun in Val Town ↗
import { fetchJSON } from "https://esm.town/v/stevekrouse/fetchJSON?v=41";
export let getMe = fetchJSON(`https://api.val.town/v1/me`, {
headers: {
Authorization: `Bearer ${Deno.env.get("valtown")}`,
},
});

GET /v1/me/runs

ExampleRun in Val Town ↗
import { runs } from "https://esm.town/v/stevekrouse/runs?v=17";
export let getRuns = runs({
token: Deno.env.get("valtown"),
error: false,
limit: 10,
offset: 0,
// last 30 minutes
since: new Date(Number(new Date()) - 1800000),
until: new Date(),
});

GET /v1/me/likes

ExampleRun in Val Town ↗
import { likes } from "https://esm.town/v/neverstew/likes";
export let getLikes = likes({
token: Deno.env.get("valtown"),
limit: 10,
offset: 0,
});

GET /v1/me/comments

ExampleRun in Val Town ↗
import { comments } from "https://esm.town/v/neverstew/comments";
export let getComments = comments({
token: Deno.env.get("valtown"),
relationship: "any",
limit: 10,
offset: 0,
// last 30 minutes
since: new Date(Number(new Date()) - 1800000),
until: new Date(),
});