This is an alternative site for discovering Elm packages. You may be looking for the official Elm package site instead.
1.0.0
Wrapper for Pokeapi
version 1.0.1
license BSD3
native-modules False
elm-version 0.18.0 <= v < 0.19.0
Tag 1.0.1
Committed At 2018-02-22 05:28:48 UTC
elm-lang/http 1.0.0 <= v < 2.0.0 1.0.0
elm-lang/html 2.0.0 <= v < 3.0.0 2.0.0
elm-lang/core 5.1.1 <= v < 6.0.0 5.1.1
NoRedInk/elm-decode-pipeline 3.0.0 <= v < 4.0.0 3.0.1

README

Pokéapi Wrapper for Elm

Build Status

Documentation

API documentation regarding Pokéapi can be found here

GitHub: https://github.com/PokeAPI/pokeapi

About

This project came about because I just wanted a fun project to create an elm package. The goal of this package is to provide type-safety to the official Pokeapi. Hope someone finds it fun/useful! :smiley:

Usage

There are 2 different kinds of endpoints: lists and single resources. For more example usages, check out the examples directory.

Lists

A basic list endpoint to grab pokemon.

getResourceList Pokemon_ (onPage 1)

Retrieving a list with a custom limit of items per page.

getResourceList Berry_ (onPageOfSize 1 100)

Single Resources

A basic single resource endpoint to grab a pokemon by name

getPokemonBy (nameOf "pikachu")

A basic single resource endpoint to grab a pokemon by id

getPokemonBy (idOf 23)

Chaining Tasks

Due to leveraging Task, chaining HTTP requests is made simpler

getBerryBy (nameOf "pecha")
    |> Task.andThen (\berry -> getBerryFirmnessBy (urlOf berry.firmness.url))

Errors

If there is some reason you need to handle for a not found status specifically, the Pokeapi provides a model and there is a decoder. You can look at the NotFound.elm file in the examples/ directory to see how handling it works with this package.

Library vs API

This library takes some freedoms to make the library more pleasurable and is not a 1-to-1 match to the PokeApi. Any inconsistencies will be listed here to be explicit.

  • ApiResource: Matches PokeApi's ApiResource and NamedApiResource
  • ApiResourceList: Matches PokeApi's ApiResourceList and NamedApiResourceList

Note The official Pokeapi documentation on various models is inconsistent with the actual models returned by the API, so there could be a situation where you see the official documentation tell you a field is of one type only to find it be inconsistent in this package. A goal of this package is to be more up-to-date than the official documentation because this has something the documentation doesn't have: type safety. Elm :sunglasses: