Skip to main content

npm SDK Installation

The Artos npm SDK (@artosai/sdk) provides a lightweight JavaScript/TypeScript client for integrating Artos functionality into your application.

Prerequisites

Before you begin, ensure you have:
  • Node.js version 16.0.0 or higher
  • npm or yarn package manager
  • An Artos API access token (provided by your Artos account manager)
  • A GitHub Packages access token (provided by Artos for SDK installation)

Step 1: Configure npm to use GitHub Packages

Create or update your project’s .npmrc file in the root of your project:
touch .npmrc
Add the following lines to .npmrc:
@artosai:registry=https://npm.pkg.github.com
//npm.pkg.github.com/:_authToken=YOUR_GITHUB_PACKAGES_TOKEN
Replace YOUR_GITHUB_PACKAGES_TOKEN with the token provided by Artos.
Using environment variables (recommended for CI/CD and security):
@artosai:registry=https://npm.pkg.github.com
//npm.pkg.github.com/:_authToken=${GITHUB_PACKAGES_TOKEN}
Then set the environment variable before installing:
export GITHUB_PACKAGES_TOKEN=your_token_here
Do not use npm login with GitHub Packages - it is not supported. Always use the .npmrc file method.

Step 2: Install the SDK

npm install @artosai/sdk
Or with yarn:
yarn add @artosai/sdk

Verify Installation

import { getTemplateUrl } from '@artosai/sdk'
console.log('Artos SDK installed successfully!')

Quick Start

Here’s a minimal example to get you started:
import { getTemplateUrl } from '@artosai/sdk'

async function main() {
    const result = await getTemplateUrl({
        documentId: 'your-document-id',
        accessToken: process.env.ARTOS_ACCESS_TOKEN,
        baseUrl: 'https://api.artosai.com'
    })

    console.log('Template URL:', result.templateUrl)
    console.log('Template ID:', result.templateId)
    console.log('Document Name:', result.documentName)
}

main().catch(console.error)

Troubleshooting

”Cannot find module ‘@artosai/sdk’”

Cause: The package is not installed or npm is not configured correctly. Solution:
  1. Verify your .npmrc file is in the project root
  2. Check that the GitHub Packages token is correct
  3. Run npm install @artosai/sdk again

Network Timeouts

Cause: Network connectivity issues or server unavailability. Solution:
  1. Check your internet connection
  2. Verify the API base URL is correct (must include https://)
  3. Implement retry logic for transient failures (see Error Handling)