{"id":15953,"library":"akamai-http-api","title":"Akamai NetStorage HTTP API for Node.js","description":"This package provides an unofficial Node.js client for interacting with the Akamai NetStorage HTTP API. It is currently at version `0.6.1` and primarily focuses on maintenance, addressing dependency updates and security vulnerabilities rather than new feature development. The library differentiates itself by providing a seemingly more robust and actively maintained alternative to Akamai's official Node.js NetStorageKit, which the README notes as having \"suspicious quality.\" It offers both stream-based 'Advanced' APIs for uploading and downloading files, and 'Basic' APIs for common file and directory operations like `du`, `dir`, `stat`, `delete`, `mkdir`, `rmdir`, `rename`, and `symlink`. It includes helpers like `fileExists` and provides explicit handling for HTTP response codes in error objects.","status":"maintenance","version":"0.6.1","language":"javascript","source_language":"en","source_url":"https://github.com/kkamkou/node-akamai-http-api","tags":["javascript","akamai","api","http","netstorage"],"install":[{"cmd":"npm install akamai-http-api","lang":"bash","label":"npm"},{"cmd":"yarn add akamai-http-api","lang":"bash","label":"yarn"},{"cmd":"pnpm add akamai-http-api","lang":"bash","label":"pnpm"}],"dependencies":[{"reason":"Used for making HTTP requests to Akamai NetStorage. It is configurable via the `request` option in `setConfig`. Note: The 'request' library itself is deprecated and no longer maintained.","package":"request","optional":false},{"reason":"Utility belt library, used internally. Has had multiple security updates addressed in recent patches.","package":"lodash","optional":false}],"imports":[{"note":"The library exports a single object containing all API methods. While the package documentation primarily uses CommonJS `require`, it can be imported as a default export in ESM environments.","wrong":"const akamai = require('akamai-http-api');","symbol":"akamai","correct":"import akamai from 'akamai-http-api';"},{"note":"Configuration is applied globally via a method on the imported `akamai` object and must be called before performing any API operations.","symbol":"setConfig","correct":"akamai.setConfig({ /* config */ });"},{"note":"This is one of the 'Advanced' API methods for stream-based file uploads. Other methods like `download`, `dir`, `delete` are also accessed directly from the `akamai` object.","symbol":"upload","correct":"akamai.upload(stream, '/path/to/remote', callback);"}],"quickstart":{"code":"const akamai = require('akamai-http-api');\nconst fs = require('fs');\nconst path = require('path');\n\n// Ensure these environment variables are set or provide direct values\nakamai.setConfig({\n  keyName: process.env.AKAMAI_KEY_NAME ?? 'your-akamai-keyname',\n  key: process.env.AKAMAI_KEY ?? 'your-akamai-secret-key-long-string',\n  host: process.env.AKAMAI_HOST ?? 'your-netstorage-hostname.akamaihd.net',\n  ssl: true, // Recommended for production\n  verbose: false,\n  request: {\n    timeout: 30000 // 30 seconds timeout (default is 20s)\n  }\n});\n\nconst localTempDir = './temp_akamai_uploads';\nif (!fs.existsSync(localTempDir)) {\n  fs.mkdirSync(localTempDir);\n}\nconst localFilePath = path.join(localTempDir, 'example-upload.txt');\nconst remoteFilePath = '/12345/MyFolder/example-upload.txt'; // Replace 12345 with your CP code\n\n// Create a dummy file for upload\nfs.writeFileSync(localFilePath, 'Hello Akamai NetStorage from node-akamai-http-api!');\nconsole.log(`Created local file: ${localFilePath}`);\n\nconst uploadStream = fs.createReadStream(localFilePath);\n\nakamai.upload(uploadStream, remoteFilePath, function (err, data) {\n  if (err) {\n    console.error('Akamai upload failed:', err.message || err);\n    // Clean up even on error\n    fs.unlinkSync(localFilePath);\n    fs.rmdirSync(localTempDir);\n    return;\n  }\n  console.log('Akamai upload successful:', data);\n\n  // Clean up the dummy file and directory\n  fs.unlinkSync(localFilePath);\n  fs.rmdirSync(localTempDir);\n  console.log(`Cleaned up local file: ${localFilePath}`);\n});","lang":"javascript","description":"This quickstart demonstrates how to initialize the `akamai-http-api` client using configuration from environment variables and then perform a basic file upload to Akamai NetStorage via a readable stream. It includes local file creation and cleanup."},"warnings":[{"fix":"Be aware of this underlying dependency risk. Monitor 'akamai-http-api' for potential migrations to a modern HTTP client, or consider alternatives if 'request' becomes a critical blocker for your security or compliance needs.","message":"The core HTTP client library, 'request', which `akamai-http-api` depends on, is officially deprecated and no longer maintained. While this package updates its dependencies, continued reliance on 'request' could lead to future compatibility issues or unpatched security vulnerabilities in the underlying HTTP layer.","severity":"breaking","affected_versions":"All versions"},{"fix":"Upgrade to `akamai-http-api@0.6.1` or newer. Regularly run `npm audit` to identify and mitigate any new security advisories.","message":"Multiple security vulnerabilities in the 'lodash' dependency have been patched. To ensure your application is secure, it is critical to use `akamai-http-api` version `0.6.1` or higher.","severity":"gotcha","affected_versions":"<0.6.1"},{"fix":"Implement client-side rate limiting, exponential back-off, or queueing mechanisms if your application performs a high volume of NetStorage operations.","message":"Akamai NetStorage has a soft rate limit of approximately 15 operations per second. Exceeding this limit can result in 500 series HTTP errors being returned by NetStorage, which are not automatically retried or handled by this client.","severity":"gotcha","affected_versions":"All versions"},{"fix":"Double-check the `host` value against your Akamai NetStorage configuration. Utilize the `request.timeout` option within `setConfig` to adjust the timeout duration if needed.","message":"Providing an incorrect `host` value in `setConfig` (e.g., a typo) will not immediately throw an error but will cause HTTP requests to hang until the connection timeout is reached (default 20 seconds).","severity":"gotcha","affected_versions":"All versions"},{"fix":"Always configure HTTP request timeouts using `akamai.setConfig({ request: { timeout: milliseconds } })`.","message":"The configuration for HTTP request timeouts was introduced and later standardized under a nested `request` object. Direct top-level `timeout` options might be ignored or behave inconsistently in newer versions.","severity":"deprecated","affected_versions":"<0.4.0"}],"env_vars":null,"last_verified":"2026-04-21T00:00:00.000Z","next_check":"2026-07-20T00:00:00.000Z","problems":[{"fix":"Implement checks (e.g., using `fileExists` or `stat`) before creating resources, or specifically handle the `err.code === 409` condition in your error callback.","cause":"Attempting to create a directory (`mkdir`) or symlink (`symlink`) where a file or directory with the same name already exists at the target path.","error":"Error: Akamai API Error. Status: 409 Conflict"},{"fix":"Verify your network stability, ensure the `host` is correctly configured, and check Akamai's rate limit guidance. Consider implementing retry logic with back-off.","cause":"A network connection reset occurred. This can happen due to an unstable network, Akamai rate limiting abruptly closing the connection, or an incorrect host configuration causing the server to reject the connection.","error":"Error: read ECONNRESET"},{"fix":"Check network connectivity and the correctness of the configured `host`. For large files, consider increasing the `request.timeout` value in `setConfig`.","cause":"The HTTP request to Akamai NetStorage exceeded the configured `request.timeout` value before receiving a response. This could be due to network latency, large file transfers, or an unreachable host.","error":"Error: ETIMEDOUT (or similar timeout error)"}],"ecosystem":"npm"}