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)
# Request up to 5,000 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.10

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.10
File Size Uploaded Provenance Actions
sharepointlib-0.1.10.tar.gz 41.8 kB Without provenance Details for sharepointlib-0.1.10.tar.gz

Built distributions (wheels)

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

Total release size: 10.5 MB

Release files / sharepointlib-0.1.10.tar.gz

Download URL sharepointlib-0.1.10.tar.gz
Size 41.8 kB
Tags Source
SHA-256 checksum
How to use checksums
61eb5322d5099da7516e3220ba69cbe2a306d77ebfcb9fcdc526f8d2667e5cc9
BLAKE2b-256 checksum
How to use checksums
94f0159d65b16c39e0c272bf52f060aadce36b5fcf8ee8b9f476b641d07c9d56
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.13.16

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

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

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

Download URL sharepointlib-0.1.10-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
ab193b76c12f32617ccf824b30f0822e4bad3f0340956545ab4f17e18fd8f249
BLAKE2b-256 checksum
How to use checksums
e48ae578289c7846342a447301b1257413e8a5f91e5c57e9e3d0ece01b8eebc5
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.13.16

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

Download URL sharepointlib-0.1.10-cp310-abi3-manylinux2014_x86_64.manylinux_2_17_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
8bf659552dc6b4e2a3ff5e31bb4e27a23d323cf1600aa706cbcede014056180b
BLAKE2b-256 checksum
How to use checksums
6b9e3b1830ad34d5ef650c1c6d240f824c6bccbde345ba3dfe0e202d3c057b5e
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.13.16

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

Download URL sharepointlib-0.1.10-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
6995f5a25e1fca32fbba114d2100517326b0f2851fc950b0e6316c6721082f2c
BLAKE2b-256 checksum
How to use checksums
ea67a44683150d16fd4ac6b791c7c4b6c828848cfb7908c7b983fa10a495d65d
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.13.16

Security for sharepointlib 0.1.10

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

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