API Reference

Sapling HTTP API documentation

class sapling.client.SaplingClient(api_key, timeout=120, hostname=None, pathname=None)

Sapling client class. Provides a mapping of Python functions to Sapling HTTP REST APIs.

Parameters
  • api_key (str) – 32-character API key

  • timeout (int) – Timeout for API call in seconds. Defaults to 120 seconds.

  • hostname (str) – Hostname override for SDK and self-hosted deployments.

  • pathname (str) – Pathname override for SDK and self-hosted deployments as well as version requirements.

accept(edit_uuid, session_id=None)

Use this API endpoint to have Sapling adapt its system over time.

Each suggested edit has an edit UUID. You can pass this information back to Sapling to indicate the edit suggestion was helpful. For each unique edit in each document, use the accept or reject API endpoint only once in total.

Parameters
  • edit_uuid (str, uuid) – Opaque UUID of the edit returned from the edits endpoint

  • session_id (str) – Unique name or UUID of text that is being processed

edits(text, session_id=None, variety=None, auto_apply=False)

Fetches edits (including for grammar and spelling) for provided text.

Parameters
  • text (str) – Text to process for edits.

  • session_id (str) – Unique name or UUID of document or portion of text that is being checked

  • variety (str) – Specifies regional English variety preference. Defaults to the configuration in the user Sapling dashboard.

  • auto_apply (bool) – Whether to return a field with edits applied to the text

Return type

list[dict]

Supported varieties:
  • us-variety: American English

  • gb-variety: British English

  • au-variety: Australian English

  • ca-variety: Canadian English

  • null-variety: Don’t suggest changes based on English variety

reject(edit_uuid, session_id=None)

Use this API endpoint to have Sapling not recommend the same edit anymore.

Each suggested edit has an edit UUID. You can pass this information back to Sapling to indicate the edit suggestion was not helpful. For each unique edit in each document, use the accept or reject API endpoint only once in total.

Parameters
  • edit_uuid (str, uuid) – Opaque UUID of the edit returned from the edits endpoint

  • session_id (str) – Unique name or UUID of text that is being processed