๐Ÿ”— Grammarly Integration with Zluri: Set up via API Tokens (REST API calls) - snehilkusum/API-Documentation-Samples GitHub Wiki


๐Ÿ“‹ Overview

This guide helps Zluri administrators integrate Grammarly via the OAuth 2.0 Set up via API Tokens (REST API calls) authentication method. After completing the setup, you'll be able to:

  • ๐Ÿ“Š Retrieve Grammarly usage data using the Analytics API

  • ๐Ÿ‘ฅ Manage licenses and user data via the License Management API

  • โœ๏ธ Score user-generated documents through the Writing Score API


โœ… Prerequisites

Before starting, ensure the following:

  • Grammarly Enterprise or Education subscription

  • Admin privileges in Grammarly dashboard

  • Zluri admin account with access to the Integrations panel


๐Ÿ” Step 1: Create OAuth 2.0 Credentials in Grammarly

  1. Log into your Grammarly Admin Panel.

  2. Go to: Organization > OAuth 2.0 Credentials

  3. Click Add Credential

  4. Name the credential (e.g., Zluri Integration)

  5. Select the scopes:

    • analytics-api

    • users-api

    • scores-api

  6. Click Create

  7. Copy your Client ID and Client Secret

โš ๏ธ Note: Keep these secure. Do not expose them in client-side code.

---

๐Ÿ” Step 2: Get OAuth Access Token

Use the following curl command to obtain an Access Token:

curl -X POST https://auth.grammarly.com/v4/api/oauth2/token \
  -d "grant_type=client_credentials" \
  -d "client_id=YOUR_CLIENT_ID" \
  -d "client_secret=YOUR_CLIENT_SECRET" \
  -d "scope=analytics-api:read users-api:read scores-api:write"

โœ… Example Response

{
  "access_token": "YOUR_ACCESS_TOKEN",
  "token_type": "bearer",
  "expires_in": 3600,
  ...
}

Use the access_token in the Authorization header as: Authorization: Bearer YOUR_ACCESS_TOKEN


๐Ÿ” Step 3: Use Grammarly APIs

๐Ÿ“ˆ A. Analytics API

Retrieve Grammarly usage statistics for licensed users.

Endpoint:

GET https://api.grammarly.com/ecosystem/api/v2/analytics/users

Example:

curl -X GET \
'https://api.grammarly.com/ecosystem/api/v2/analytics/users?limit=10&date_from=2024-10-01&date_to=2024-10-10' \
  -H "Authorization: Bearer YOUR_ACCESS_TOKEN"

๐Ÿ”„ Response:

Returns usage data like:

  • Days Active
  • Sessions Count
  • Sessions Improved %
  • Prompt Count

๐Ÿ‘ฅ B. License Management API

โžค List Users

GET https://api.grammarly.com/ecosystem/api/v1/users

โžค Delete a User

DELETE https://api.grammarly.com/ecosystem/api/v1/users/{userId}

โžค List Invitees

GET https://api.grammarly.com/ecosystem/api/v1/invitees

โžค Delete an Invitee

DELETE https://api.grammarly.com/ecosystem/api/v1/invitees/{inviteeId}

โœ๏ธ C. Writing Score API

  1. Create a score request:
POST https://api.grammarly.com/ecosystem/api/v2/scores
{
  "filename": "example.docx"
}
  1. Upload file (within 120 seconds):
curl -T example.docx "<file_upload_url_from_previous_step>"
  1. Get score results:
GET https://api.grammarly.com/ecosystem/api/v2/scores/{score_request_id}

๐Ÿ“Š Score Components:

  • general_score
  • correctness
  • clarity
  • delivery
  • engagement

๐Ÿงช Supported File Types

Format Extension MIME Type
Microsoft Word .doc / .docx application/msword, application/vnd.openxmlformats-officedocument.wordprocessingml.document
OpenDocument .odt application/vnd.oasis.opendocument.text
Text .txt text/plain
Rich Text .rtf application/rtf

โš ๏ธ Constraints & Recommendations

Limit Value
Max File Size 4 MB
Max Text Length 100,000 characters
Upload Timeout 120 seconds
API Request Rate 50 req/sec (GET), 10 req/sec (POST)
Score Retention 30 days
Document Retention โ‰ค 24 hours
Pagination Use limit and cursor

๐Ÿง  Use exponential backoff for 429 (Rate Limit Exceeded) responses.



๐Ÿ“š References


Got questions? Feel free to submit a ticket or contact us directly at [email protected].

โš ๏ธ **GitHub.com Fallback** โš ๏ธ