F# wrapper for swapi.co.
fsharp-swapi, you'll need to get the F# Data library.
fsharp-swapi, simply reference the
swapi.fs file from your solution. You can also add the file using the paket dependency manager by adding the following line into your paket.dependencies file:
github evelinag/fsharp-swapi swapi.fs
See paket documentation for more details on referencing Github dependencies. See paket documentation for more details on referencing Github dependencies.
Using F# Swapi
To use the library, reference
fsharp-swapi from your F# code.
#r "packages/FSharp.Data/lib/net40/FSharp.Data.dll" #load "swapi.fs" open StarWars.API
examples.fsx contains "practical" examples of usage. Head there if you're interested in the average height of a Star Wars character, or if you want to know which eye colour is the most common.
Accessing individual resources
In swapi.co, each resource is available through its ID number. To access each resource based on the ID, call the following functions:
getPerson idreturns information on a given person.
getPlanet idreturns information about a planet.
getFilm idreturns information about a film.
getSpecies idgives information about a species.
getVehicle idgives information about a vehicle.
getStarship idreturns information about a specific starship.
All the functions use the F# JSON type providers. You can access all the information they return using the dot:
Downloading all information
To download all items available for each resource in swapi.co, you can run the following functions:
The library is heavily based on F# JSON type providers.