This directory contains comprehensive examples demonstrating how to use RAWGKit.
Demonstrates fundamental operations:
- Client initialization
- Fetching games and game details
- Searching for games
- Fetching game content (screenshots, videos, achievements)
- Fetching resources (genres, platforms, stores)
- Error handling
- Cache management
Shows advanced query capabilities:
- Fluent query builder
- Type-safe filtering (platforms, genres, stores)
- Date range filtering
- Metacritic score filtering
- Combining multiple filters
- Exact search
- Various ordering options
Covers AsyncSequence features:
- Streaming large result sets with automatic pagination
- Early termination
- Task cancellation
- Collecting and processing results
- Concurrent operations with async sequences
All examples require a valid RAWG API key. Get yours at https://rawg.io/apidocs.
Replace "your-api-key" with your actual API key in any example.
- Add RAWGKit as a dependency
- Copy any example file to your project
- Call the example functions from your code
import RAWGKit
Task {
do {
try await fetchPopularGames()
} catch {
print("Error: \(error)")
}
}- Create a new Swift Playground
- Import RAWGKit
- Copy and paste any example
- Run the playground
swift run --package-path /path/to/RAWGKitlet client = RAWGClient(apiKey: "your-api-key")let games = try await client.fetchGames(pageSize: 10)let results = try await client.fetchGames(search: "zelda")let response = try await client.gamesQuery()
.search("witcher")
.orderByRating()
.year(2015)
.execute(with: client)for try await game in client.allGames(search: "minecraft") {
print(game.name)
}- Main README - Full documentation
- Contributing Guide - How to contribute
- API Documentation - RAWG API reference