Skip to main content

Python SharePoint API for folder or file operations (download, upload, delete)

Project description

Sharepoint API

Install

pip install sharepoint-api

Setup Config

Create config.yaml

TENANT_NAME: ""
SITE_NAME: ""
CLIENT_ID: "xxxxxxx-xxxx-xxxx-xxxx-xxxxxxx"
CLIENT_SECRET: ""
LIBRARY_NAME: "Shared Documents"

Currently I am using Sharepoint "Shared Documents" area
If you needs to change -> Change in YAML file

LIBRARY_NAME: ""

Examples:

from sharepoint_api import SharePoint


sharepoint = SharePoint(config_path='config.yaml')
sp_path = "Myfiles/temp"
folder = sharepoint.get_folder(sp_path)
print(f"Folder: {folder}")
files, subfolders = sharepoint.list_folder_items()
print(files, subfolders)

# Download file
sharepoint.download_file(sp_path="Myfiles/temp/exam_result_v1.csv", local_file_path="/home/user/myfiles")

# Delete File
sharepoint.delete_file("MyFiles/models/yolo11n-obb.pt")

# Get file metadata
file_metadata = sharepoint.get_file_metadata("MyFiles/videos/sample_video.mp4")
print(f"File Metadata: {file_metadata.properties}")

# Upload File
sharepoint.upload_file("sample/exam_result_v1.csv", "Myfiles/temp/upload_test")

# Download Folder
sharepoint.download_folder(sp_path="Myfiles/temp/test1", local_file_path="/home/user/myfiles/sample")

# Create Folder
sharepoint.create_folder("Myfiles/temp/test2")

# Delete Folder
sharepoint.delete_folder("Myfiles/temp/test2")

# Upload Folder
sharepoint.upload_folder("sample/test", "Myfiles/gallery")

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

sharepoint_api-1.4.1.tar.gz (5.0 kB view details)

Uploaded Source

File details

Details for the file sharepoint_api-1.4.1.tar.gz.

File metadata

  • Download URL: sharepoint_api-1.4.1.tar.gz
  • Upload date:
  • Size: 5.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.10.16

File hashes

Hashes for sharepoint_api-1.4.1.tar.gz
Algorithm Hash digest
SHA256 11f372aabe363606413df8779aa9c1f2c72027ab896a1cc8926132bf7e7f6463
MD5 97e7a1b78b563792e75e6b7eed1f379d
BLAKE2b-256 e6e945e43623c7de692d7a7cd6340286c18d689283a67439c6ec045e4f83511e

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page