Val Town Code SearchReturn to Val Town

API Access

You can access search results via JSON API by adding format=json to your query:

https://codesearch.val.run/?q=api&page=452&format=json

For typeahead suggestions, use the /typeahead endpoint:

https://codesearch.val.run/typeahead?q=api

Returns an array of strings in format "username" or "username/projectName"

Found 4887 results for "api"(641ms)

vtOpenAPImain.tsx1 match

@stevekrouse•Updated 12 months ago
1// set at Thu May 02 2024 18:00:24 GMT+0000 (Coordinated Universal Time)
2export let vtOpenAPI = "openapi: 3.1.0\ninfo:\n title: Val Town API\n description: |\n The Val Town API provides services to evaluate JavaScript and TypeScript expressions, run vals as APIs, either as functions or Express handlers.\n\n Learn more at [https://docs.val.town](https://docs.val.town)\n version: 1.7.0\nservers:\n - url: https://api.val.town\n description: Val Town API v1\n\ncomponents:\n securitySchemes:\n bearerAuth:\n type: http\n scheme: bearer\n bearerFormat: API Key\n schemas:\n JSON:\n oneOf:\n - type: string\n - type: number\n - type: object\n - type: array\n items: {}\n - type: boolean\n description: \"Can be anything: string, number, array, object, etc., including `null`\"\n Relationship:\n type: string\n enum: [\"received\", \"given\", \"any\"]\n Privacy:\n type: string\n enum: [\"public\", \"unlisted\", \"private\"]\n Author:\n type: object\n properties:\n id:\n description: The user's id\n type: string\n format: uuid\n username:\n description: The user's username\n type: string\n User:\n type: object\n allOf:\n - $ref: \"#/components/schemas/Author\"\n properties:\n bio:\n description: The user's bio\n type:\n - string\n - \"null\"\n profileImageUrl:\n description: The url for the user's profile picture\n type:\n - string\n - \"null\"\n BaseVal:\n type: object\n properties:\n id:\n type: string\n format: uuid\n author:\n $ref: \"#/components/schemas/Author\"\n name:\n type: string\n code:\n type: string\n public:\n type: boolean\n deprecated: true\n privacy:\n $ref: \"#/components/schemas/Privacy\"\n version:\n type: integer\n format: int32\n runEndAt:\n type:\n - string\n - \"null\"\n format: date-time\n deprecated: true\n runStartAt:\n type:\n - string\n - \"null\"\n format: date-time\n deprecated: true\n FullVal:\n type: object\n allOf:\n - $ref: \"#/components/schemas/BaseVal\"\n properties:\n logs:\n type: array\n items: {}\n output:\n type: object\n exported:\n type: object\n error:\n type: object\n readme:\n type: string\n likeCount:\n type: number\n referenceCount:\n type: number\n ValFields:\n type: object\n properties:\n name:\n type: string\n privacy:\n $ref: \"#/components/schemas/Privacy\"\n readme:\n type:\n - string\n - \"null\"\n ValInput:\n type: object\n allOf:\n - $ref: \"#/components/schemas/ValFields\"\n properties:\n code:\n type: string\n PaginatedList:\n type: object\n properties:\n data:\n type: array\n links:\n type: object\n properties:\n self:\n description: The URL of the current page of results\n type: string\n format: uri\n next:\n description: The URL of the next page of results\n type: string\n format: uri\n prev:\n description: The URL of the previous page of results\n type: string\n format: uri\n ValList:\n type: object\n allOf:\n - $ref: \"#/components/schemas/PaginatedList\"\n properties:\n data:\n type: array\n items:\n $ref: \"#/components/schemas/BaseVal\"\n BaseValRef:\n type: object\n properties:\n id:\n description: The id of the val\n type: string\n name:\n description: The name of the val\n type: string\n author:\n $ref: \"#/components/schemas/Author\"\n author_id:\n description: The id of the val's author\n type: string\n deprecated: true\n username:\n description: The username of the val's author\n type: string\n deprecated: true\n ValRef:\n type: object\n allOf:\n - $ref: \"#/components/schemas/BaseValRef\"\n properties:\n public:\n type: boolean\n deprecated: true\n privacy:\n $ref: \"#/components/schemas/Privacy\"\n version:\n type: integer\n format: int32\n BaseRun:\n type: object\n properties:\n id:\n type: string\n format: uuid\n error: {}\n parentId:\n type: string\n format: uuid\n runEndAt:\n type:\n - string\n - \"null\"\n format: date-time\n deprecated: true\n runStartAt:\n type:\n - string\n - \"null\"\n format: date-time\n deprecated: true\n val:\n $ref: \"#/components/schemas/ValRef\"\n FullRun:\n type: object\n allOf:\n - $ref: \"#/components/schemas/BaseRun\"\n properties:\n emails:\n type: array\n items: {}\n logs:\n type: array\n items: {}\n returnValue: {}\n args:\n type: array\n items: {}\n RunList:\n type: object\n allOf:\n - $ref: \"#/components/schemas/PaginatedList\"\n properties:\n data:\n type: array\n items:\n $ref: \"#/components/schemas/BaseRun\"\n Comment:\n type: object\n properties:\n id:\n type: string\n format: uuid\n author:\n $ref: \"#/components/schemas/Author\"\n comment:\n description: The contents of the comment\n type: string\n createdAt:\n type: string\n format: date-time\n val:\n $ref: \"#/components/schemas/ValRef\"\n Reference:\n type: object\n properties:\n referencedAt:\n type: string\n format: date-time\n reference:\n $ref: \"#/components/schemas/BaseValRef\"\n dependsOn:\n $ref: \"#/components/schemas/BaseValRef\"\n CommentList:\n type: object\n allOf:\n - $ref: \"#/components/schemas/PaginatedList\"\n properties:\n data:\n type: array\n items:\n $ref: \"#/components/schemas/Comment\"\n ReferenceList:\n type: object\n allOf:\n - $ref: \"#/components/schemas/PaginatedList\"\n properties:\n data:\n type: array\n items:\n $ref: \"#/components/schemas/Reference\"\n parameters:\n expression:\n in: path\n name: expression\n required: true\n description: |\n The JavaScript or TypeScript expression to be evaluated.\n This should be a single expression, like a single function\n call, assignment operation, or calculation. If you need\n to execute multiple expressions, wrap them in a function.\n schema:\n type: string\n examples:\n simpleAddition:\n value: \"1+1\"\n summary: Simple addition\n functionCall:\n value: \"@stevekrouse.addOne(@stevekrouse.example1)\"\n summary: Calling a user's val function\n user_id:\n name: user_id\n in: path\n required: true\n description: id of the user\n schema:\n type: string\n format: uuid\n examples:\n stevekrouse:\n value: \"a0bf3b31-15a5-4d5c-880e-4b1e22c9bc18\"\n username:\n name: username\n in: path\n required: true\n description: |\n The username of the val owner, *not* including the `@` symbol.\n schema:\n type: string\n examples:\n stevekrouse:\n value: stevekrouse\n summary: Steve Krouse's username\n val_id:\n name: val_id\n in: path\n required: true\n description: id of the val\n schema:\n type: string\n format: uuid\n examples:\n hello:\n value: \"eb4a2ace-b6c8-4393-85e0-4813b3f04e12\"\n val_name:\n name: val_name\n in: path\n required: true\n description: The name of the val.\n schema:\n type: string\n examples:\n id:\n value: id\n summary: \"id\"\n description: |\n This val is a function that returns its arguments. It is useful for testing how the API handles the arguments passed to it.\n\n View the val at [https://val.town/v/stevekrouse.id](https://val.town/v/stevekrouse.id)\n version:\n name: version\n in: path\n required: true\n description: val version\n schema:\n type: number\n run_id:\n name: run_id\n in: path\n required: true\n description: id of the log\n schema:\n type: string\n format: uuid\n examples:\n hello:\n value: \"cd0653ac-aede-4d0d-8c8e-21c7ef763eb2\"\n offset:\n name: offset\n in: query\n description: Pagination offset\n schema:\n type: integer\n default: 0\n minimum: 0\n limit:\n name: limit\n in: query\n description: Pagination limit\n schema:\n type: integer\n default: 20\n minimum: 1\n maximum: 100\n comments_since:\n name: since\n in: query\n description: Return comments where `createdAt > since` (non-inclusive)\n schema:\n type: string\n examples:\n isostring:\n $ref: \"#/components/examples/isostring\"\n comments_until:\n name: until\n in: query\n description: Return comments where `createdAt <= until` (inclusive)\n schema:\n type: string\n examples:\n isostring:\n $ref: \"#/components/examples/isostring\"\n references_since:\n name: since\n in: query\n description: Return references where `referencedAt > since` (non-inclusive)\n schema:\n type: string\n examples:\n isostring:\n $ref: \"#/components/examples/isostring\"\n references_until:\n name: until\n in: query\n description: Return references where `referencedAt <= until` (inclusive)\n schema:\n type: string\n examples:\n isostring:\n $ref: \"#/components/examples/isostring\"\n relationship:\n name: relationship\n in: query\n schema:\n $ref: \"#/components/schemas/Relationship\"\n examples:\n user_stevekrouse:\n value:\n {\n \"id\": \"a0bf3b31-15a5-4d5c-880e-4b1e22c9bc18\",\n \"username\": \"@stevekrouse\",\n \"bio\": \"mayor of val town\\nhttps://stevekrouse.com\",\n \"profileImageUrl\": \"https://images.clerk.dev/uploaded/img_2PqHa2Gsy93xQrjh2w78Xu0cChW.jpeg\",\n }\n val_hello:\n value:\n {\n \"id\": \"eb4a2ace-b6c8-4393-85e0-4813b3f04e12\",\n \"author\":\n {\n \"id\": \"a0bf3b31-15a5-4d5c-880e-4b1e22c9bc18\",\n \"username\": \"@stevekrouse\",\n },\n \"name\": \"hello\",\n \"code\": 'export let hello = \"Hello World\";',\n \"public\": false,\n \"privacy\": \"private\",\n \"version\": 0,\n \"runStartAt\": null,\n \"runEndAt\": null,\n \"logs\": [],\n \"output\": { \"json\": \"Hello World\" },\n \"exported\": { \"json\": { \"hello\": \"Hello World\" } },\n \"error\": null,\n \"readme\": \"# Hello\",\n \"likeCount\": 0,\n \"referenceCount\": 0,\n }\n val_hello_v1:\n value:\n {\n \"id\": \"eb4a2ace-b6c8-4393-85e0-4813b3f04e12\",\n \"author\":\n {\n \"id\": \"a0bf3b31-15a5-4d5c-880e-4b1e22c9bc18\",\n \"username\": \"@stevekrouse\",\n },\n \"name\": \"hello\",\n \"code\": 'export let hello = \"Hello World 2\";',\n \"public\": false,\n \"privacy\": \"private\",\n \"version\": 1,\n \"runStartAt\": null,\n \"runEndAt\": null,\n \"logs\": [],\n \"output\": { \"json\": \"Hello World 2\" },\n \"exported\": { \"json\": { \"hello\": \"Hello World 2\" } },\n \"error\": null,\n \"readme\": \"# Hello\",\n \"likeCount\": 0,\n \"referenceCount\": 0,\n }\n isostring:\n value: \"2023-07-26T03:28:00.000Z\"\n summary: ISO String\n responses:\n ExpressionResult:\n description: The returned result of executing the passed expression successfully. The result can be of any JSON type. It will not include any logs that were generated during execution.\n content:\n application/json:\n schema:\n oneOf:\n - type: string\n - type: number\n - type: object\n - type: array\n items: {}\n - type: boolean\n examples:\n simpleAddition:\n value: 2\n summary: Simple addition result\n functionCall:\n value: 42\n summary: Calling a function result\n\nsecurity:\n - bearerAuth: []\n - {}\n\npaths:\n /v1/me:\n get:\n summary: Get profile information for the current user\n tags: [Me]\n responses:\n \"200\":\n description: OK\n content:\n application/json:\n schema:\n $ref: \"#/components/schemas/User\"\n examples:\n stevekrouse:\n $ref: \"#/components/examples/user_stevekrouse\"\n \"401\":\n description: Unauthorized\n\n /v1/me/likes:\n get:\n summary: Get vals liked by the current user\n tags: [Me]\n parameters:\n - $ref: \"#/components/parameters/offset\"\n - $ref: \"#/components/parameters/limit\"\n responses:\n \"200\":\n description: OK\n content:\n application/json:\n schema:\n $ref: \"#/components/schemas/ValList\"\n \"401\":\n description: Unauthorized\n\n /v1/me/comments:\n get:\n summary: Get comments related to current user, either given or received\n tags: [Me]\n parameters:\n - $ref: \"#/components/parameters/offset\"\n - $ref: \"#/components/parameters/limit\"\n - $ref: \"#/components/parameters/comments_since\"\n - $ref: \"#/components/parameters/comments_until\"\n - $ref: \"#/components/parameters/relationship\"\n responses:\n \"200\":\n description: OK\n content:\n application/json:\n schema:\n $ref: \"#/components/schemas/CommentList\"\n \"401\":\n description: Unauthorized\n\n /v1/me/references:\n get:\n summary: Returns vals that depend on any of the user's vals\n tags: [Me]\n parameters:\n - $ref: \"#/components/parameters/offset\"\n - $ref: \"#/components/parameters/limit\"\n - $ref: \"#/components/parameters/references_since\"\n - $ref: \"#/components/parameters/references_until\"\n responses:\n \"200\":\n description: OK\n content:\n application/json:\n schema:\n $ref: \"#/components/schemas/ReferenceList\"\n \"401\":\n description: Unauthorized\n\n /v1/vals:\n post:\n summary: Create a new val\n tags: [Vals]\n requestBody:\n description: Code of the new val to be run.\n required: true\n content:\n application/json:\n schema:\n $ref: \"#/components/schemas/ValInput\"\n examples:\n increment:\n value: { \"code\": 'let hello = \"Hello World\";' }\n text/plain:\n schema:\n type: string\n examples:\n increment:\n value: 'let hello = \"Hello World\";'\n text/javascript:\n schema:\n type: string\n examples:\n increment:\n value: 'let hello = \"Hello World\";'\n application/javascript:\n schema:\n type: string\n examples:\n increment:\n value: 'let hello = \"Hello World\";'\n responses:\n \"200\":\n description: OK\n content:\n application/json:\n schema:\n $ref: \"#/components/schemas/FullVal\"\n examples:\n hello:\n $ref: \"#/components/examples/val_hello\"\n \"401\":\n description: Unauthorized\n put:\n summary: Create or update a val by name and code.\n tags: [Vals]\n requestBody:\n description: The JSON to set the val to\n required: true\n content:\n application/json:\n schema:\n type: object\n properties:\n name:\n type: string\n description: Name of the val\n code:\n type: string\n description: Code to run for the val\n required:\n - name\n - code\n responses:\n \"200\":\n description: OK\n content:\n application/json:\n schema:\n $ref: \"#/components/schemas/BaseVal\"\n \"401\":\n description: Unauthorized\n \"400\":\n description: Error\n\n /v1/vals/{val_id}:\n get:\n summary: Get val by id\n tags: [Vals]\n parameters:\n - $ref: \"#/components/parameters/val_id\"\n responses:\n \"200\":\n description: OK\n content:\n application/json:\n schema:\n $ref: \"#/components/schemas/FullVal\"\n examples:\n hello:\n $ref: \"#/components/examples/val_hello\"\n \"404\":\n description: Val not found\n put:\n summary: Update a val's name or privacy\n tags: [Vals]\n parameters:\n - $ref: \"#/components/parameters/val_id\"\n requestBody:\n description: Fields to be updated.\n required: true\n content:\n application/json:\n schema:\n $ref: \"#/components/schemas/ValFields\"\n examples:\n name_and_privacy:\n value: { \"name\": \"hello\", \"privacy\": \"unlisted\" }\n responses:\n \"204\":\n description: No Content\n \"401\":\n description: Unauthorized\n delete:\n summary: Delete a val\n tags: [Vals]\n parameters:\n - $ref: \"#/components/parameters/val_id\"\n responses:\n \"204\":\n description: No Content\n\n /v1/vals/{val_id}/versions:\n get:\n summary: List versions of a val\n tags: [Vals]\n parameters:\n - $ref: \"#/components/parameters/val_id\"\n - $ref: \"#/components/parameters/offset\"\n - $ref: \"#/components/parameters/limit\"\n responses:\n \"200\":\n description: OK\n content:\n application/json:\n schema:\n type: object\n allOf:\n - $ref: \"#/components/schemas/PaginatedList\"\n properties:\n data:\n type: array\n items:\n type: object\n properties:\n val_id:\n type: string\n format: uuid\n description: Unique identifier for the val.\n version:\n type: number\n description: Version number of the val.\n runStartAt:\n type:\n - string\n - \"null\"\n format: date-time\n deprecated: true\n runEndAt:\n type:\n - string\n - \"null\"\n format: date-time\n deprecated: true\n \"404\":\n description: Val not found\n post:\n summary: Create a new version of a val\n tags: [Vals]\n parameters:\n - $ref: \"#/components/parameters/val_id\"\n requestBody:\n description: Code of the new version to be run.\n required: true\n content:\n application/json:\n schema:\n $ref: \"#/components/schemas/ValInput\"\n examples:\n increment:\n value: { \"code\": 'let hello = \"Hello World 2\";' }\n text/plain:\n schema:\n type: string\n examples:\n increment:\n value: 'let hello = \"Hello World 2\";'\n text/javascript:\n schema:\n type: string\n examples:\n increment:\n value: 'let hello = \"Hello World 2\";'\n application/javascript:\n schema:\n type: string\n examples:\n increment:\n value: 'let hello = \"Hello World 2\";'\n responses:\n \"201\":\n description: Created\n content:\n application/json:\n schema:\n $ref: \"#/components/schemas/FullVal\"\n examples:\n hello:\n $ref: \"#/components/examples/val_hello_v1\"\n \"404\":\n description: Val not found\n\n /v1/vals/{val_id}/versions/{version}:\n get:\n summary: Get a specific version of a val\n tags: [Vals]\n parameters:\n - $ref: \"#/components/parameters/val_id\"\n - $ref: \"#/components/parameters/version\"\n responses:\n \"200\":\n description: OK\n content:\n application/json:\n schema:\n $ref: \"#/components/schemas/FullVal\"\n examples:\n hello:\n $ref: \"#/components/examples/val_hello\"\n \"404\":\n description: Val or version not found\n delete:\n summary: Delete a val version\n tags: [Vals]\n parameters:\n - $ref: \"#/components/parameters/val_id\"\n - $ref: \"#/components/parameters/version\"\n responses:\n \"204\":\n description: No Content\n\n /v1/users/{user_id}/vals:\n get:\n summary: List a user's vals\n tags: [Users]\n parameters:\n - $ref: \"#/components/parameters/user_id\"\n - $ref: \"#/components/parameters/offset\"\n - $ref: \"#/components/parameters/limit\"\n responses:\n \"200\":\n description: OK\n content:\n application/json:\n schema:\n $ref: \"#/components/schemas/ValList\"\n\n /v1/alias/{username}:\n get:\n summary: Get a user profile information by their username\n tags: [Alias]\n parameters:\n - $ref: \"#/components/parameters/username\"\n responses:\n \"200\":\n description: OK\n content:\n application/json:\n schema:\n $ref: \"#/components/schemas/User\"\n examples:\n stevekrouse:\n $ref: \"#/components/examples/user_stevekrouse\"\n \"404\":\n description: Not found\n\n /v1/alias/{username}/{val_name}:\n get:\n summary: Get a val by the author's username and val name\n tags: [Alias]\n parameters:\n - $ref: \"#/components/parameters/username\"\n - $ref: \"#/components/parameters/val_name\"\n responses:\n \"200\":\n description: OK\n content:\n application/json:\n schema:\n $ref: \"#/components/schemas/FullVal\"\n \"404\":\n description: Not found\n\n /v1/search/vals:\n get:\n summary: Search for vals across the platform\n tags: [Search]\n parameters:\n - name: query\n in: query\n description: Search query\n required: true\n schema:\n type: string\n minLength: 1\n maxLength: 512\n - $ref: \"#/components/parameters/offset\"\n - $ref: \"#/components/parameters/limit\"\n responses:\n \"200\":\n description: OK\n content:\n application/json:\n schema:\n $ref: \"#/components/schemas/ValList\"\n\n /v1/eval/{expression}:\n get:\n summary: Evaluate a JavaScript or TypeScript expression\n tags: [\"Eval\"]\n description: |\n Evaluates the JavaScript or TypeScript `{expression}` and responds with the returned result. \n\n ### Unauthenticated\n Unauthenticated use will have read-only access to public vals. \n\n ### Authenticated\n Authenticated use will have read access to the authenticated user's private vals and secrets, write access to the authenticated user's vals, and the ability to send the authenticated user emails via `console.email`.\n\n Vals generated via this API will *not* appear in the authenticated user's workspace.\n parameters:\n - $ref: \"#/components/parameters/expression\"\n responses:\n \"200\":\n $ref: \"#/components/responses/ExpressionResult\"\n \"400\":\n description: Bad request or Error thrown executing user code\n \"404\":\n description: Not found\n \"500\":\n description: Internal server error\n\n /v1/eval:\n post:\n summary: Evaluate a JavaScript or TypeScript expression\n tags: [\"Eval\"]\n description: |\n Evaluates the JavaScript or TypeScript `{expression}` and responds with the returned result. \n\n ### Unauthenticated\n Unauthenticated use will have read-only access to public vals. \n\n ### Authenticated\n Authenticated use will have read access to the authenticated user's private vals and secrets, write access to the authenticated user's vals, and the ability to send the authenticated user emails via `console.email`.\n\n Vals generated via this API will *not* appear in the authenticated user's workspace.\n requestBody:\n description: When used as a POST endpoint, the request body\n must contain the code to be run.\n required: true\n content:\n application/json:\n schema:\n type: object\n required: [\"code\"]\n properties:\n code:\n type: string\n args:\n type: array\n items:\n $ref: \"#/components/schemas/JSON\"\n examples:\n \"Add two numbers\":\n value: { \"code\": \"(a, b) => a + b\", \"args\": [1, 42] }\n responses:\n \"200\":\n $ref: \"#/components/responses/ExpressionResult\"\n \"400\":\n description: Bad request or Error thrown executing user code\n \"404\":\n description: Not found\n \"500\":\n description: Internal server error\n\n /v1/run/{username}.{val_name}:\n get:\n deprecated: true\n summary: Run a val as an API\n tags: [\"Run\"]\n description: This endpoint runs the specified user's val and returns the output.\n parameters:\n - $ref: \"#/components/parameters/username\"\n - $ref: \"#/components/parameters/val_name\"\n - in: query\n name: args\n schema:\n type: string\n description: The args query parameter can provide arguments to the given val. The parameter needs to be a JSON-encoded array, in which each item in the array is passed to the val as a function parameter.\n examples:\n name:\n value: '[\"Steve\"]'\n summary: Calling a function with a single string argument\n empty:\n value: \"\"\n responses:\n \"200\":\n $ref: \"#/components/responses/ExpressionResult\"\n \"400\":\n description: Bad request or Error thrown executing user code\n \"404\":\n description: Not found\n \"500\":\n description: Internal server error\n post:\n deprecated: true\n summary: Run a val as an API\n tags: [\"Run\"]\n parameters:\n - $ref: \"#/components/parameters/username\"\n - $ref: \"#/components/parameters/val_name\"\n requestBody:\n required: false\n description: Provide arguments to the given val function by including a post body with your request.\n content:\n application/json:\n schema:\n type: object\n additionalProperties: false\n properties:\n args:\n type: array\n items:\n $ref: \"#/components/schemas/JSON\"\n responses:\n \"200\":\n $ref: \"#/components/responses/ExpressionResult\"\n \"400\":\n description: Bad request or Error thrown executing user code\n \"404\":\n description: Not found\n \"500\":\n description: Internal server error\n\n \"/\":\n servers:\n - url: https://{username}-{val_name}.express.val.run\n description: Val Town API v1\n variables:\n username:\n default: stevekrouse\n val:\n default: expressHTMLExample\n get:\n summary: Run a val as an API (as an Express handler)\n tags: [\"Express\"]\n description: |\n Runs `@{username}.{val_name}` as an Express handler. \n\n `@{username}.{val_name}` must be a function. It is passed the Express [`req`](https://expressjs.com/en/4x/api.html#req) and [`res`](https://expressjs.com/en/4x/api.html#res) objects as its arguments. You can use `req` to pull out request data, and `res` to respond with any valid Express response. Learn more at the [Express docs](https://expressjs.com/en/4x/api.html).\n\n Unlike the other two APIs, the Express API is specified via subdomain and runs at `https://{username}-{val_name}.express.val.run`.\n\n ### Unauthenticated\n Unauthenticated use will only be able to call public vals as Express handlers.\n\n The val will be executed with `{username}`'s permissions (\"API Mode\"), so it will be able to read and write to `{username}`'s public and private vals, secrets, and use `console.email`.\n\n ### Authenticated\n Authenticated use is able to call private vals as Express handlers.\n responses:\n \"200\":\n description: Function executed successfully\n content:\n \"*/*\":\n schema:\n type: string\n description: The result of the executed function, in any media type\n \"400\":\n description: Bad request or Error thrown executing user code\n \"404\":\n description: Not found\n \"500\":\n description: Internal server error\n post:\n summary: Run a val as an API (as an Express handler)\n tags: [\"Express\"]\n description: |\n Runs `@{username}.{val_name}` as an Express handler. \n\n `@{username}.{val_name}` must be a function. It is passed the Express [`req`](https://expressjs.com/en/4x/api.html#req) and [`res`](https://expressjs.com/en/4x/api.html#res) objects as its arguments. You can use `req` to pull out request data, and `res` to respond with any valid Express response. Learn more at the [Express docs](https://expressjs.com/en/4x/api.html).\n\n ### Unauthenticated\n Unauthenticated use will only be able to call public vals as Express handlers.\n\n The val will be executed with `{username}`'s permissions (\"API Mode\"), so it will be able to read and write to `{username}`'s public and private vals, secrets, and use `console.email`.\n\n ### Authenticated\n Authenticated use is able to call private vals as Express handlers.\n requestBody:\n description: |\n The request body will be accessible to the val Express handler under the first argument, commonly called `req`, as `req.body`.\n required: false\n content:\n application/json:\n schema:\n $ref: \"#/components/schemas/JSON\"\n examples:\n name:\n value: '{\"name\": \"Steve\"}'\n summary: JSON object as the request body\n responses:\n \"200\":\n description: Function executed successfully\n content:\n \"*/*\":\n schema:\n type: string\n description: The result of the executed function, in any media type\n \"400\":\n description: Bad request or Error thrown executing user code\n \"404\":\n description: Not found\n \"500\":\n description: Internal server error\n";

