Skip to main content

sharepointlib

Microsoft SharePoint client package for Python powered by Rust.

Installation

pip install sharepointlib

Usage

import sharepointlib

sharepoint = sharepointlib.SharePoint(
    client_id="<client-id>",
    tenant_id="<tenant-id>",
    client_secret="<client-secret>",
    sp_domain="companygroup.sharepoint.com",
)

Authentication and sites

# Force token refresh (for long-running sessions)
sharepoint.renew_token()
# Site metadata
response = sharepoint.get_site_info(name="My Site", save_as="site_info.json")
if response.status_code == 200:
    print(response.content)
# Resolve hostname details from a site ID
response = sharepoint.get_hostname_info(site_id="companygroup.sharepoint.com,abc,def")
if response.status_code == 200:
    print(response.content)
# Drives
response = sharepoint.list_drives(site_id="companygroup.sharepoint.com,abc,def")
if response.status_code == 200:
    print(response.content)

Drives and files

# List a folder
response = sharepoint.list_dir(
    drive_id="b!123",
    path="Sellout/Support",
    alias=r"_\d{8}",
)
if response.status_code == 200:
    print(response.content)
# Download one file
response = sharepoint.download_file(
    drive_id="b!123",
    remote_path="Sellout/Support/report.xlsx",
    local_path=r"C:\\Temp\\report.xlsx",
)
print(response.status_code)
# Download to memory (bytes)
response = sharepoint.download_file_to_memory(
    drive_id="b!123",
    remote_path="Sellout/Support/report.xlsx",
)
if response.status_code == 200:
    payload_bytes = response.content
    print(len(payload_bytes))
# Copy across drives via streaming
response = sharepoint.copy_file_stream(
    source_drive_id="b!SRC",
    source_path="Sellout/2024/Sellout_November.xlsx",
    target_drive_id="b!DST",
    target_path="Archive/2024",
    new_name="Sellout_November_2024_Backup.xlsx",
    timeout=7200,
)
print(response.status_code)
# Get folder metadata
response = sharepoint.get_dir_info(
    drive_id="b!123",
    path="Sellout/Support",
)
if response.status_code == 200:
    print(response.content)
# Create / rename / delete a folder
created = sharepoint.create_dir(
    drive_id="b!123",
    path="Sellout",
    name="Support_New",
)

renamed = sharepoint.rename_folder(
    drive_id="b!123",
    path="Sellout/Support_New",
    new_name="Support_Renamed",
)

deleted = sharepoint.delete_dir(
    drive_id="b!123",
    path="Sellout/Support_Renamed",
)

print(created.status_code, renamed.status_code, deleted.status_code)
# File metadata and download URL
info = sharepoint.get_file_info(
    drive_id="b!123",
    filename="Sellout/Support/report.xlsx",
)
url = sharepoint.get_download_url(
    drive_id="b!123",
    filename="Sellout/Support/report.xlsx",
)

print(info.status_code)
print(url)
# Upload a local file
response = sharepoint.upload_file(
    drive_id="b!123",
    local_path=r"C:\\Temp\\report.xlsx",
    remote_path="Sellout/Support",
)
print(response.status_code)
# Move / rename / copy / delete a file
moved = sharepoint.move_file(
    drive_id="b!123",
    filename="Sellout/Support/report.xlsx",
    target_path="Archive/2024",
    new_name="report_2024.xlsx",
)

renamed = sharepoint.rename_file(
    drive_id="b!123",
    filename="Archive/2024/report_2024.xlsx",
    new_name="report_final.xlsx",
)

copied = sharepoint.copy_file(
    drive_id="b!123",
    filename="Archive/2024/report_final.xlsx",
    target_path="Archive/Backup",
)

deleted = sharepoint.delete_file(
    drive_id="b!123",
    filename="Archive/Backup/report_final.xlsx",
)

print(moved.status_code, renamed.status_code, copied.status_code, deleted.status_code)
# Check out and check in a file
checked_out = sharepoint.check_out_file(
    drive_id="b!123",
    filename="Sellout/Support/report.xlsx",
)

checked_in = sharepoint.check_in_file(
    drive_id="b!123",
    filename="Sellout/Support/report.xlsx",
    comment="Updated after reconciliation",
)

print(checked_out.status_code, checked_in.status_code)
# Download all files from a folder to a local directory
response = sharepoint.download_all_files(
    drive_id="b!123",
    remote_path="Sellout/Support",
    local_path=r"C:\\Temp\\support",
)
print(response.status_code)

SharePoint lists

# SharePoint lists
response = sharepoint.list_lists(site_id="companygroup.sharepoint.com,abc,def")
if response.status_code == 200:
    print(response.content)
# List list columns
response = sharepoint.list_list_columns(
    site_id="companygroup.sharepoint.com,abc,def",
    list_id="1234-5678-90ab-cdef",
)
if response.status_code == 200:
    print(response.content)
# List list items with selected fields
response = sharepoint.list_list_items(
    site_id="companygroup.sharepoint.com,abc,def",
    list_id="1234-5678-90ab-cdef",
    fields="Title,Status,Owner",
)
if response.status_code == 200:
    print(response.content)
