Azion Lib
Install Azion Lib packages to call Object Storage, SQL Database, and other Azion services from JavaScript or TypeScript code.
A client library is a package of functions that stands in for the HTTP API of a platform. Your code imports a function, passes it plain values, and reads the object it returns. The library builds the request, attaches your credentials, and parses the answer, so your code writes no HTTP calls of its own.
Azion Lib is that library for the Azion Platform: a set of npm packages for JavaScript and TypeScript. Six of its modules call an Azion service, such as Object Storage or SQL Database. Seven more, such as JWT, Cookies, and WASM Image Processor, run entirely inside your code and make no API call. Use Azion Lib to manage buckets and objects from a script, run SQL statements on a database, purge cached URLs, sign and verify JSON Web Tokens (JWTs), or set cookies on a response.
Get started See how it worksCode model
Each module ships in an npm package, and your code imports only the functions it calls. This Node.js script creates an Object Storage bucket with the @aziontech/storage package:
Saved as create-bucket.mjs and run with node create-bucket.mjs, the script prints the name of the bucket it created:
- The
importline loads one function from the module’s package. No client object is needed for a direct call. createBucketreads your personal token from theAZION_TOKENenvironment variable and sends the request to Azion API v4.- The function takes one object argument, with the bucket
nameand itsworkloads_accesslevel. - The call returns a response envelope,
{ data, error }, instead of throwing.dataholds the bucket on success, anderrorholdsmessageandoperationon failure.
If you know async and await in JavaScript, you know how to call the Storage functions. To run this script against your account, follow the Azion Lib quickstart.
Call path
Installing a package gives your code no access to your account. The token comes with each call, from a client or from the environment.
- Your code calls a function of an API module directly, or through a client that
createClientreturns. - The function takes your personal token from the
tokenfield of its client, or from theAZION_TOKENenvironment variable on a direct call. - The function sends the request to the Azion API. Storage, SQL, and Purge call Azion API v4, and Applications and Domains call Azion API v3. AI calls a chat service of its own.
- The API acts on the resources of your account, such as a bucket or a database, and the function hands the answer back to your code.
Only the six API modules read AZION_TOKEN, and AZION_DEBUG set to true turns on their debug logs. The seven other modules read neither variable. For the token settings, the response envelopes, and the API version of each module, refer to How Azion Lib works.
Packages and boundaries
Azion Lib ships in two kinds of npm package, and a project often installs both. This table gives the package that carries each module:
| Module | Package |
|---|---|
| Storage | @aziontech/storage |
| SQL | @aziontech/sql |
| JWT | @aziontech/jwt |
| Utils | @aziontech/utils |
| Config | @aziontech/config |
| Types | @aziontech/types |
| unenv preset | @aziontech/unenv-preset |
| Client | azion |
| Applications | azion |
| Domains | azion |
| Purge | azion |
| AI client | azion |
| Cookies | azion |
| WASM Image Processor | azion |
The azion package receives bug fixes only, and its maintenance ends in December 2026. The seven modules in the @aziontech scope each have a package of their own. The other seven have no scoped package, so azion is the only package that carries them. Each module page names its package and its install command.
- Where the functions run: in Node.js, the six API modules call their services over REST, and Cookies, JWT, Config, and the Utils
parseRequestfunction run too. The UtilsmountSPAandmountMPAfunctions and thenode:fspolyfill of the unenv preset do not run in Node.js. They run inside a function, including a function served locally with azion dev, and handlers typed with Types run there too. Storage calls theAzion.Storageinterface of Azion Runtime instead of the REST API when that interface is present. - What it does not do: Azion Lib has no KV Store module. A function reads and writes KV Store through
Azion.KV, a global of Azion Runtime. For more information, refer to KV Store API. WASM Image Processor resizes an image inside your code with WebAssembly. It is separate from Image Processor, which builds derived images on an application. - Interfaces: the API modules call the Azion API for you. To call it directly, refer to Azion API. To manage resources from a terminal, use the Azion CLI, and to manage them as code, use the Azion Terraform Provider.
- Help: Troubleshoot Azion Lib lists errors a call can return and how to fix them, and the Glossary defines the terms of Azion Lib.