Giter Site home page Giter Site logo

fsharp-swapi's Introduction

F# Swapi

F# wrapper for swapi.co.

Installation

To use fsharp-swapi, you'll need to get the F# Data library.

To use 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.Data and fsharp-swapi from your F# code.

#r "packages/FSharp.Data/lib/net40/FSharp.Data.dll"
#load "swapi.fs"
open StarWars.API

File 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 id returns information on a given person.
  • getPlanet id returns information about a planet.
  • getFilm id returns information about a film.
  • getSpecies id gives information about a species.
  • getVehicle id gives information about a vehicle.
  • getStarship id returns 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:

swapi.gif

Downloading all information

To download all items available for each resource in swapi.co, you can run the following functions:

  • getAllPeople()
  • getAllPlanets()
  • getAllFilms()
  • getAllSpecies()
  • getAllVehicles()
  • getAllStarships()

The library is heavily based on F# JSON type providers.

fsharp-swapi's People

Contributors

evelinag avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.