Skip to content

ThomasG51/PokeAPIService

Repository files navigation

PokeAPIService

This Swift package provides a comprehensive and efficient solution for accessing and utilizing data related to Pokemon from the PokeAPI. It simplifies the process of fetching, parsing, and managing Pokemon information within your iOS applications.

swift xcode-version github actions

⚠️
As the package is still in development phase, not all PokeAPI resources are available yet
Please check-out the resources by category section.

Installation

Swift Package Manager

.package(url: "https://github.com/ThomasG51/PokeAPIService", from: "<version>")

Xcode Package Dependency

https://github.com/ThomasG51/PokeAPIService

How to use ?

A core strength of this package is its ability to seamlessly fetch data directly from each model. Each Pokemon, Pokedex, Generation or other can initiate a request to PokeAPI and populate its properties.

⚠️ Please note that due to restrictions by the underlying API, some models do not have acces to all fetching functions. Refer to the specific model documentation for more details.

Examples:

Fetch one object by ID

let pokemonID = 1
Pokemon.selectOne(by: pokemonID)

let generationID = 1
Generation.selectOne(by: generationID)

let pokedexID = 1
Pokedex.selectOne(by: pokedexID)

let versionID = 1
Version.selectOne(by: versionID)

Fetch one object by name

let pokemonName = "bulbasaur"
Pokemon.selectOne(by: pokemonName)

let generationName = "generation-i"
Generation.selectOne(by: generationName)

let pokedexName = "kanto"
Pokedex.selectOne(by: pokedexName)

let versionName = "red"
Version.selectOne(by: versionName)

Fetch a list of objects

Pokemon.selectAll(from: 151, count: 100)

Generation.selectAll() // Without count argument, the list will be paginate by 20 by default

Pokedex.selectAll(count: 3)

Version.selectAll(from: 0, count: 1)

Fetch a list of light resources (only id, name and type)

Pokemon.lightResources(from: 0, count: 151)

Generation.lightResources(from: 0, count: 1)

Pokedex.lightResources(from: 1, count: 1)

Version.lightResources(from: 0, count: 4)

Resources by category

Berries

  • Berry
  • BerryFirmness
  • BerryFlavor

Games

  • Generation
  • Pokedex
  • Version
  • VersionGroup

Pokemon

  • Ability
  • Characteristic
  • EggGroup
  • Gender
  • GrowthRate
  • Nature
  • PokeathlonStat
  • Pokemon
  • PokemonColor
  • PokemonLocationArea
  • PokemonForm
  • PokemonHabitat
  • PokemonShape
  • PokemonSpecies
  • PokemonType
  • Stat

License

PokeAPIService is available under the MIT license.

About

a package to use PokeAPI in Swift

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Contributors

Languages