A client for the Untappd API, written in Swift.
It was created during the Q42 hackathon w00tcamp for the Uncheckd app. Check it out!
- User authentication to Untappd using
ASWebAuthenticationSession
- Uses modern Swift concurrency (async/await)
- Response validation with error handling, including typed errors
- Request/response logging
A helper class UntappdAuthenticationSession
lets the user log in using their Untappd account.
A custom URL scheme must be defined by your app in order to receive the access token.
import Foundation
import UntappdKit
func signIn() async throws {
let presentationAnchor = await MainActor.run { UIWindow() }
let authProvider = await UntappdAuthenticationSession(
clientID: "...",
clientSecret: "...",
redirectURL: URL(string: "myapp://authenticate")!,
urlScheme: "myapp",
presentationAnchor: presentationAnchor
)
let token = try await authProvider.authenticate()
print("Received access token: \(token.accessToken)")
// Store token in the Keychain
}
The UntappdClient
is the main class for accessing the Untappd API.
The offset and limit, combined with the response.pagination
property may be used to fetch multiple pages of responses.
func fetchUserBeers() async throws {
let untappdClient = UntappdClient()
// Optionally set a delegate here to provide the user's access token to Untappd:
// untappdClient.delegate = self
let response: UserBeersResponse = try await untappdClient.userBeers(username: "Fubaruba", offset: 0, limit: 50)
print("Bram has \(response.totalCount) total beers checked in")
for beerItem in response.beers.items {
print("\(beerItem.beer.beerName) from \(beerItem.brewery.breweryName)")
print("has \(beerItem.beer.beerAbv)% ABV")
}
}
- Authentication
- Activity Feed
- User Activity Feed
- Venue Activity Feed
- Beer Activity Feed
- Brewery Activity Feed
- Notifications
- User Info
- User Wish List
- User Friends
- User Badges
- User Beers
- Brewery Info
- Beer Info
- Venue Info
- Beer Search
- Brewery Search
- Checkin
- Toast / Un-toast
- Pending Friends
- Add Friend
- Remove Friend
- Accept Friend
- Reject Friend
- Add Comment
- Remove Comment
- Add to Wish List
- Remove from Wish List
See the Untappd API docs for more info about the API calls.
Pull requests are welcome, especially for implementing more of the API. I used QuickType to quickly reverse-engineer the codable models.
- 28-11-2024: Initial open source release.
- 22-11-2024: Initial version for the w00tcamp project Uncheckd
MIT licensed, see LICENSE.md.