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
Python
cURL
interfaceScanConfig {
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
}
interfaceScanOptions {
config: ScanConfig
webhookUrl?: string// webhook URL to notify when job is completed
}
interfaceScanResponse {
jobID: string// UUID of the scan jobuserID: string// UUID of the user who created the jobcreatedAt: number// timestamp of job creationstatus: '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
}
asyncfunctionapiScan(pdfBlob: Blob, scanOptions: ScanOptions, token: string): Promise<ScanResponse> {
const response = awaitfetch('https://api.lookscanned.io/v1/scan-jobs', {
method: 'POST',
headers: {
'Authorization': `Bearer ${token}`
},
body: JSON.stringify(scanOptions)
})
constresult: ScanResponse = await response.json()
// PUT PDF Blob to upload URLconst uploadURL = result.uploadURLawaitfetch(uploadURL, {
method: 'PUT',
headers: {
'Content-Type': 'application/pdf',
'Content-Length': pdfBlob.size.toString()
},
body: pdfBlob
})
// get scan job statusconst jobStatusResponse = awaitfetch(`https://api.lookscanned.io/v1/scan-jobs/${result.jobID}`, {
headers: {
'Authorization': `Bearer ${token}`
}
})
returnawait jobStatusResponse.json()
}