vtOpenAPI_migratedmain.tsx1 match

@stevekrouse•Updated 12 months ago
1// set at Thu May 02 2024 18:00:24 GMT+0000 (Coordinated Universal Time)
2export let vtOpenAPI = "openapi: 3.1.0\ninfo:\n title: Val Town API\n description: |\n The Val Town API provides services to evaluate JavaScript and TypeScript expressions, run vals as APIs, either as functions or Express handlers.\n\n Learn more at [https://docs.val.town](https://docs.val.town)\n version: 1.7.0\nservers:\n - url: https://api.val.town\n description: Val Town API v1\n\ncomponents:\n securitySchemes:\n bearerAuth:\n type: http\n scheme: bearer\n bearerFormat: API Key\n schemas:\n JSON:\n oneOf:\n - type: string\n - type: number\n - type: object\n - type: array\n items: {}\n - type: boolean\n description: \"Can be anything: string, number, array, object, etc., including `null`\"\n Relationship:\n type: string\n enum: [\"received\", \"given\", \"any\"]\n Privacy:\n type: string\n enum: [\"public\", \"unlisted\", \"private\"]\n Author:\n type: object\n properties:\n id:\n description: The user's id\n type: string\n format: uuid\n username:\n description: The user's username\n type: string\n User:\n type: object\n allOf:\n - $ref: \"#/components/schemas/Author\"\n properties:\n bio:\n description: The user's bio\n type:\n - string\n - \"null\"\n profileImageUrl:\n description: The url for the user's profile picture\n type:\n - string\n - \"null\"\n BaseVal:\n type: object\n properties:\n id:\n type: string\n format: uuid\n author:\n $ref: \"#/components/schemas/Author\"\n name:\n type: string\n code:\n type: string\n public:\n type: boolean\n deprecated: true\n privacy:\n $ref: \"#/components/schemas/Privacy\"\n version:\n type: integer\n format: int32\n runEndAt:\n type:\n - string\n - \"null\"\n format: date-time\n deprecated: true\n runStartAt:\n type:\n - string\n - \"null\"\n format: date-time\n deprecated: true\n FullVal:\n type: object\n allOf:\n - $ref: \"#/components/schemas/BaseVal\"\n properties:\n logs:\n type: array\n items: {}\n output:\n type: object\n exported:\n type: object\n error:\n type: object\n readme:\n type: string\n likeCount:\n type: number\n referenceCount:\n type: number\n ValFields:\n type: object\n properties:\n name:\n type: string\n privacy:\n $ref: \"#/components/schemas/Privacy\"\n readme:\n type:\n - string\n - \"null\"\n ValInput:\n type: object\n allOf:\n - $ref: \"#/components/schemas/ValFields\"\n properties:\n code:\n type: string\n PaginatedList:\n type: object\n properties:\n data:\n type: array\n links:\n type: object\n properties:\n self:\n description: The URL of the current page of results\n type: string\n format: uri\n next:\n description: The URL of the next page of results\n type: string\n format: uri\n prev:\n description: The URL of the previous page of results\n type: string\n format: uri\n ValList:\n type: object\n allOf:\n - $ref: \"#/components/schemas/PaginatedList\"\n properties:\n data:\n type: array\n items:\n $ref: \"#/components/schemas/BaseVal\"\n BaseValRef:\n type: object\n properties:\n id:\n description: The id of the val\n type: string\n name:\n description: The name of the val\n type: string\n author:\n $ref: \"#/components/schemas/Author\"\n author_id:\n description: The id of the val's author\n type: string\n deprecated: true\n username:\n description: The username of the val's author\n type: string\n deprecated: true\n ValRef:\n type: object\n allOf:\n - $ref: \"#/components/schemas/BaseValRef\"\n properties:\n public:\n type: boolean\n deprecated: true\n privacy:\n $ref: \"#/components/schemas/Privacy\"\n version:\n type: integer\n format: int32\n BaseRun:\n type: object\n properties:\n id:\n type: string\n format: uuid\n error: {}\n parentId:\n type: string\n format: uuid\n runEndAt:\n type:\n - string\n - \"null\"\n format: date-time\n deprecated: true\n runStartAt:\n type:\n - string\n - \"null\"\n format: date-time\n deprecated: true\n val:\n $ref: \"#/components/schemas/ValRef\"\n FullRun:\n type: object\n allOf:\n - $ref: \"#/components/schemas/BaseRun\"\n properties:\n emails:\n type: array\n items: {}\n logs:\n type: array\n items: {}\n returnValue: {}\n args:\n type: array\n items: {}\n RunList:\n type: object\n allOf:\n - $ref: \"#/components/schemas/PaginatedList\"\n properties:\n data:\n type: array\n items:\n $ref: \"#/components/schemas/BaseRun\"\n Comment:\n type: object\n properties:\n id:\n type: string\n format: uuid\n author:\n $ref: \"#/components/schemas/Author\"\n comment:\n description: The contents of the comment\n type: string\n createdAt:\n type: string\n format: date-time\n val:\n $ref: \"#/components/schemas/ValRef\"\n Reference:\n type: object\n properties:\n referencedAt:\n type: string\n format: date-time\n reference:\n $ref: \"#/components/schemas/BaseValRef\"\n dependsOn:\n $ref: \"#/components/schemas/BaseValRef\"\n CommentList:\n type: object\n allOf:\n - $ref: \"#/components/schemas/PaginatedList\"\n properties:\n data:\n type: array\n items:\n $ref: \"#/components/schemas/Comment\"\n ReferenceList:\n type: object\n allOf:\n - $ref: \"#/components/schemas/PaginatedList\"\n properties:\n data:\n type: array\n items:\n $ref: \"#/components/schemas/Reference\"\n parameters:\n expression:\n in: path\n name: expression\n required: true\n description: |\n The JavaScript or TypeScript expression to be evaluated.\n This should be a single expression, like a single function\n call, assignment operation, or calculation. If you need\n to execute multiple expressions, wrap them in a function.\n schema:\n type: string\n examples:\n simpleAddition:\n value: \"1+1\"\n summary: Simple addition\n functionCall:\n value: \"@stevekrouse.addOne(@stevekrouse.example1)\"\n summary: Calling a user's val function\n user_id:\n name: user_id\n in: path\n required: true\n description: id of the user\n schema:\n type: string\n format: uuid\n examples:\n stevekrouse:\n value: \"a0bf3b31-15a5-4d5c-880e-4b1e22c9bc18\"\n username:\n name: username\n in: path\n required: true\n description: |\n The username of the val owner, *not* including the `@` symbol.\n schema:\n type: string\n examples:\n stevekrouse:\n value: stevekrouse\n summary: Steve Krouse's username\n val_id:\n name: val_id\n in: path\n required: true\n description: id of the val\n schema:\n type: string\n format: uuid\n examples:\n hello:\n value: \"eb4a2ace-b6c8-4393-85e0-4813b3f04e12\"\n val_name:\n name: val_name\n in: path\n required: true\n description: The name of the val.\n schema:\n type: string\n examples:\n id:\n value: id\n summary: \"id\"\n description: |\n This val is a function that returns its arguments. It is useful for testing how the API handles the arguments passed to it.\n\n View the val at [https://val.town/v/stevekrouse.id](https://val.town/v/stevekrouse.id)\n version:\n name: version\n in: path\n required: true\n description: val version\n schema:\n type: number\n run_id:\n name: run_id\n in: path\n required: true\n description: id of the log\n schema:\n type: string\n format: uuid\n examples:\n hello:\n value: \"cd0653ac-aede-4d0d-8c8e-21c7ef763eb2\"\n offset:\n name: offset\n in: query\n description: Pagination offset\n schema:\n type: integer\n default: 0\n minimum: 0\n limit:\n name: limit\n in: query\n description: Pagination limit\n schema:\n type: integer\n default: 20\n minimum: 1\n maximum: 100\n comments_since:\n name: since\n in: query\n description: Return comments where `createdAt > since` (non-inclusive)\n schema:\n type: string\n examples:\n isostring:\n $ref: \"#/components/examples/isostring\"\n comments_until:\n name: until\n in: query\n description: Return comments where `createdAt <= until` (inclusive)\n schema:\n type: string\n examples:\n isostring:\n $ref: \"#/components/examples/isostring\"\n references_since:\n name: since\n in: query\n description: Return references where `referencedAt > since` (non-inclusive)\n schema:\n type: string\n examples:\n isostring:\n $ref: \"#/components/examples/isostring\"\n references_until:\n name: until\n in: query\n description: Return references where `referencedAt <= until` (inclusive)\n schema:\n type: string\n examples:\n isostring:\n $ref: \"#/components/examples/isostring\"\n relationship:\n name: relationship\n in: query\n schema:\n $ref: \"#/components/schemas/Relationship\"\n examples:\n user_stevekrouse:\n value:\n {\n \"id\": \"a0bf3b31-15a5-4d5c-880e-4b1e22c9bc18\",\n \"username\": \"@stevekrouse\",\n \"bio\": \"mayor of val town\\nhttps://stevekrouse.com\",\n \"profileImageUrl\": \"https://images.clerk.dev/uploaded/img_2PqHa2Gsy93xQrjh2w78Xu0cChW.jpeg\",\n }\n val_hello:\n value:\n {\n \"id\": \"eb4a2ace-b6c8-4393-85e0-4813b3f04e12\",\n \"author\":\n {\n \"id\": \"a0bf3b31-15a5-4d5c-880e-4b1e22c9bc18\",\n \"username\": \"@stevekrouse\",\n },\n \"name\": \"hello\",\n \"code\": 'export let hello = \"Hello World\";',\n \"public\": false,\n \"privacy\": \"private\",\n \"version\": 0,\n \"runStartAt\": null,\n \"runEndAt\": null,\n \"logs\": [],\n \"output\": { \"json\": \"Hello World\" },\n \"exported\": { \"json\": { \"hello\": \"Hello World\" } },\n \"error\": null,\n \"readme\": \"# Hello\",\n \"likeCount\": 0,\n \"referenceCount\": 0,\n }\n val_hello_v1:\n value:\n {\n \"id\": \"eb4a2ace-b6c8-4393-85e0-4813b3f04e12\",\n \"author\":\n {\n \"id\": \"a0bf3b31-15a5-4d5c-880e-4b1e22c9bc18\",\n \"username\": \"@stevekrouse\",\n },\n \"name\": \"hello\",\n \"code\": 'export let hello = \"Hello World 2\";',\n \"public\": false,\n \"privacy\": \"private\",\n \"version\": 1,\n \"runStartAt\": null,\n \"runEndAt\": null,\n \"logs\": [],\n \"output\": { \"json\": \"Hello World 2\" },\n \"exported\": { \"json\": { \"hello\": \"Hello World 2\" } },\n \"error\": null,\n \"readme\": \"# Hello\",\n \"likeCount\": 0,\n \"referenceCount\": 0,\n }\n isostring:\n value: \"2023-07-26T03:28:00.000Z\"\n summary: ISO String\n responses:\n ExpressionResult:\n description: The returned result of executing the passed expression successfully. The result can be of any JSON type. It will not include any logs that were generated during execution.\n content:\n application/json:\n schema:\n oneOf:\n - type: string\n - type: number\n - type: object\n - type: array\n items: {}\n - type: boolean\n examples:\n simpleAddition:\n value: 2\n summary: Simple addition result\n functionCall:\n value: 42\n summary: Calling a function result\n\nsecurity:\n - bearerAuth: []\n - {}\n\npaths:\n /v1/me:\n get:\n summary: Get profile information for the current user\n tags: [Me]\n responses:\n \"200\":\n description: OK\n content:\n application/json:\n schema:\n $ref: \"#/components/schemas/User\"\n examples:\n stevekrouse:\n $ref: \"#/components/examples/user_stevekrouse\"\n \"401\":\n description: Unauthorized\n\n /v1/me/likes:\n get:\n summary: Get vals liked by the current user\n tags: [Me]\n parameters:\n - $ref: \"#/components/parameters/offset\"\n - $ref: \"#/components/parameters/limit\"\n responses:\n \"200\":\n description: OK\n content:\n application/json:\n schema:\n $ref: \"#/components/schemas/ValList\"\n \"401\":\n description: Unauthorized\n\n /v1/me/comments:\n get:\n summary: Get comments related to current user, either given or received\n tags: [Me]\n parameters:\n - $ref: \"#/components/parameters/offset\"\n - $ref: \"#/components/parameters/limit\"\n - $ref: \"#/components/parameters/comments_since\"\n - $ref: \"#/components/parameters/comments_until\"\n - $ref: \"#/components/parameters/relationship\"\n responses:\n \"200\":\n description: OK\n content:\n application/json:\n schema:\n $ref: \"#/components/schemas/CommentList\"\n \"401\":\n description: Unauthorized\n\n /v1/me/references:\n get:\n summary: Returns vals that depend on any of the user's vals\n tags: [Me]\n parameters:\n - $ref: \"#/components/parameters/offset\"\n - $ref: \"#/components/parameters/limit\"\n - $ref: \"#/components/parameters/references_since\"\n - $ref: \"#/components/parameters/references_until\"\n responses:\n \"200\":\n description: OK\n content:\n application/json:\n schema:\n $ref: \"#/components/schemas/ReferenceList\"\n \"401\":\n description: Unauthorized\n\n /v1/vals:\n post:\n summary: Create a new val\n tags: [Vals]\n requestBody:\n description: Code of the new val to be run.\n required: true\n content:\n application/json:\n schema:\n $ref: \"#/components/schemas/ValInput\"\n examples:\n increment:\n value: { \"code\": 'let hello = \"Hello World\";' }\n text/plain:\n schema:\n type: string\n examples:\n increment:\n value: 'let hello = \"Hello World\";'\n text/javascript:\n schema:\n type: string\n examples:\n increment:\n value: 'let hello = \"Hello World\";'\n application/javascript:\n schema:\n type: string\n examples:\n increment:\n value: 'let hello = \"Hello World\";'\n responses:\n \"200\":\n description: OK\n content:\n application/json:\n schema:\n $ref: \"#/components/schemas/FullVal\"\n examples:\n hello:\n $ref: \"#/components/examples/val_hello\"\n \"401\":\n description: Unauthorized\n put:\n summary: Create or update a val by name and code.\n tags: [Vals]\n requestBody:\n description: The JSON to set the val to\n required: true\n content:\n application/json:\n schema:\n type: object\n properties:\n name:\n type: string\n description: Name of the val\n code:\n type: string\n description: Code to run for the val\n required:\n - name\n - code\n responses:\n \"200\":\n description: OK\n content:\n application/json:\n schema:\n $ref: \"#/components/schemas/BaseVal\"\n \"401\":\n description: Unauthorized\n \"400\":\n description: Error\n\n /v1/vals/{val_id}:\n get:\n summary: Get val by id\n tags: [Vals]\n parameters:\n - $ref: \"#/components/parameters/val_id\"\n responses:\n \"200\":\n description: OK\n content:\n application/json:\n schema:\n $ref: \"#/components/schemas/FullVal\"\n examples:\n hello:\n $ref: \"#/components/examples/val_hello\"\n \"404\":\n description: Val not found\n put:\n summary: Update a val's name or privacy\n tags: [Vals]\n parameters:\n - $ref: \"#/components/parameters/val_id\"\n requestBody:\n description: Fields to be updated.\n required: true\n content:\n application/json:\n schema:\n $ref: \"#/components/schemas/ValFields\"\n examples:\n name_and_privacy:\n value: { \"name\": \"hello\", \"privacy\": \"unlisted\" }\n responses:\n \"204\":\n description: No Content\n \"401\":\n description: Unauthorized\n delete:\n summary: Delete a val\n tags: [Vals]\n parameters:\n - $ref: \"#/components/parameters/val_id\"\n responses:\n \"204\":\n description: No Content\n\n /v1/vals/{val_id}/versions:\n get:\n summary: List versions of a val\n tags: [Vals]\n parameters:\n - $ref: \"#/components/parameters/val_id\"\n - $ref: \"#/components/parameters/offset\"\n - $ref: \"#/components/parameters/limit\"\n responses:\n \"200\":\n description: OK\n content:\n application/json:\n schema:\n type: object\n allOf:\n - $ref: \"#/components/schemas/PaginatedList\"\n properties:\n data:\n type: array\n items:\n type: object\n properties:\n val_id:\n type: string\n format: uuid\n description: Unique identifier for the val.\n version:\n type: number\n description: Version number of the val.\n runStartAt:\n type:\n - string\n - \"null\"\n format: date-time\n deprecated: true\n runEndAt:\n type:\n - string\n - \"null\"\n format: date-time\n deprecated: true\n \"404\":\n description: Val not found\n post:\n summary: Create a new version of a val\n tags: [Vals]\n parameters:\n - $ref: \"#/components/parameters/val_id\"\n requestBody:\n description: Code of the new version to be run.\n required: true\n content:\n application/json:\n schema:\n $ref: \"#/components/schemas/ValInput\"\n examples:\n increment:\n value: { \"code\": 'let hello = \"Hello World 2\";' }\n text/plain:\n schema:\n type: string\n examples:\n increment:\n value: 'let hello = \"Hello World 2\";'\n text/javascript:\n schema:\n type: string\n examples:\n increment:\n value: 'let hello = \"Hello World 2\";'\n application/javascript:\n schema:\n type: string\n examples:\n increment:\n value: 'let hello = \"Hello World 2\";'\n responses:\n \"201\":\n description: Created\n content:\n application/json:\n schema:\n $ref: \"#/components/schemas/FullVal\"\n examples:\n hello:\n $ref: \"#/components/examples/val_hello_v1\"\n \"404\":\n description: Val not found\n\n /v1/vals/{val_id}/versions/{version}:\n get:\n summary: Get a specific version of a val\n tags: [Vals]\n parameters:\n - $ref: \"#/components/parameters/val_id\"\n - $ref: \"#/components/parameters/version\"\n responses:\n \"200\":\n description: OK\n content:\n application/json:\n schema:\n $ref: \"#/components/schemas/FullVal\"\n examples:\n hello:\n $ref: \"#/components/examples/val_hello\"\n \"404\":\n description: Val or version not found\n delete:\n summary: Delete a val version\n tags: [Vals]\n parameters:\n - $ref: \"#/components/parameters/val_id\"\n - $ref: \"#/components/parameters/version\"\n responses:\n \"204\":\n description: No Content\n\n /v1/users/{user_id}/vals:\n get:\n summary: List a user's vals\n tags: [Users]\n parameters:\n - $ref: \"#/components/parameters/user_id\"\n - $ref: \"#/components/parameters/offset\"\n - $ref: \"#/components/parameters/limit\"\n responses:\n \"200\":\n description: OK\n content:\n application/json:\n schema:\n $ref: \"#/components/schemas/ValList\"\n\n /v1/alias/{username}:\n get:\n summary: Get a user profile information by their username\n tags: [Alias]\n parameters:\n - $ref: \"#/components/parameters/username\"\n responses:\n \"200\":\n description: OK\n content:\n application/json:\n schema:\n $ref: \"#/components/schemas/User\"\n examples:\n stevekrouse:\n $ref: \"#/components/examples/user_stevekrouse\"\n \"404\":\n description: Not found\n\n /v1/alias/{username}/{val_name}:\n get:\n summary: Get a val by the author's username and val name\n tags: [Alias]\n parameters:\n - $ref: \"#/components/parameters/username\"\n - $ref: \"#/components/parameters/val_name\"\n responses:\n \"200\":\n description: OK\n content:\n application/json:\n schema:\n $ref: \"#/components/schemas/FullVal\"\n \"404\":\n description: Not found\n\n /v1/search/vals:\n get:\n summary: Search for vals across the platform\n tags: [Search]\n parameters:\n - name: query\n in: query\n description: Search query\n required: true\n schema:\n type: string\n minLength: 1\n maxLength: 512\n - $ref: \"#/components/parameters/offset\"\n - $ref: \"#/components/parameters/limit\"\n responses:\n \"200\":\n description: OK\n content:\n application/json:\n schema:\n $ref: \"#/components/schemas/ValList\"\n\n /v1/eval/{expression}:\n get:\n summary: Evaluate a JavaScript or TypeScript expression\n tags: [\"Eval\"]\n description: |\n Evaluates the JavaScript or TypeScript `{expression}` and responds with the returned result. \n\n ### Unauthenticated\n Unauthenticated use will have read-only access to public vals. \n\n ### Authenticated\n Authenticated use will have read access to the authenticated user's private vals and secrets, write access to the authenticated user's vals, and the ability to send the authenticated user emails via `console.email`.\n\n Vals generated via this API will *not* appear in the authenticated user's workspace.\n parameters:\n - $ref: \"#/components/parameters/expression\"\n responses:\n \"200\":\n $ref: \"#/components/responses/ExpressionResult\"\n \"400\":\n description: Bad request or Error thrown executing user code\n \"404\":\n description: Not found\n \"500\":\n description: Internal server error\n\n /v1/eval:\n post:\n summary: Evaluate a JavaScript or TypeScript expression\n tags: [\"Eval\"]\n description: |\n Evaluates the JavaScript or TypeScript `{expression}` and responds with the returned result. \n\n ### Unauthenticated\n Unauthenticated use will have read-only access to public vals. \n\n ### Authenticated\n Authenticated use will have read access to the authenticated user's private vals and secrets, write access to the authenticated user's vals, and the ability to send the authenticated user emails via `console.email`.\n\n Vals generated via this API will *not* appear in the authenticated user's workspace.\n requestBody:\n description: When used as a POST endpoint, the request body\n must contain the code to be run.\n required: true\n content:\n application/json:\n schema:\n type: object\n required: [\"code\"]\n properties:\n code:\n type: string\n args:\n type: array\n items:\n $ref: \"#/components/schemas/JSON\"\n examples:\n \"Add two numbers\":\n value: { \"code\": \"(a, b) => a + b\", \"args\": [1, 42] }\n responses:\n \"200\":\n $ref: \"#/components/responses/ExpressionResult\"\n \"400\":\n description: Bad request or Error thrown executing user code\n \"404\":\n description: Not found\n \"500\":\n description: Internal server error\n\n /v1/run/{username}.{val_name}:\n get:\n deprecated: true\n summary: Run a val as an API\n tags: [\"Run\"]\n description: This endpoint runs the specified user's val and returns the output.\n parameters:\n - $ref: \"#/components/parameters/username\"\n - $ref: \"#/components/parameters/val_name\"\n - in: query\n name: args\n schema:\n type: string\n description: The args query parameter can provide arguments to the given val. The parameter needs to be a JSON-encoded array, in which each item in the array is passed to the val as a function parameter.\n examples:\n name:\n value: '[\"Steve\"]'\n summary: Calling a function with a single string argument\n empty:\n value: \"\"\n responses:\n \"200\":\n $ref: \"#/components/responses/ExpressionResult\"\n \"400\":\n description: Bad request or Error thrown executing user code\n \"404\":\n description: Not found\n \"500\":\n description: Internal server error\n post:\n deprecated: true\n summary: Run a val as an API\n tags: [\"Run\"]\n parameters:\n - $ref: \"#/components/parameters/username\"\n - $ref: \"#/components/parameters/val_name\"\n requestBody:\n required: false\n description: Provide arguments to the given val function by including a post body with your request.\n content:\n application/json:\n schema:\n type: object\n additionalProperties: false\n properties:\n args:\n type: array\n items:\n $ref: \"#/components/schemas/JSON\"\n responses:\n \"200\":\n $ref: \"#/components/responses/ExpressionResult\"\n \"400\":\n description: Bad request or Error thrown executing user code\n \"404\":\n description: Not found\n \"500\":\n description: Internal server error\n\n \"/\":\n servers:\n - url: https://{username}-{val_name}.express.val.run\n description: Val Town API v1\n variables:\n username:\n default: stevekrouse\n val:\n default: expressHTMLExample\n get:\n summary: Run a val as an API (as an Express handler)\n tags: [\"Express\"]\n description: |\n Runs `@{username}.{val_name}` as an Express handler. \n\n `@{username}.{val_name}` must be a function. It is passed the Express [`req`](https://expressjs.com/en/4x/api.html#req) and [`res`](https://expressjs.com/en/4x/api.html#res) objects as its arguments. You can use `req` to pull out request data, and `res` to respond with any valid Express response. Learn more at the [Express docs](https://expressjs.com/en/4x/api.html).\n\n Unlike the other two APIs, the Express API is specified via subdomain and runs at `https://{username}-{val_name}.express.val.run`.\n\n ### Unauthenticated\n Unauthenticated use will only be able to call public vals as Express handlers.\n\n The val will be executed with `{username}`'s permissions (\"API Mode\"), so it will be able to read and write to `{username}`'s public and private vals, secrets, and use `console.email`.\n\n ### Authenticated\n Authenticated use is able to call private vals as Express handlers.\n responses:\n \"200\":\n description: Function executed successfully\n content:\n \"*/*\":\n schema:\n type: string\n description: The result of the executed function, in any media type\n \"400\":\n description: Bad request or Error thrown executing user code\n \"404\":\n description: Not found\n \"500\":\n description: Internal server error\n post:\n summary: Run a val as an API (as an Express handler)\n tags: [\"Express\"]\n description: |\n Runs `@{username}.{val_name}` as an Express handler. \n\n `@{username}.{val_name}` must be a function. It is passed the Express [`req`](https://expressjs.com/en/4x/api.html#req) and [`res`](https://expressjs.com/en/4x/api.html#res) objects as its arguments. You can use `req` to pull out request data, and `res` to respond with any valid Express response. Learn more at the [Express docs](https://expressjs.com/en/4x/api.html).\n\n ### Unauthenticated\n Unauthenticated use will only be able to call public vals as Express handlers.\n\n The val will be executed with `{username}`'s permissions (\"API Mode\"), so it will be able to read and write to `{username}`'s public and private vals, secrets, and use `console.email`.\n\n ### Authenticated\n Authenticated use is able to call private vals as Express handlers.\n requestBody:\n description: |\n The request body will be accessible to the val Express handler under the first argument, commonly called `req`, as `req.body`.\n required: false\n content:\n application/json:\n schema:\n $ref: \"#/components/schemas/JSON\"\n examples:\n name:\n value: '{\"name\": \"Steve\"}'\n summary: JSON object as the request body\n responses:\n \"200\":\n description: Function executed successfully\n content:\n \"*/*\":\n schema:\n type: string\n description: The result of the executed function, in any media type\n \"400\":\n description: Bad request or Error thrown executing user code\n \"404\":\n description: Not found\n \"500\":\n description: Internal server error\n";

