Swift. Make your first call.
Install the official Swift client and bring ParseAPI into your app.
Official Swift SDK
.package(url: "https://github.com/parseapi/swift", from: "1.8.0")Your language. The same ParseAPI.
Get connected
One country. Your first request.
Look up the United States and print its name.
Install the library.
Add the ParseAPI product to your app target. In Xcode, you can also add the repository URL through Add Package Dependencies.
.package(url: "https://github.com/parseapi/swift", from: "1.8.0")Add your app key.
Create an app key in Keys and allow your bundle identifier. Replace parse_app_... in the example.
The SDK sends your bundle identifier automatically. Carrier, HLR and Email mailbox verification require a secret key on your server.
Make a request.
Add this function to your app, then call it from an async task. This lookup uses your plan's request allowance.
import ParseAPI
func loadCountry() async throws {
let parse = try ParseAPI("parse_app_...")
let country = try await parse.country("US")
print(country.name)
}
// Call from your app's async task.
// try await loadCountry()United StatesHandle API errors
Read the error code and request ID when an API request fails. Branch on the code, such as not_found, rather than the message. A response with valid: false is a successful lookup. Transport failures still propagate.
import ParseAPI
func loadCountry() async throws {
let parse = try ParseAPI("parse_app_...")
do {
let country = try await parse.country("US")
print(country.name)
} catch let error as ParseAPIError {
print(error.code, error.status, error.requestId ?? "")
throw error
}
}
// Call from your app's async task.
// try await loadCountry()Requests and retries
SDK methods follow the API routes. Unknown response values stay unknown, rather than becoming empty strings or guesses.
Ordinary lookups retry temporary failures. Separately metered checks make one attempt by default. You can configure the retry count. See the retry policy.