{"id":15887889,"url":"https://github.com/dabigblob/libsql-web-api-http-stateless-client","last_synced_at":"2026-04-12T11:35:46.995Z","repository":{"id":205076102,"uuid":"713359130","full_name":"DaBigBlob/libsql-web-api-http-stateless-client","owner":"DaBigBlob","description":"extremely thin and effecient libSQL stateless http driver for TypeScript and JavaScript running on Web API","archived":false,"fork":false,"pushed_at":"2023-11-05T02:37:15.000Z","size":54,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-02-08T07:23:50.807Z","etag":null,"topics":["cloudflare-pages","cloudflare-workers","database","http","https","lambda-functions","libsql","netlify","serverless","sqlite","versel","webapi"],"latest_commit_sha":null,"homepage":"https://www.npmjs.com/package/libsql-web-api-http-stateless-client","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/DaBigBlob.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2023-11-02T11:09:47.000Z","updated_at":"2023-11-02T14:25:58.000Z","dependencies_parsed_at":null,"dependency_job_id":"cbe9a3bf-cccb-48b8-a5a3-3c9a1ca5b738","html_url":"https://github.com/DaBigBlob/libsql-web-api-http-stateless-client","commit_stats":null,"previous_names":["dabigblob/libsql-web-api-http-stateless-client"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/DaBigBlob%2Flibsql-web-api-http-stateless-client","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/DaBigBlob%2Flibsql-web-api-http-stateless-client/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/DaBigBlob%2Flibsql-web-api-http-stateless-client/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/DaBigBlob%2Flibsql-web-api-http-stateless-client/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/DaBigBlob","download_url":"https://codeload.github.com/DaBigBlob/libsql-web-api-http-stateless-client/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":246852969,"owners_count":20844499,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["cloudflare-pages","cloudflare-workers","database","http","https","lambda-functions","libsql","netlify","serverless","sqlite","versel","webapi"],"created_at":"2024-10-06T06:05:34.349Z","updated_at":"2026-04-12T11:35:46.903Z","avatar_url":"https://github.com/DaBigBlob.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# **__THIS PROJECT/PACKAGE HAS BEEN DEPRECATED__**\n**This project has been depricated in favor of:**\n- [**libsql-stateless** (github)](https://github.com/DaBigBlob/libsql-stateless)\n- [**libsql-stateless** (npmjs)](https://www.npmjs.com/package/libsql-stateless)\n\n**Please don't keep using this project/package.**\n\n# libsql-web-api-http-stateless-client\n\n\u003e libSQL http driver for TypeScript and JavaScript running with Web API.\n\n- This is built for edge-functions that quickly spin up, do stuff, and die.\n- No bullshit classes and nonsense computation to figure out protocol type and shit.\n- Separate and small functions so you're not importing stuff you're not using.\n- Is very small package (85 lines of code) and uses very little memory.\n- Runs extremely fast on Cloudflare Workers, Vercel Edge Funcrions, etc.\n- Works with any libsql server. (eg: Turso, self-hosted, etc.)\n\n## Installation\n\n```bash\n$ npm i libsql-web-api-http-stateless-client\n# OR\n$ bun add libsql-web-api-http-stateless-client\n```\n\n## Usage\n\n```ts\nimport {execute, executeBatch, checkServerCompat} from 'libsql-web-api-http-stateless-client'; //mjs\n//or\n{execute, executeBatch, checkServerCompat} = require('libsql-web-api-http-stateless-client'); //for cjs\n\n//remember to use the following in async functions only (because await)\nconst res1 = await execute(\n    {\n        url: \"https://the-pink-mad-man.turso.io\", //DB url (http:// or https:// only)\n        authToken: \"skdfkvskdjvfcsjdvc.bd2y309rehwfg\" //auth token\n    },\n    \"SELECT * FROM chicken_yum_yum;\"\n);\n\nconst res2 = await execute(\n    {\n        url: \"https://the-pink-mad-man.turso.io\", //DB url (http:// or https:// only)\n        authToken: \"skdfkvskdjvfcsjdvc.bd2y309rehwfg\"\n    },\n    {\n        q: \"SELECT * FROM chicken_yum_yum WHERE owner = ?\",\n        params: [\"the_pink_man\"]\n    }\n);\n\n//execute return either\n{\n    isOk: true,\n    val: {\n        results: {\n            columns: Array\u003cstring\u003e, //the names of your columns\n            rows: Array\u003cArray\u003c_Value\u003e\u003e, //values\n        }\n    }\n}\n//or\n{\n    isOk: false,\n    err: string //reason for failure\n}\n\nconst res3 = await executeBatch(\n    {\n        url: \"https://the-pink-mad-man.turso.io\", //DB url (http:// or https:// only)\n        authToken: \"skdfkvskdjvfcsjdvc.bd2y309rehwfg\"\n    },\n    [\n        {\n            q: \"SELECT * FROM chicken_yum_yum WHERE owner = ?\",\n            params: [\"the_pink_man\"]\n        },\n        {\n            q: \"SELECT * FROM chicken_yum_yum WHERE dead = ?\",\n            params: [\"yes\"]\n        },\n        \"SELECT * FROM chicken_yum_yum;\",\n        //keep on going\n    ]\n);\n\n//executeBatch return either\n{\n    isOk: true,\n    val: Array\u003c{ //an array of results cause you made an array or query\n        results: {\n            columns: Array\u003cstring\u003e,\n            rows: Array\u003cArray\u003c_Value\u003e\u003e,\n        }\n    }\u003e\n}\n//or\n{\n    isOk: false,\n    err: string //reason for failure\n}\n```\n\nBecause `isOk` boolean field is always gaurenteed, you can you something like:\n\n```ts\nif (res.isOk) {\n    //do something with res.val\n} else {\n    //do somthing with res.err\n}\n```\n\n### Other Helper Functions\n\n```ts\nimport {extractBatchQueryResultRows, extractQueryResultRows, checkServerCompat} from 'libsql-web-api-http-stateless-client'; //mjs\n//or\n{extractBatchQueryResultRows, extractQueryResultRows, checkServerCompat} = require('libsql-web-api-http-stateless-client'); //for cjs\n\n//you might've noticed that res.val is often pretty cluttered with redundant stuff.\n//this is because of libsql's http api v0's schema, and executeBatch and execute doing exactly as much as fetching the data.\n//this is on purpose. it is to give you the flexibility of being able to choose exactly what post-processing is done to your data.\n//for this purpose, we also provide helper functions to clean thre res.val's up if you want\nconst res1 = await executeBatch(\n    //stuff\n);\nif (res1.isOk) {\n    const abc = extractBatchQueryResultRows(res);\n    //returns:\n    Array\u003cArray\u003cArray\u003cValues\u003e\u003e\u003e\n  //  ^     ^   ^^^^^^^^^^^^\n  //  |     |      just a row\n  //  |  array or rows (for 1 query)\n  // array of that (multiple query)\n}\n\nconst res2 = await execute(\n    //stuff\n);\nif (res2.isOk) {\n    const abc = extractQueryResultRows(res);\n    //returns:\n    Array\u003cArray\u003cValues\u003e\u003e\n  //  ^   ^^^^^^^^^^^^\n  //  |      just a row\n  //array or rows (for 1 query)\n}\n```\n\n### Checking Server Compatiblity\n\n```ts\nimport {checkServerCompat} from 'libsql-web-api-http-stateless-client'; //mjs\n//or\n{checkServerCompat} = require('libsql-web-api-http-stateless-client'); //for cjs\n\n//remember to use the following in async functions only (because await)\nconst res = await checkServerCompat(\"https://the-pink-mad-man.turso.io\");//DB url (http:// or https:// only)\n//returns:\n{\n    isOk: true\n}\n//or\n{\n    isOk: false\n}\n//so again you can just use:\nif (res.isOk) {\n    //do something\n} else {\n    //do something\n}\n```\n\n### Other Goodies\n\n```ts\nimport {sqlite_text, sqlite_integer, sqlite_real, sqlite_blob, sqlite_null, sqlite_value, sqlite_query} from 'libsql-web-api-http-stateless-client'; //mjs\n//or\n{sqlite_text, sqlite_integer, sqlite_real, sqlite_blob, sqlite_null, sqlite_value, sqlite_query} = require('libsql-web-api-http-stateless-client'); //for cjs\n\n// sqlite_text, sqlite_integer, sqlite_real, sqlite_blob and sqlite_null are the 5 datatypes supported by sqlite\n// sqlite_value is the type union of the above datatypes\n// sqlite_query is the query (the sql stuff you write) type for this library\n\n//thsese are implemented as:\nexport type sqlite_value = sqlite_text|sqlite_integer|sqlite_integer|sqlite_real|sqlite_blob|sqlite_null;\nexport type sqlite_text = string; //a UTF-8 encoded string\nexport type sqlite_integer = number; //a 64-bit signed integer\nexport type sqlite_real = number; //a 64-bits floating number\nexport type sqlite_blob = string; //some binary data, encoded in base64\nexport type sqlite_null = null; //the null value\n\nexport type sqlite_query = string | { q: string, params: Record\u003cstring, sqlite_value\u003e | Array\u003csqlite_value\u003e };\n```","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdabigblob%2Flibsql-web-api-http-stateless-client","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdabigblob%2Flibsql-web-api-http-stateless-client","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdabigblob%2Flibsql-web-api-http-stateless-client/lists"}