> ## Documentation Index
> Fetch the complete documentation index at: https://docs.somark.cn/llms.txt
> Use this file to discover all available pages before exploring further.

# SoMark SDK

> Integrate document parsing into your Python or JavaScript project with the SoMark SDK.

Best for products, backend services, and automation systems. If you are still comparing integration paths, start with the [get started overview](/en/documentation/get-started-overview); if you only need a terminal workflow, go to [SoMark CLI](/en/documentation/cli).

<Steps>
  <Step title="Install the SDK">
    SoMark provides both Python and JavaScript implementations.

    <CodeGroup>
      ```bash Python theme={null}
      pip install somark
      ```

      ```bash JavaScript theme={null}
      npm install somark-js
      ```
    </CodeGroup>
  </Step>

  <Step title="Initialize the client">
    The simplest setup is to pass your API key during initialization.

    <CodeGroup>
      ```python Python theme={null}
      from somark import SoMark

      client = SoMark(api_key="sk-your-api-key")
      ```

      ```typescript JavaScript theme={null}
      import { SoMark } from 'somark-js'

      const client = new SoMark({ apiKey: 'sk-your-api-key' })
      ```
    </CodeGroup>
  </Step>

  <Step title="Complete one sync parse first">
    Start with one file and one working result before expanding into more formats or downstream processing.

    <CodeGroup>
      ```python Python theme={null}
      response = client.parser.parse(
          file="./document.pdf",
          formats=["md", "json"],
      )
      response.save("./document.md")
      ```

      ```typescript JavaScript theme={null}
      const response = await client.parser.parse({
        file: './document.pdf',
        formats: ['md', 'json'],
      })

      await response.save('./document.md')
      ```
    </CodeGroup>
  </Step>

  <Step title="Use async tasks for larger jobs">
    Long documents, batch jobs, and background flows are a better fit for async mode.

    <CodeGroup>
      ```python Python theme={null}
      task = client.parser.parse_async(file="./large.pdf", formats=["md"])
      result = task.wait()
      result.save("./large.md")
      ```

      ```typescript JavaScript theme={null}
      const task = await client.parser.parseAsync({
        file: './large.pdf',
        formats: ['md'],
      })

      const result = await task.wait()
      await result.save('./large.md')
      ```
    </CodeGroup>

    For more parameter details and error-handling guidance, continue to the [CLI & SDK usage guide](/en/cli-sdk/usage).
  </Step>
</Steps>
