Scan API

API Scan est une nouvelle fonctionnalité fournie par Look Scanned qui permet de convertir des documents PDF en copies numérisées réalistes via de simples appels API, adaptée aux processus d'automatisation et à l'intégration de développement. Elle prend en charge divers paramètres personnalisables, notamment la couleur, le bruit, le flou, les bordures et les angles de rotation pour répondre aux différentes exigences des scénarios. API Scan est compatible avec divers environnements de développement et langages de programmation courants, permettant aux développeurs d'intégrer facilement les fonctionnalités principales de Look Scanned dans leurs propres applications ou services.

API Bearer Token

Exemples de code

TypeScript TypeScript
Python Python
curl cURL
interface ScanConfig {
  rotate?: number                // degrees to rotate the document
  rotate_var?: number            // degrees to rotate the document randomly
  colorspace?: 'gray' | 'sRGB'   // the colorspace of the output image
  blur?: number                  // the amount of blur to apply to the image
  noise?: number                 // the amount of noise to apply to the image
  border?: boolean               // whether to add a border to the image
  brightness?: number            // the brightness of the image. 1 is no change
  contrast?: number              // the contrast of the image. 1 is no change
  resolution?: number            // the resolution of the image in DPI
  output_format?: 'image/png' | 'image/jpeg' // the format of the output image
}

interface ScanOptions {
  config: ScanConfig
  webhookUrl?: string        // webhook URL to notify when job is completed
}

interface ScanResponse {
  jobID: string              // UUID of the scan job
  userID: string             // UUID of the user who created the job
  createdAt: number          // timestamp of job creation
  status: 'pending' | 'processing' | 'completed' | 'failed'
  config: ScanConfig
  inputUploadedAt?: number   // timestamp when input file was uploaded
  completedAt?: number       // timestamp when job was completed
  webhookUrl?: string        // webhook URL for notifications
  uploadURL?: string         // S3 presigned URL for file upload
  downloadURL?: string       // S3 presigned URL for file download
}

async function apiScan(pdfBlob: Blob, scanOptions: ScanOptions, token: string): Promise<ScanResponse> {
  const response = await fetch('https://api.lookscanned.io/v1/scan-jobs', {
    method: 'POST',
    headers: {
      'Authorization': `Bearer ${token}`
    },
    body: JSON.stringify(scanOptions)
  })
  const result: ScanResponse = await response.json()

  // PUT PDF Blob to upload URL
  const uploadURL = result.uploadURL
  await fetch(uploadURL, {
    method: 'PUT',
    headers: {
      'Content-Type': 'application/pdf',
      'Content-Length': pdfBlob.size.toString()
    },
    body: pdfBlob
  })
  
  // get scan job status
  const jobStatusResponse = await fetch(`https://api.lookscanned.io/v1/scan-jobs/${result.jobID}`, {
    headers: {
      'Authorization': `Bearer ${token}`
    }
  })
  return await jobStatusResponse.json()
}

Essayez-le

Grayscale
image/jpeg
{
  "config": {
    "rotate": 1,
    "rotate_var": 0.5,
    "colorspace": "gray",
    "blur": 0,
    "noise": 0,
    "border": false,
    "brightness": 1.3,
    "contrast": 1.3,
    "resolution": 150,
    "output_format": "image/jpeg"
  }
}