Skip to main content

grafap

grafap is a Python package for interacting with the Microsoft Graph API and the Sharepoint REST API. Primarily common functions with regards to sharepoint lists. Creating new items, querying lists, etc.

Usage

from grafap import GrafapClient

client = GrafapClient(
    tenant_id="...",
    client_id="...",
    client_secret="...",
)

# Or just use convenience func to pull from expected env vars
# if already loaded
client = GrafapClient.from_env()

# async
sites = await client.sites_return()

# sync
sites = client.sync.sites_return()

Can run untit tests with uv run pytest tests -v when in the project root. Integration tests require real Graph API credentials and network access, so they are marked with @pytest.mark.integration and can be run separately with uv run pytest tests -v -m integration.

Configuration

Several parameters are required for grafap client instantiation. Most of the endpoints in grafap are just using the standard Microsoft Graph API which only requires a client ID and secret.

The Sharepoint REST API, however requires using a client certificate. The Sharepoint REST API is currently only used for the following functions (that don't have an equivalent in the Microsoft Graph API). If you're not using them, then you don't need the certificate or the other vars in the Sharepoint REST API table.

  • "ensuring" a user in a sharepoint site.
  • downloading an attachment from a sharepoint list item

MS Graph Vars

Env Variable Description
GRAPH_LOGIN_BASE_URL Should be https://login.microsoftonline.com/
GRAPH_BASE_URL Should be https://graph.microsoft.com/v1.0/sites/
GRAPH_TENANT_ID Tenant ID from app registration created in Azure.
GRAPH_CLIENT_ID Client ID from app registration created in Azure.
GRAPH_CLIENT_SECRET Client secret from app registration created in Azure.
GRAPH_GRANT_TYPE Should be 'client_credentials'
GRAPH_SCOPES Should typically be https://graph.microsoft.com/.default unless using more fine-grained permissions.

Sharepoint Rest API Vars

Env Variable Description
SP_SITE Base Site URL you're interacting with. Should be https://DOMAIN.sharepoint.com/
SP_SCOPES Scopes for sharepoint rest API. Should look like <https://{tenant name}.sharepoint.com/.default>
SP_LOGIN_BASE_URL Should be https://login.microsoftonline.com/
SP_TENANT_ID Tenant ID from app registration created in Azure.
SP_CLIENT_ID Client ID from app registration created in Azure.
SP_GRANT_TYPE client_credentials
SP_CERTIFICATE_PATH Path to .pfx file
SP_CERTIFICATE_PASSWORD Password for the .pfx file.

Metadata

Release files for grafap 2.0

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

Source distribution (sdist)

Source distribution for grafap 2.0
File Size Uploaded
grafap-2.0.tar.gz 11.0 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for grafap 2.0
File Interpreter ABI Platform
grafap-2.0-py3-none-any.whl Python 3 none any Details

Total release size: 23.0 kB

Release files / grafap-2.0.tar.gz

Download URL grafap-2.0.tar.gz
Size 11.0 kB
Tags Source
SHA-256 checksum
How to use checksums
680bab21c7438e46a08673353fb79e8e1e6acd4bc6de7dbc24d8689e8bfc0771
BLAKE2b-256 checksum
How to use checksums
ac509fa561038120552f5111707042b292efdc0e412fc43324d7cac861e008f3
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via uv/0.12.2 {"installer":{"name":"uv","version":"0.12.2","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

Release files / grafap-2.0-py3-none-any.whl

Download URL grafap-2.0-py3-none-any.whl
Size 11.9 kB
Tags Python 3
SHA-256 checksum
How to use checksums
4fb73c452863554eaee7c29051e48bc08d5983c00cf3134432579331284dda43
BLAKE2b-256 checksum
How to use checksums
4966fe1c6fac483737f6dcdb36087849c78dc3f3a72761f09861ea68af937dd8
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via uv/0.12.2 {"installer":{"name":"uv","version":"0.12.2","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

Release history Release notifications | RSS feed

2.1

2 release files

This release

2.0 This release

2 release files

1.2

2 release files

1.1

2 release files

1.0

2 release files

0.1.13

2 release files

0.1.10

2 release files

0.1.9

2 release files

0.1.8

2 release files

0.1.7

2 release files

0.1.6

2 release files

0.1.5

2 release files

0.1.4

2 release files

0.1.2

2 release files

0.1.1

2 release files

0.1.0

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