Registry / azure / onedrive-api

onedrive-api

JSON →
library1.1.1jsnpmunverified

This package, `onedrive-api`, provides a functional programming-oriented interface for interacting with the Microsoft OneDrive API. It is designed for Node.js environments and facilitates operations such as file and folder management, link creation, and metadata retrieval. The current stable version is 1.1.1, which was last published in June 2019. Due to its age, it should be considered a legacy library, and its compatibility with the latest OneDrive API changes may be limited. The library focuses solely on API communication, advising users to handle authentication separately, with `simple-oauth2` being a suggested tool. It features a modular API for various item operations like `createFolder`, `uploadSimple`, and `listChildren`.

npm install onedrive-api
INSTALL
IMPORT
SIG · ONEDRIVE-API
O
onedrive-api
azurejavascriptv1.1.1
Install
Import
Disk
Pass rate
0/ 6
Env Coverage0 / 6
glibc
1822
musl
1822
Install & Compatibility
Where this runs
tested against v? · npm install
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
node 18226 runs
build_error
glibc
node 18226 runs
build_error
Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

oneDriveAPI
import oneDriveAPI from 'onedrive-api';
import { oneDriveAPI } from 'onedrive-api';
The library exports a default object containing all API methods, typically used in TypeScript or ESM.
oneDriveAPI
const oneDriveAPI = require('onedrive-api');
CommonJS require style for Node.js environments.
items.listChildren
oneDriveAPI.items.listChildren({...});
import { listChildren } from 'onedrive-api';
Individual API methods are nested under the `items` property of the main export, not top-level named exports.

Demonstrates how to import the library and use the `listChildren` method to retrieve and log the names and types of items in the user's OneDrive root directory.

import oneDriveAPI from 'onedrive-api'; // This library does not handle authentication. // You need to obtain an access token yourself, e.g., using simple-oauth2. const accessToken: string = process.env.ONEDRIVE_ACCESS_TOKEN ?? 'YOUR_ONEDRIVE_ACCESS_TOKEN'; if (!accessToken || accessToken === 'YOUR_ONEDRIVE_ACCESS_TOKEN') { console.error('Please set the ONEDRIVE_ACCESS_TOKEN environment variable or replace the placeholder.'); process.exit(1); } async function listRootChildren() { try { console.log('Attempting to list children of the root directory...'); const children = await oneDriveAPI.items.listChildren({ accessToken: accessToken, itemId: 'root', drive: 'me' }); console.log('Children of root directory:'); children.value.forEach((item: any) => { console.log(`- ${item.name} (ID: ${item.id}, Type: ${item.folder ? 'Folder' : 'File'})`); }); // Uncomment for full response body: // console.log(JSON.stringify(children, null, 2)); } catch (error) { console.error('Failed to list children:', error); if (error && typeof error === 'object' && 'response' in error) { console.error('API Error Response:', error.response.body); } } } listRootChildren();
Debug
Known issues
breakingThis package is currently abandoned and has not received updates since June 2019. It relies on outdated dependencies (e.g., `got` v9) and may not be compatible with the latest OneDrive API changes or Node.js versions.
fix
Consider using a more recently maintained OneDrive API client library or interacting directly with the OneDrive REST API.
affects: >=1.1.1
gotchaThe `onedrive-api` library explicitly does not handle authentication. You must implement your own OAuth2 flow to obtain and manage access tokens (e.g., refreshing expired tokens) before making any API calls.
fix
Integrate a separate OAuth2 client library (such as `simple-oauth2` as suggested by the README) to manage the authentication process and provide valid `accessToken` values to `onedrive-api` methods.
affects: >=1.0.0
gotchaThe OneDrive API itself has undergone significant changes since 2019. This library might be using deprecated endpoints or data structures, potentially leading to unexpected errors or missing functionality for newer OneDrive features.
fix
Thoroughly test all API interactions and consult the official Microsoft Graph API documentation for OneDrive to ensure compatibility. Be prepared to implement workarounds or directly call the API if needed.
affects: >=1.0.0
Errors
Common errors & fixes
Error: Access token invalid or expired
The provided `accessToken` is no longer valid, has expired, or was never valid.
fix
Ensure your OAuth2 flow properly refreshes access tokens before each API request and that the token has the necessary scopes for the operation.
Error: Request failed with status code 404 (Not Found) - { "error": { "code": "itemNotFound", "message": "..." } }
The `itemId` or `itemPath` specified in the request does not exist or is inaccessible to the authenticated user.
fix
Verify the correctness of the `itemId` or `itemPath`. Ensure the user associated with the `accessToken` has permissions to access the specified resource.
Error: Request failed with status code 400 (Bad Request) - { "error": { "code": "nameAlreadyExists", "message": "..." } }
An operation like `createFolder` or `uploadSimple` was attempted with a name that already exists in the target location, and no conflict behavior was specified.
fix
When creating or uploading, specify a unique name or implement conflict resolution (e.g., by adding a timestamp to the name or handling `nameAlreadyExists` errors).
Upgrade
Version history
1.1.1latest on npm
Audit
Dependencies
gotrequiredRuntime dependency for making HTTP requests to the OneDrive API.
pathrequiredRuntime dependency for path manipulation.
simple-oauth2optionalRecommended for handling OAuth2 authentication flows with OneDrive, but not a direct runtime dependency.
Agent activity
27 hits · last 30 days
node
24
OpenAI (training)
1
Resources
onedrive-api — npm install onedrive-api · libregistry