send-transcripts
Val Town is a collaborative website to build and scale JavaScript apps.
Deploy APIs, crons, & store data – all from the browser, and deployed in milliseconds.
Viewing readonly version of main branch: v4View latest version
A simple API endpoint that receives text and saves it to a SQLite database.
- Save text entries to a SQLite database
- Retrieve all text entries
- Retrieve specific text entries by ID
- Automatic timestamps for entries
- Input validation and error handling
Save a new text entry.
Request Body:
{ "text": "Your text content here" }
Response:
{ "success": true, "id": 1, "message": "Text saved successfully" }
Retrieve all text entries (ordered by most recent first).
Response:
{ "success": true, "data": [ { "id": 1, "text": "Your text content", "created_at": "2024-01-01 12:00:00" } ] }
Retrieve a specific text entry by ID.
Response:
{ "success": true, "data": { "id": 1, "text": "Your text content", "created_at": "2024-01-01 12:00:00" } }
The API uses a SQLite table with the following structure:
CREATE TABLE text_entries ( id INTEGER PRIMARY KEY AUTOINCREMENT, text TEXT NOT NULL, created_at DATETIME DEFAULT CURRENT_TIMESTAMP );
curl -X POST https://your-val-url/api/text \ -H "Content-Type: application/json" \ -d '{"text": "Hello, world!"}'
curl https://your-val-url/api/text
curl https://your-val-url/api/text/1
The API returns appropriate HTTP status codes:
- 200: Success
- 400: Bad request (missing or invalid text)
- 404: Text entry not found
- 500: Server error
All error responses include an error
field with a descriptive message.