Skip to content

blindpaylabs/blindpay-swift

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

18 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

BlindPay Swift SDK

chat on Discord twitter Version

The official Swift SDK for BlindPay - Global payments infrastructure made simple.

Installation

Swift Package Manager

Add the following to your Package.swift file:

dependencies: [
    .package(url: "https://github.com/blindpaylabs/blindpay-swift.git", from: "1.0.0")
]

Or add it via Xcode:

  1. File → Add Packages...
  2. Enter the repository URL: https://github.com/blindpaylabs/blindpay-swift.git
  3. Select the version and add it to your target

Authentication

To get started, you will need both your API key and your instance ID, you can obtain your API key and instance ID from the BlindPay dashboard https://app.blindpay.com/instances/<instance_id>/api-keys

import BlindPay

let blindpay = BlindPay(
    apiKey: "your-api-key-here",
    instanceId: "your-instance-id-here"
)

Note

All API calls are going to use the provided API key and instance ID

Quick Start

Check for available rails

func getAvailableRails() async {
    let blindpay = BlindPay(
        apiKey: "your-api-key-here",
        instanceId: "your-instance-id-here"
    )

    do {
        let response = try await blindpay.getRails()

        if let error = response.error {
            throw NSError(domain: "BlindPay", code: -1, userInfo: [NSLocalizedDescriptionKey: error.message])
        }

        if let data = response.data {
            print("Rails: ", data)
        }
    } catch {
        print("Error: \(error)")
    }
}

await getAvailableRails()

Response format

All API methods return a consistent response format

Success response

APIResponse(
    data: /* your data */,
    error: nil
)

Error response

APIResponse(
    data: nil,
    error: APIError(message: "Error message")
)

Error handling

This SDK uses a consistent error handling pattern. Always check for errors:

do {
    let response = try await blindpay.getRails()

    if let error = response.error {
        print("API Error: \(error.message)")
        return
    }

    if let data = response.data {
        print("Success:", data)
    }
} catch {
    print("Error: \(error)")
}

For detailed API documentation, visit:

Support

License

This project is licensed under the MIT License - see the LICENSE file for details.

Made with ❤️ by the BlindPay team