GCRIPT Python API Client & Examples

This document describes the Python API client examples provided with GCRIPT to help developers automate document processing workflows.

Overview

The GCRIPT project includes a set of ready-to-use Python scripts that demonstrate how to interact with the API. These scripts cover the full lifecycle of a job, from health checks to result downloading.

Location

  • Source Code: gcript_web/content/examples/python_api_client/
  • Downloadable Zip: Available on the FAQ Page or at static/examples/python_api_client.zip

Included Examples

Script Description
config.py Central configuration file for API URL and Key.
1_check_health.py Verifies connectivity to the API and validates your API Key.
2_submit_job.py Demonstrates how to upload a file and submit a processing job with configuration options (including anonymization).
3_check_status.py Polls the /jobs/<id> endpoint to check the progress of a specific job.
4_download_result.py Downloads the final processed document once the job is complete.
5_end_to_end.py A complete workflow script that chains all the above steps together.
6_analyze_and_submit.py Advanced: Demonstrates how to first analyze a document structure (/analyze-sections) and then submit a job that specifically skips certain sections.

Feature Highlight: Advanced Configuration

The examples demonstrate advanced API features including:

1. Anonymization

You can protect sensitive information by specifying a list of strict terms to anonymize. * Configuration: anonymization.protected_strings * Example: 2_submit_job.py * Usage: python options = { "anonymization": { "protected_strings": ["Project Alpha", "John Doe"], "anonymize_numbers": True } }

2. Section Skipping

You can skip specific sections of a document (e.g., appendices, prefaces) by index. * Configuration: skip_sections (List of integers) * Example: 6_analyze_and_submit.py * Usage: 1. Call POST /api/analyze-sections to get the list of sections and their indices. 2. Pass the indices you want to skip in the job submission config: python options = { "skip_sections": [0, 4] # Skips the first and fifth sections }

Getting Started

  1. Download the examples from the FAQ page.
  2. Install Requests: pip install requests
  3. Configure: Edit config.py with your API Key (generated in your User Profile).
  4. Run: Execute python 5_end_to_end.py to see it in action.