# Add, update, and delete a list item
created = sharepoint.add_list_item(
    site_id="companygroup.sharepoint.com,abc,def",
    list_id="1234-5678-90ab-cdef",
    item={"Title": "New task", "Status": "Open"},
)

updated = sharepoint.update_list_item(
    site_id="companygroup.sharepoint.com,abc,def",
    list_id="1234-5678-90ab-cdef",
    item_id="42",
    item={"Status": "In progress"},
)

deleted = sharepoint.delete_list_item(
    site_id="companygroup.sharepoint.com,abc,def",
    list_id="1234-5678-90ab-cdef",
    item_id="42",
)

print(created.status_code, updated.status_code, deleted.status_code)

Methods that return a Response expose status_code (the HTTP status code) and content (the decoded payload: a dict, list, bytes, or None). Methods raise RuntimeError when a Rust operation fails.

For technical and contributor documentation, see DEV.md.

Version

Recommended way to read installed package version:

from importlib.metadata import version

print(version("sharepointlib"))

Convenience attribute:

import sharepointlib

print(sharepointlib.__version__)

Licence

BSD-3-Clause Licence (see LICENSE)

Metadata

Release files for sharepointlib 0.1.9

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for sharepointlib 0.1.9
File Size Uploaded
sharepointlib-0.1.9.tar.gz 41.7 kB Details

Built distributions (wheels)

Table of built distributions (wheels) for sharepointlib 0.1.9
File
sharepointlib-0.1.9-cp310-abi3-win_amd64.whl CPython 3.10 abi3 Windows x86-64 Details
sharepointlib-0.1.9-cp310-abi3-manylinux_2_39_aarch64.whl CPython 3.10 abi3 Linux glibc 2.39+ ARM64 Details
sharepointlib-0.1.9-cp310-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl CPython 3.10 abi3 Linux glibc 2.17+ x86-64 Details
sharepointlib-0.1.9-cp310-abi3-macosx_11_0_arm64.whl CPython 3.10 abi3 macOS 11.0+ ARM64 Details

Total release size: 10.5 MB

Release files / sharepointlib-0.1.9.tar.gz

Download URL sharepointlib-0.1.9.tar.gz
Size 41.7 kB
Tags Source
SHA-256 checksum
How to use checksums
1b5d252291d70a5d76feef5fedad4bb15ba9def47a8b6962de34055c8be580ce
BLAKE2b-256 checksum
How to use checksums
b189e6cf0e0e61f0dc56b2793a74cbd34f911a7ee27d037e06582542ec207a0e
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.13.14

Release files / sharepointlib-0.1.9-cp310-abi3-win_amd64.whl

Download URL sharepointlib-0.1.9-cp310-abi3-win_amd64.whl
Size 2.4 MB
Tags CPython 3.10 Windows x86-64 abi3
SHA-256 checksum
How to use checksums
f9bbe042ac6b14e03caac1ad81ce6de9e1d007635f85c4187757ce5d3c0eb8e1
BLAKE2b-256 checksum
How to use checksums
a1191b553a27a6fb17c8fa1175ca9c978a74767e92f4f196ff13ea9944e7107c
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.13.14

Release files / sharepointlib-0.1.9-cp310-abi3-manylinux_2_39_aarch64.whl

Download URL sharepointlib-0.1.9-cp310-abi3-manylinux_2_39_aarch64.whl
Size 2.8 MB
Tags CPython 3.10 Linux glibc 2.39+ ARM64 abi3
SHA-256 checksum
How to use checksums
d3ea4a50440d26d5ed8d15abfbdc438198e3d97c3ac9c8d8eba9f860f846077a
BLAKE2b-256 checksum
How to use checksums
6d269b8f026fd3aacdd8d71231f81127b671fc1710f4e17571036a61d52aba60
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.13.14

Release files / sharepointlib-0.1.9-cp310-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl

Download URL sharepointlib-0.1.9-cp310-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Size 2.8 MB
Tags CPython 3.10 Linux glibc 2.17+ x86-64 abi3
SHA-256 checksum
How to use checksums
2af1374b20444821b5f9d73c5e8692428a1256a5b17b252b3f52a9bda7e24954
BLAKE2b-256 checksum
How to use checksums
9cbe61042f49d4b19061b74f54f7c851da7d0ea898b4754f495ce99566e5fedc
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.13.14

Release files / sharepointlib-0.1.9-cp310-abi3-macosx_11_0_arm64.whl

Download URL sharepointlib-0.1.9-cp310-abi3-macosx_11_0_arm64.whl
Size 2.5 MB
Tags CPython 3.10 abi3 macOS 11.0+ ARM64
SHA-256 checksum
How to use checksums
86ef10ef53c520f2972c98793ce12d426ecb66ff8be417d1e3f193dfed89f810
BLAKE2b-256 checksum
How to use checksums
c4eb2f68bc257d0d6445301ce95b48c9c1884a172bd5e5026bb8ca59f39e2e8e
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.13.14

Release history Release notifications | RSS feed

This release

0.1.9 This release

5 release files

0.1.4

5 release files

0.0.44

2 release files

0.0.22

2 release files

0.0.20

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page