Swift πŸ¦‰

The official Swift client for the CardScan API provides a native Swift interface with async/await support.

Installation

Swift Package Manager

Add the following to your Package.swift:

dependencies: [
    .package(url: "https://github.com/CardScan-ai/api-clients.git", from: "1.0.0")
]

Or in Xcode:

  1. File β†’ Add Package Dependencies

  2. Enter: https://github.com/CardScan-ai/api-clients.git

  3. Select version rule and add to your project

Basic Usage

import CardScanClient

// Initialize with your API key
let apiKey = "sk_test_cardscan_ai_..."
let client = CardScanAPI(apiKey: apiKey)

// Generate a session token for a user
do {
    let tokenResponse = try await client.getAccessToken(userId: "unique-user-123")
    let sessionToken = tokenResponse.Token
    let identityId = tokenResponse.IdentityId
    let sessionId = tokenResponse.session_id
    
    // Initialize client with session token for frontend operations
    let userClient = CardScanAPI(sessionToken: sessionToken, live: false)
} catch {
    print("Error creating access token: \(error)")
}

Card Scanning Workflow

1. Create a Card

2. Generate Upload URL

3. Upload Image

4. Poll for Results

Error Handling

WebSocket Support

For real-time updates:

Eligibility Verification

SwiftUI Integration

Combine Support

For reactive programming with Combine:

Configuration

Source Code

View the source code and contribute: GitHub

Last updated

Was this helpful?