telegramSendPhotomain.tsx1 match

@stevekrouse•Updated 1 year ago
3export const telegramSendPhoto = async (botToken: string, options: TelegramSendPhotoOptions) =>
4 fetchJSON(
5 `https://api.telegram.org/bot${botToken}/sendPhoto`,
6 {
7 method: "POST",

telegramValTownAPIREADME.md1 match

@stevekrouse•Updated 1 year ago
1Migrated from folder: Archive/telegramValTownAPI

upload_urlmain.tsx1 match

@stevekrouse•Updated 1 year ago
1// Function to upload data using Wormhole API and return the URL
2async function uploadToFileIo(file) {
3 const formData = new FormData();

modifyImageREADME.md1 match

@stevekrouse•Updated 1 year ago
1Code from https://deno.com/blog/build-image-resizing-api
2
3Useful for compressing an image before sending to chatgpt4v, for example

modifyImageREADME.md1 match

@stevekrouse•Updated 1 year ago
1Code from https://deno.com/blog/build-image-resizing-api
2
3Useful for compressing an image before sending to chatgpt4v, for example

signedFetchmain.tsx1 match

@stevekrouse•Updated 1 year ago
7// Make an authenticated request to another user's val
8// Example usage: https://www.val.town/v/stevekrouse.authRequestEx
9export const runValAPIAuth = async ({ val, args, handle, privateKey, keys }: {
10 val: string;
11 args: any;

code_search_is_easyREADME.md3 matches

@stevekrouse•Updated 1 year ago
11How does this new shiny search engine work? Well, it's quite simple.
12
131. I wrote a [Deno script](https://github.com/pomdtr/val-town-mirror/blob/main/scripts/pull.ts) that fetches all vals from the Val Town API.
142. I pushed the data to a [Github Repository](https://github.com/pomdtr/val-town-mirror)
153. I added a [Github Action](https://github.com/pomdtr/val-town-mirror/blob/main/.github/workflows/sync.yaml) that runs the script every hour to refresh the data.
164. I created a simple frontend on top of the Github Search API that allows you to search the data. It's [hosted on Val Town](https://www.val.town/v/pomdtr/val_town_search) (obviously).
17
18That was it. I didn't have to build a complex search engine, I just used the tools that were available to me.
19
20Is this a scalable solution for Val Town? Probably not.\
21Am I abusing the Github API? Maybe.\
22Does it work better than the current search feature of Val Town? Absolutely!
23

valToGHmain.tsx2 matches

@nbbaier•Updated 1 year ago
1import { API_URL } from "https://esm.town/v/std/API_URL?v=5";
2import { fetchJSON } from "https://esm.town/v/stevekrouse/fetchJSON?v=42";
3import { Octokit } from "npm:@octokit/rest";
127
128 try {
129 const { code } = await fetchJSON(`${API_URL}/v1/alias/${vtUser}/${valName}`, {
130 headers: { "Authorization": `Bearer ${Deno.env.get("valtown")}` },
131 });

PassphraseAPI2 file matches

@wolf•Updated 2 days ago

openapi2 file matches

@stevekrouse•Updated 4 days ago
artivilla
founder @outapint.io vibe coding on val.town. dm me to build custom vals: https://artivilla.com
fiberplane
Purveyors of Hono tooling, API Playground enthusiasts, and creators of 🪿 HONC 🪿 (https://honc.dev)