/spaceapi

A small Elixir package for parsing the Space API

Primary LanguageElixir

SpaceApi

A small Elixir package for parsing the Space API

What?

This small piece of code parses the Space API for you into a nice format.

Installation

First, add SpaceApi to your mix.exs dependencies:

def deps do
  [{:spaceapi, "~> 0.1.1"}]
end

and run $ mix deps.get. That's it!

Usage

This example is fetching the Space API-JSON via HTTPoison which is not shipped within SpaceApi.

HTTPoison.start

resp = HTTPoison.get! "https://hsmr.cc/spaceapi.json"
hsmr = SpaceApi.from_string resp.body

"#{hsmr.space} is " <> case SpaceApi.Space.is_open? hsmr do
  true  -> "open ∩( ・ω・)∩"
  false -> "closed ;_;"
end

License

You are free to use this code under the MIT License or under the GPLv3.