# Assess Grammar & Writing Quality

> This document outlines the essential steps for using the Grammar Checker API, covering scan execution and result management.

Get started with Copyleaks' [Grammar Checker](https://copyleaks.com/grammar-checker) API to detect and correct over 30 types of writing issues across grammar, mechanics, sentence structure, and word choice.

The API is available in two ways:
1.  **Sync:** Submit text via an HTTP request and receive the analysis in the response.
2.  **Async:** Use the [Authenticity API](/guides/authenticity/detect-plagiarism-text) to submit larger documents and receive results via webhook.

<Note>
This guide focuses on the **synchronous** option. For asynchronous submissions, see the **[Authenticity API Guide](/guides/authenticity/detect-plagiarism-text)**.
</Note>

## Get started

<Steps>
  <Step>
    ### Before you begin
    Before you start, ensure you have the following:
    - An active Copyleaks account. If you don't have one, **[sign up for free](https://api.copyleaks.com/signup)**.
    - You can find your API key on the **[API Dashboard](https://api.copyleaks.com/dashboard)**.
  </Step>

  <Step>
    ### Installation
    <InstallSDKs />
  </Step>

  <Step>
    ### Login
    <GuideLogin />
  </Step>

  <Step>
    ### Send request
    Use the [Writing Feedback Endpoint](/reference/actions/writing-assistant/check). Provide a unique `scanId` for each request.

    <Tip>
      For testing, set `"sandbox": true` in the request body. Sandbox mode is free and returns mock results.
    </Tip>

    <CodeGroup>
    ```http title="HTTP" icon="globe"
    POST https://api.copyleaks.com/v1/writing-feedback/my-scan-1/check

    Headers
    Authorization: Bearer <YOUR_AUTH_TOKEN>
    Content-Type: application/json

    Body
    {
      "text": "Copyleaks is a online plagarism detector that helps schools, business and content creators to make sure thier work is orginal. It scans textes from internet and databasis to find similerities. The tool is fast, accurate and supports multipal languages. However, some times it gives false possitives, so users should double check results. Overall, its a usefull platform for mantaining content integrity.",
      "sandbox": true
    }
    ```
    ```bash title="cURL" icon="terminal"
    curl -X POST "https://api.copyleaks.com/v1/writing-feedback/my-scan-1/check" \
         -H "Authorization: Bearer <YOUR_AUTH_TOKEN>" \
         -H "Content-Type: application/json" \
         -d '{
               "text": "Copyleaks is a online plagarism detector that helps schools, business and content creators to make sure thier work is orginal. It scans textes from internet and databasis to find similerities. The tool is fast, accurate and supports multipal languages. However, some times it gives false possitives, so users should double check results. Overall, its a usefull platform for mantaining content integrity.",
               "sandbox": true
             }'
    ```
    ```python title="Python" icon="python"
    from copyleaks.copyleaks import Copyleaks
    from copyleaks.models.submit.writing_assistant_document import WritingAssistantDocument

    scan_id = "my-python-scan"
    sample_text = "Hello world, this is a test."
    
    submission = WritingAssistantDocument(sample_text)
    submission.set_sandbox(True)
    
    response = Copyleaks.WritingAssistantClient.submit_text(auth_token, scan_id, submission)
    print(response)
    ```
    ```javascript title="JavaScript" icon="square-js"
    const { Copyleaks, CopyleaksWritingAssistantSubmissionModel } = require('plagiarism-checker');

    async function checkWriting() {
        try {
            // Initialize Copyleaks
            const copyleaks = new Copyleaks();

            // Login to get the authentication token.
            // Replace with your email and API key.
            const loginResult = await copyleaks.loginAsync('YOUR_EMAIL@example.com', 'YOUR_API_KEY');

            const scanId = `writing-scan-${Date.now()}`;
            
            // The text to be checked
            const textToCheck = "This is a sample text to check for grammar and writing quality.";

            // Create a submission model
            const submission = new CopyleaksWritingAssistantSubmissionModel(textToCheck);
            submission.sandbox = true; // Use sandbox for testing

            // Submit the text for analysis
            const response = await copyleaks.writingAssistantClient.submitTextAsync(loginResult, scanId, submission);
            console.log("Writing analysis results:", response);

        } catch (error) {
            console.error("An error occurred:", error);
        }
    }

    checkWriting();
    ```
    ```java title="Java" icon="java"
    import classes.Copyleaks;
    import models.submissions.CopyleaksWritingAssistantSubmissionModel;
    import models.responses.WritingAssistantResponse;

    String scanId = "my-java-scan";
    String sampleText = "Hello world, this is a test.";

    CopyleaksWritingAssistantSubmissionModel submission = new CopyleaksWritingAssistantSubmissionModel(sampleText);
    submission.setSandbox(true);

    WritingAssistantResponse response = Copyleaks.writingAssistantClient.submitText(authToken, scanId, submission);
    System.out.println(response);
    ```
    </CodeGroup>
  </Step>

  <Step>
    ### Interpreting the response
    The [Grammar Checker Response](/reference/data-types/writing/writing-assistant) contains detailed feedback under the `corrections` and `score` properties. The `score` provides an overall quality metric and a breakdown by category, while `corrections` pinpoints the exact location and suggested changes for each issue.

    ```json title="Example Response Snippet"
    {
      "score": {
        "corrections": {
          "overallScore": 93,
          "grammarCorrectionsScore": 100
        },
        "readability": {
          "readabilityLevelText": "College Student"
        }
      },
      "corrections": {
        "text": {
          "chars": { "types": [18], "starts": [28], "lengths": [9], "operationTexts": ["stretches "] }
        }
      }
    }
    ```
  </Step>
</Steps>

## Next steps

<CardGroup cols={2}>
    <Card title="Full API Reference" icon="code" href="/reference/actions/writing-assistant/check/">Explore the complete documentation for the Grammar Checker response object.</Card>
    <Card title="Correction Types" icon="list-check" href="/reference/data-types/writing/correction-types">See a detailed list of all supported correction types and languages.</Card>
    <Card title="Try it" icon="play" href="https://copyleaks.com/grammar-checker">Test the Copyleaks grammar checker with your own text and see suggestions in seconds.</Card>
</CardGroup>
