How to Access Personal OneDrive Files via API | Developer Guide
Question details
The user needs a programmatic way to interact with a personal OneDrive account to retrieve file lists, check file sizes, and perform local file comparisons.

- Product
- Microsoft OneDrive
- Device & OS
- not provided
- Scenario
- A developer is attempting to build a tool or script that interacts directly with a personal OneDrive account to manage, scan, or compare file structures.
- Observed behavior
- The user requires official developer documentation and API endpoints rather than consumer-level support for OneDrive file management.
Before starting your API implementation, ensure you have an active Microsoft account and access to the Microsoft Entra admin center to register your application.
Use the Microsoft Graph API for OneDrive
The official and most robust method to interact with OneDrive programmatically is by utilizing the Microsoft Graph API.
Microsoft Graph provides a unified REST API endpoint that allows developers to access data within the Microsoft 365 ecosystem, including personal OneDrive accounts. It replaces older, deprecated OneDrive-specific APIs and offers comprehensive methods to list files, retrieve metadata such as exact file sizes, and upload or download content.
Navigate to the Microsoft Entra admin center, register a new application, and configure it to support personal Microsoft accounts. This step provides the client ID necessary for authentication.
In your app registration, add the necessary Microsoft Graph permissions. For reading file sizes and lists, select 'Files.Read' or 'Files.ReadWrite' under delegated permissions.
Use the Microsoft Authentication Library (MSAL) to acquire an access token for the user, allowing your application to securely make calls on their behalf.
Execute a standard HTTP GET request to 'https://graph.microsoft.com/v1.0/me/drive/root/children' to retrieve a list of files in the root directory, which will include size properties for your local comparisons.

Looking for a seamless Office suite to open your local and cloud files?
While you build your custom OneDrive API integration, consider using WPS Office to seamlessly view and edit your local documents. WPS Office is a high-performing suite that perfectly handles your file management needs without a subscription.
- 1. Download the software: Visit the official WPS Office website and download the free installation package tailored for your operating system.
- 2. Install WPS Office: Run the downloaded installer and follow the quick on-screen instructions to set up the suite on your computer.
- 3. Manage your files: Launch WPS Office to instantly open your local files or seamlessly connect to your preferred cloud storage platforms.

Frequently Asked Questions
Does the Microsoft Graph API support personal OneDrive accounts?
Yes, the Microsoft Graph API supports both OneDrive for Business and personal OneDrive accounts. You simply need to ensure that your application registration is configured to permit personal Microsoft accounts during the initial setup.
Can I use the API to compare local file sizes with OneDrive files?
Yes. When you retrieve file listings via the API, the JSON response includes a 'size' property indicating the exact byte count of the file. Your code can use this metadata to compare against local file sizes for synchronization or duplicate detection.
Is there an SDK available for interacting with OneDrive?
Microsoft provides official Microsoft Graph SDKs for several major programming languages including C#, Java, JavaScript, Python, and PHP. These SDKs simplify the process of handling authentication, creating requests, and parsing OneDrive file data.




