The best examples of integrating third-party APIs in iOS: 3 examples that actually ship
1. Real examples of integrating third-party APIs in iOS for payments
When people talk about examples of integrating third-party APIs in iOS: 3 examples, payments is usually the first category that comes up. You want to charge users, stay out of PCI compliance nightmares, and not reinvent card validation. That’s exactly why services like Stripe, Braintree, and RevenueCat exist.
Let’s walk through Stripe as a primary example, then touch on a few more real-world patterns.
Stripe: Card entry, Payment Intents, and 3D Secure
Stripe’s iOS SDK is one of the best examples of a third-party API done reasonably well for mobile. The modern flow in 2024–2025 almost always uses Payment Intents:
- Your iOS app collects payment details using Stripe’s UI components (or Apple Pay).
- Your backend creates a PaymentIntent via Stripe’s REST API.
- The app confirms the PaymentIntent and handles any Strong Customer Authentication (3D Secure) steps.
In Swift, the shape looks like this (simplified, but realistic):
import StripePaymentSheet
final class CheckoutViewModel: ObservableObject {
@Published var paymentSheet: PaymentSheet?
@Published var isLoading = false
func preparePaymentSheet() async {
isLoading = true
defer { isLoading = false }
// 1. Ask your backend to create a PaymentIntent and return client secret
let url = URL(string: "https://api.yourbackend.com/create-payment-intent")!
var request = URLRequest(url: url)
request.httpMethod = "POST"
let (data, _) = try await URLSession.shared.data(for: request)
let response = try JSONDecoder().decode(PaymentIntentResponse.self, from: data)
// 2. Configure the PaymentSheet
var configuration = PaymentSheet.Configuration()
configuration.merchantDisplayName = "Your App, Inc."
configuration.applePay = .init(merchantId: "merchant.com.yourapp", merchantCountryCode: "US")
paymentSheet = PaymentSheet(paymentIntentClientSecret: response.clientSecret,
configuration: configuration)
}
func presentPaymentSheet(from viewController: UIViewController) async throws {
guard let paymentSheet = paymentSheet else { return }
await withCheckedContinuation { continuation in
paymentSheet.present(from: viewController) { paymentResult in
switch paymentResult {
case .completed:
continuation.resume()
case .canceled:
continuation.resume()
case .failed(let error):
print("Payment failed: \(error)")
continuation.resume()
}
}
}
}
}
struct PaymentIntentResponse: Decodable {
let clientSecret: String
}
This is a concrete example of how third-party payment APIs usually split responsibilities:
- iOS app: Collects sensitive data using the vendor’s SDK, never directly touching raw card numbers.
- Backend: Talks to Stripe’s REST API using a secret key, creates PaymentIntents, and stores the result.
Other examples of integrating third-party APIs in iOS for payments include:
- Braintree for PayPal and cards in one SDK.
- RevenueCat for subscriptions built on top of StoreKit, which is especially useful if you’re trying to keep subscription logic out of your app code.
As you evaluate these, pay attention to:
- SDK size and impact on your app’s binary.
- Support for async/await and Swift Concurrency.
- How they handle PCI compliance and security recommendations. For broader context on payment security expectations in the U.S., the Federal Trade Commission’s guidance on online payments is worth a read: https://consumer.ftc.gov/articles/online-shopping.
2. Location and mapping: more examples of integrating third-party APIs in iOS
The second category in our examples of integrating third-party APIs in iOS: 3 examples is mapping and location. Apple’s MapKit is fine for many apps, but when teams need custom styling, turn-by-turn navigation, or advanced routing, they often reach for Mapbox, Google Maps Platform, or HERE.
Mapbox: Custom maps, directions, and offline tiles
Mapbox is a strong example of a third-party SDK that combines a native iOS framework with a REST API. You typically use:
- The Maps SDK for iOS to render maps locally.
- The Directions API and Matrix API via HTTPS for routing and ETA calculations.
A minimal SwiftUI integration might look like this using Mapbox Maps v11+ style APIs:
import MapboxMaps
import SwiftUI
struct MapboxMapView: UIViewRepresentable {
func makeUIView(context: Context) -> MapView {
let resourceOptions = ResourceOptions(accessToken: ProcessInfo.processInfo.environment["MAPBOX_ACCESS_TOKEN"] ?? "")
let initOptions = MapInitOptions(resourceOptions: resourceOptions,
cameraOptions: CameraOptions(center: CLLocationCoordinate2D(latitude: 37.7749,
longitude: -122.4194),
zoom: 11))
let mapView = MapView(frame: .zero, mapInitOptions: initOptions)
return mapView
}
func updateUIView(_ uiView: MapView, context: Context) { }
}
For directions, you’d usually call your own backend, which then calls Mapbox’s Directions API with your secret token. That pattern—client → your server → third-party API—is one of the best examples of how to avoid shipping secret keys inside an iOS app.
Mapbox is not the only mapping example of integrating third-party APIs in iOS. Teams also rely on:
- Google Maps SDK for iOS for Places, autocomplete, and Street View.
- HERE SDK when they need advanced fleet routing.
Across these services, common issues include:
- Rate limits: You can easily blow through free tiers if you’re not caching results. For location-heavy apps, it’s worth reading general guidance on location privacy and user expectations; the U.S. National Institute of Standards and Technology (NIST) has a good overview of privacy engineering considerations: https://www.nist.gov/privacy-engineering.
- Privacy: You’re sending user coordinates to a third party. Your privacy policy and in‑app disclosures need to match what you’re actually doing.
3. AI and language models: the newest examples of integrating third-party APIs in iOS
The third category in our examples of integrating third-party APIs in iOS: 3 examples is the newest one to go mainstream: AI. Whether it’s OpenAI, Anthropic, or Google Gemini, the pattern is similar: your app sends text or data to a model API and gets back generated content, embeddings, or classifications.
OpenAI: ChatGPT-style features inside an iOS app
OpenAI’s API is a straightforward HTTP JSON API. In production, you should treat it like Stripe or Mapbox: your iOS client talks to your backend, which then calls OpenAI with your secret key.
A trimmed-down Swift async/await example that calls your own proxy might look like this:
struct ChatRequest: Encodable {
let message: String
}
struct ChatResponse: Decodable {
let reply: String
}
final class ChatService {
func sendMessage(_ text: String) async throws -> String {
let url = URL(string: "https://api.yourbackend.com/chat")!
var request = URLRequest(url: url)
request.httpMethod = "POST"
request.setValue("application/json", forHTTPHeaderField: "Content-Type")
let body = ChatRequest(message: text)
request.httpBody = try JSONEncoder().encode(body)
let (data, _) = try await URLSession.shared.data(for: request)
let response = try JSONDecoder().decode(ChatResponse.self, from: data)
return response.reply
}
}
Your backend then talks to OpenAI’s /v1/chat/completions or /v1/responses endpoint. This is a clear example of integrating a third-party API in iOS without exposing API keys, and it also gives you a single place to implement safety filters and logging.
Other AI-related examples of integrating third-party APIs in iOS include:
- Speech-to-text via services like AssemblyAI or Google Cloud Speech-to-Text.
- Image recognition via AWS Rekognition or Google Vision AI.
- On-device plus cloud hybrid using Apple’s Core ML locally and a third-party model for heavy-duty tasks.
If your AI features touch health or mental health content, you should make sure your UX and claims are grounded in evidence. For general health information standards, resources from the U.S. National Institutes of Health are helpful context: https://www.nih.gov/health-information.
4. Common patterns across the best examples of third-party API integration
If you look across these best examples of integrating third-party APIs in iOS—Stripe, Mapbox, OpenAI, Firebase, RevenueCat—a few patterns repeat over and over.
Always assume the network will fail
Every example of a third-party integration that survives real traffic has defensive networking:
- Timeouts and retry logic with backoff.
- User-visible error states (“Can’t reach the server right now. Try again?”).
- Caching where it makes sense (e.g., recently fetched map tiles, last known AI response, locally stored payment methods).
With Swift Concurrency, you can centralize this in a small networking layer that wraps URLSession and handles retries, decoding, and error translation.
Keep secrets off the device
In all the serious examples of integrating third-party APIs in iOS: 3 examples, the pattern is the same:
- The iOS app talks to your API with short-lived tokens (OAuth, JWT, or session cookies).
- Your backend talks to Stripe, Mapbox, OpenAI, or whoever with long-lived secrets.
If a third-party SDK demands you embed a secret key in the app bundle, treat that as a red flag. At minimum, scope that key to mobile-only, narrow permissions, and be ready to rotate it.
Versioning and breaking changes
Third-party APIs evolve. Good vendors publish versioned endpoints and migration guides. Bad ones just break you.
To avoid surprises:
- Pin your CocoaPods or Swift Package Manager dependencies to a known-good version.
- Track API versions on your backend and roll out changes behind feature flags.
- Monitor deprecation notices; most vendors give 6–12 months’ warning.
Firebase, for example, is a widely used case where developers rely on analytics, remote config, and push notifications in iOS apps. Firebase’s release notes and versioning strategy are a live example of how to manage constant SDK evolution.
5. More real examples: analytics, auth, and notifications
Beyond the core examples of integrating third-party APIs in iOS: 3 examples we’ve focused on, most production apps layer in several more services.
Some additional real examples include:
- Firebase Analytics for event tracking and funnels, often replacing or augmenting Apple’s own analytics.
- Auth0 or AWS Cognito for authentication, especially when you need social logins, enterprise SSO, or multi-tenant setups.
- OneSignal or Firebase Cloud Messaging (FCM) as a push notification orchestration layer, sitting on top of Apple Push Notification service (APNs).
- Sentry or Firebase Crashlytics for crash reporting and performance metrics.
Taken together, these show that modern iOS apps are rarely “just” Swift and UIKit/SwiftUI. They’re orchestrations of multiple third-party APIs, each with its own SDK, rate limits, and failure modes.
6. Putting it all together in 2024–2025
In 2024–2025, the best examples of integrating third-party APIs in iOS share a few traits:
- They use Swift Concurrency pervasively for readability and performance.
- They avoid leaking third-party concepts everywhere in the codebase; integrations are wrapped in small, testable services.
- They respect user privacy and local regulations, especially around payments, location, and health data.
If you’re looking for a practical path forward:
- Start with one integration—payments, maps, or AI—using the patterns above.
- Build a tiny service layer around the SDK or REST API.
- Write one or two integration tests that hit a sandbox environment.
- Only then expand to additional third-party APIs.
Over time, your app will start to look a lot like the real examples we’ve covered: Stripe or RevenueCat for money, Mapbox or Google Maps for location, OpenAI or similar for AI features, and Firebase or Sentry for telemetry.
FAQ: Real examples of integrating third-party APIs in iOS
Q1. What are some real examples of integrating third-party APIs in iOS apps?
Real examples include using Stripe or Braintree for payments, Mapbox or Google Maps for mapping and routing, OpenAI for AI-powered chat or summarization, Firebase for analytics and push notifications, and RevenueCat for managing in‑app subscriptions.
Q2. Can you give an example of integrating Stripe into an iOS app?
Yes. A typical example of integrating Stripe in iOS uses the Stripe iOS SDK for collecting card details or Apple Pay, while your backend creates and confirms PaymentIntents using Stripe’s REST API. The app never stores raw card numbers, and the backend handles all secret keys and server-side validation.
Q3. What are the best examples of safe API key handling in iOS?
The best examples store long-lived keys on a server, not in the app. The iOS client authenticates with your backend, which then talks to third-party APIs like OpenAI, Mapbox, or Stripe. If you must embed a key (for example, a restricted Maps key), you scope it tightly and rotate it regularly.
Q4. Are there examples of integrating third-party APIs in iOS without using vendor SDKs?
Absolutely. Many teams call third-party REST APIs directly with URLSession instead of pulling in a heavy SDK. OpenAI, some mapping services, and custom analytics endpoints are common examples of this pattern.
Q5. How do I choose between different third-party APIs for the same feature?
Look at pricing, SDK maintenance, feature set, and how well the API fits your architecture. For payments, compare Stripe vs. Braintree vs. in‑app purchases. For maps, compare Mapbox vs. Google Maps vs. MapKit. The strongest choice is usually the one that balances cost, reliability, and how easily you can swap it out later if you need to.
Related Topics
Best examples of travel app API usage examples for modern mobile apps
Practical examples of handling API responses in mobile apps
Best examples of using social media APIs to share content in mobile apps
The best examples of integrating third-party APIs in iOS: 3 examples that actually ship
Real-world examples of integrating payment gateways API in mobile apps
Explore More Using APIs in Mobile Applications
Discover more examples and insights in this category.
View All Using APIs in Mobile Applications