A local SQLite version of the PokeAPI database for Swift applications, built using StructuredQueries and GRDB.swift for type-safe database access.
This package provides a complete, offline-accessible Pokemon database with all the data from PokeAPI packaged as a Swift library. Perfect for iOS and macOS apps that need Pokemon data without network dependencies.
- 🗄️ Complete PokeAPI database in SQLite format
- 🔍 Type-safe database queries using StructuredQueries
- 📱 iOS 18+ and macOS 15+ support
- ⚡ Fast, offline access to Pokemon data
- 🧪 Comprehensive test suite with snapshot testing
- iOS 13.0+, macOS 10.15+, tvOS 13+, watchOS 7.0+
- Swift 6.1+
- Xcode 16.4+
Add this package to your project by adding the following to your Package.swift
:
dependencies: [
.package(url: "https://github.com/rjchatfield/swift-pokeapi-database", from: "0.1.0")
]
And then adding the following product to any target that needs access to the library:
.product(name: "PokeAPIDatabase", package: "swift-pokeapi-database"),
Or add it through Xcode:
- File → Add Package Dependencies
- Enter the repository URL
- Select the version you want to use
import PokeAPIDatabase
// Create a database connection
let database = try PokeAPIDatabase.makeDatabase()
// Query Pokemon data
let pikachu = try database.read { db in
try PokeAPIPokemon
.filter(Column("identifier") == "pikachu")
.fetchOne(db)
}
// Get all Pokemon from generation 1
let gen1Pokemon = try database.read { db in
try PokeAPIPokemon
.joining(required: PokeAPIPokemonSpecies.self)
.filter(PokeAPIPokemonSpecies.Columns.generationId == 1)
.fetchAll(db)
}
// Get Pokemon by type
let firePokemon = try database.read { db in
try PokeAPIPokemon
.joining(required: PokeAPIPokemonType.self)
.joining(required: PokeAPIType.self)
.filter(PokeAPIType.Columns.identifier == "fire")
.fetchAll(db)
}
The package includes complete models for all PokeAPI entities:
PokeAPIPokemon
- Individual Pokemon formsPokeAPIPokemonSpecies
- Base Pokemon species dataPokeAPIType
- Pokemon types (Fire, Water, etc.)PokeAPIMove
- Pokemon movesPokeAPIAbility
- Pokemon abilitiesPokeAPIItem
- Items and berriesPokeAPILocation
- Game locations- And many more...
# Build the package
swift build
# Run tests
swift test
This package contains data from the PokeAPI project. All Pokemon data is sourced from PokeAPI's comprehensive database.
Important: Pokemon and Pokemon character names are trademarks of Nintendo. This package is not affiliated with or endorsed by Nintendo, Game Freak, or The Pokemon Company.
We welcome contributions! Here's how you can help:
- Check existing issues before creating a new one
- Include Swift version, platform, and clear reproduction steps
- For database issues, specify which Pokemon/data is affected
- Follow existing code style and patterns
- Add tests for new functionality
- Ensure all tests pass with
swift test
- Update documentation as needed
Note: The Pokemon data comes directly from PokeAPI. If you find incorrect Pokemon data (stats, types, etc.), please report it to the PokeAPI project instead.
For issues with the Swift models or database schema, please create an issue here.
This project is licensed under the BSD 3-Clause License - see the LICENSE file for details.
The Pokemon data is provided by PokeAPI under their license terms. Pokemon and Pokemon character names are trademarks of Nintendo.