Library
List, read, add, replace and delete a project's library modules — shared code every function of the same language can import — with the REST API.
Library modules are shared helpers that several functions reuse. Every function of the same language gets the whole library. Guide: Library.
GET /api/projects/:id/library
GET /api/projects/:id/library/:name
PUT /api/projects/:id/library/:name
DELETE /api/projects/:id/library/:name#List and read
GET /library returns every module of the current draft, with its language, description and code. GET /library/:name returns one.
#Add or replace a module
PUT /library/:name creates the module or replaces its code:
| Field | Type | Default | Description |
|---|---|---|---|
code | string | — | The complete source |
language | string? | the module's, or the project's | javascript or python |
description | string? | unchanged | Up to 500 characters |
curl -X PUT https://wispfn.com/api/projects/$PROJECT/library/pricing \
-H "Authorization: Bearer $WISP_API_KEY" -H "content-type: application/json" \
-d '{"code":"export const vat = (cents) => Math.round(cents * 0.2);","description":"VAT helpers"}'JavaScript functions import it with import { vat } from './lib/pricing.js'; Python with from lib.pricing import vat.
#Delete a module
DELETE /library/:name. Functions that still import it fail to build, so remove the imports first.
Every change creates a new draft version and rebuilds the functions of that language. Scope: functions:write (reading: functions:read).