Open source · MIT · Node.js 18+
Akamai NetStorage, typed.
A Node.js and TypeScript client and CLI for the Akamai NetStorage API (the NetStorage HTTP API). Upload and download files or buffers, browse and manage directories, with promises or callbacks and a type for every response.
import Netstorage from "ts-netstorageapi-akamai";
const ns = new Netstorage({
hostname: "example-nsu.akamaihd.net",
keyName: "upload-user",
key: process.env.NETSTORAGE_KEY!,
cpCode: "123456",
ssl: true,
});
await ns.uploadAsync("./build/app.js", "/123456/static/");
const { stat } = await ns.statAsync("/123456/static/app.js");
console.log(stat.file[0].size, stat.file[0].md5);const Netstorage = require("ts-netstorageapi-akamai").default;
const ns = new Netstorage({ hostname, keyName, key, cpCode: "123456", ssl: true });
ns.upload("./build/app.js", "/123456/static/", (err, res, body) => {
if (err) throw err;
console.log(res?.statusCode, body); // 200 { message: 'Request Processed.' }
});export NETSTORAGE_HOST=example-nsu.akamaihd.net NETSTORAGE_KEYNAME=upload-user NETSTORAGE_KEY=... NETSTORAGE_CPCODE=123456
npx akamai-netstorage upload ./build/app.js static/
npx akamai-netstorage stat static/app.jsWhat happens on every call
Each method builds the request, signs it the way NetStorage expects and turns the XML reply into a typed object.
Why this package
Akamai's own Node.js client, netstorageapi, has not had a release since March 2018. This package keeps its method names and callback signatures, so switching is usually a one-line change, and adds what modern projects need.
netstorageapi 1.1.5 (Akamai) | ts-netstorageapi-akamai 1.1.1 | |
|---|---|---|
| TypeScript types | None | Config, every method and every response |
async/await | Callbacks only | Every method also has a promise (…Async) form |
| Upload or download from memory | Files only | uploadBuffer, downloadBuffer |
| If a local file can't be read during an upload | Reports the error, then still sends an empty upload, which can overwrite the file on NetStorage | Reports the error once and sends nothing |
| If the connection drops mid-response | The callback is never called | Reports an ECONNRESET error |
npm audit on a fresh install (Oct 2026) | 2 moderate (xml2js prototype pollution) | 0 |
| Install size | 12 packages, about 1,200 files | 8 packages, about 140 files |
| Command line tool | No | akamai-netstorage |
| Latest release | March 2018 | Maintained, tested on Node 18, 20, 22 and 24 in CI |
Both send the same signed requests (HMAC-SHA256, version 5) and return the same parsed responses, so switching does not change what NetStorage sees. Migrate from netstorageapi →
Everything you need
Types for everything
Config, options and every response are typed, with editor documentation on every method.
Promises or callbacks
Each method has an Async twin. Keep callbacks where you have them.
Buffers in and out
Upload generated content and read files into memory without temporary files.
A command line tool
akamai-netstorage for scripts and CI, with JSON output and clear exit codes.
Safe failure handling
Failed uploads send nothing, and dropped connections report an error instead of hanging.
Small and audited
Two runtime dependencies, a 22 kB package and a clean npm audit.
Fifteen operations
The 13 NetStorage actions the client supports, as 15 methods with a page each.
Transfer
upload PUT
Upload a local file to Akamai NetStorage.
uploadBuffer PUT
Upload a Buffer to Akamai NetStorage, for content that never touches the disk.
download GET
Download a file from NetStorage to the local disk.
downloadBuffer GET
Download a file into memory.
Browse
dir GET
List the entries of one directory.
list GET
List files recursively, with a marker to resume long listings.
du GET
Show the number of files and bytes used under a directory.
stat GET
Get details of a file or directory.
Manage
mkdir POST
Create a directory.
rmdir POST
Remove an empty directory.
rename POST
Rename or move a file.
symlink POST
Create a symlink that points to an existing file.
mtime POST
Set the modification time of a file.
delete POST
Delete a file or symlink.
quickDelete POST
Delete a directory and everything in it.
Questions people ask
How do I upload a file to Akamai NetStorage from Node.js?
Create a client with your NetStorage hostname, key name and key, then call uploadAsync with the local path and the NetStorage path. A destination ending in / keeps the local file name.
await ns.uploadAsync("./dist/app.js", "/123456/static/");Is there a TypeScript client for Akamai NetStorage?
Yes. ts-netstorageapi-akamai ships types for the configuration, every method and every response, and each method has a promise form and a callback form.
npm install ts-netstorageapi-akamaiHow do I migrate from netstorageapi?
The configuration, method names, arguments and callbacks match Akamai's netstorageapi, so usually only the import changes. The one renamed method is quick_delete, which is quickDelete here.
const Netstorage = require("ts-netstorageapi-akamai").default;How do I sign NetStorage API requests?
The client signs every request for you with HMAC-SHA256 (version 5) in the X-Akamai-ACS-Auth-Data and X-Akamai-ACS-Auth-Sign headers. Keep your clock within one minute of Akamai's time, or NetStorage answers 403.
const ns = new Netstorage({ hostname, keyName, key, cpCode: "123456", ssl: true });How do I upload a buffer to NetStorage without writing a temp file?
Use uploadBufferAsync with the Buffer, a file name and the NetStorage path; the content never touches the disk.
await ns.uploadBufferAsync(Buffer.from(JSON.stringify(data)), "data.json", "/123456/api/");Is there a command line tool for Akamai NetStorage?
Yes. The package installs akamai-netstorage, which reads the upload key from NETSTORAGE_KEY (never from a flag), takes the host and key name from the environment or from --host and --key-name, and supports ls, list, du, stat, upload, download, cat, mkdir, rmdir, rm, rename, symlink, mtime and quick-delete.
npx akamai-netstorage upload ./dist/app.js static/Why does Akamai NetStorage return 403?
Usually the request signature failed: check that your clock is within one minute of Akamai's, that hostname, keyName and key are right, and that a new upload account has finished propagating, which can take up to 120 minutes.
ns.stat("/123456/file.txt", (err, res) => console.log(res?.statusCode));
Built by Boffin Coders
Boffin Coders designs and builds websites, web applications and mobile apps for businesses and agencies, and maintains this package as open source. Need Akamai NetStorage uploads, a media pipeline or a Node.js backend built for you?
Upgrading from 1.0.x? Version 1.1.0 is a drop-in upgrade: your code keeps working without changes. See what changed →