@tonyartz4/apisql
v0.1.3
Published
WASM bindings for ApiSQL - A query language for JSON APIs
Readme

ApiSQL WASM

The WebAssembly bindings for ApiSQL, allowing you to run ApiSQL queries directly in Node.js or the browser (via bundlers).
Installation
npm install @tonyartz4/apisqlUsage
Node.js (CommonJS)
const { run } = require("@tonyartz4/apisql");
async function main() {
const query = `
REQUEST GetPokemon
GET https://pokeapi.co/api/v2/pokemon?limit=5
RESPONSE
FROM body.results
SELECT { name, url }
`;
try {
// The run function returns the result directly as a JavaScript object
const result = await run(query);
console.log(result);
} catch (e) {
console.error("Query failed:", e);
}
}
main();ES Modules / Bundlers (Webpack, Vite, etc.)
import { run } from "@tonyartz4/apisql";
const query = `
REQUEST GetPokemon
GET https://pokeapi.co/api/v2/pokemon?limit=5
RESPONSE
FROM body.results
SELECT { name, url }
`;
run(query)
.then((result) => console.log(result))
.catch((err) => console.error(err));API Reference
run(source: string): Promise<any>
Executes an ApiSQL query string and returns the result.
source: The ApiSQL query string.- Returns: A
Promisethat resolves to the query result (as a JavaScript object) or rejects with an error.
Building from Source
To build the WASM package locally:
- Install
wasm-pack: https://rustwasm.github.io/wasm-pack/installer/ - Run the build script:
cd crates/wasm
npm run buildLicense
MIT
