Using the web API

Using the web API / Application building

(Rules as Code + OpenFisca) training series, session four.

OpenFisca API

Simple input/output API design

Not suitable for large scale simulations

Documentation:
http://openfisca.org/doc/openfisca-web-api/index.html

API Documentation

Supports OpenAPI specification, endpoint at '/spec', examples:

http://api.demo.openfisca.org/latest/spec

https://openfisca-aotearoa.synco.pt/spec

API and Swagger

Example:

http://legislation.demo.openfisca.org/swagger

Example API Calls

A collection of calls is explorable in the OpenFisca Aotearoa instance

https://github.com/BetterRules/openfisca-aotearoa/tree/master/openfisca_aotearoa/api_examples

Application Planning

Planning: divide inputs into:

  • Computable
    - "we know their birthdate so we can compute their age"
  • Already known
    - "this application is only applicable to citizens"
  • User answers required
    - "we need to know how much they've earned this week"
Application cont.

Minimise the number of questions required.

  • Create question logic trees
    - "we only ask their income if they have a job"
    - this is often in tension with:
  • If they answer this question first we can exit
    - and/or:
  • We have these 5 essential opening questions
Application cont.

How much can we inform without questions?.

  • "If you earn more than $120k you are not eligible"
  • "Here is a table of all the possible results"
  • "We will be asking these 5 essential opening questions"
Application cont.

Mapping questions/answers to OpenFisca variables

  • This question answers which inputs
    - question asking is difficult, try to match context and legal terminology
  • This result for variable X can be used in variable Y
  • We need this group of answers to compute this variable

Hotkeys

  • f: full screen

  • s: speaker notes

  • b: pause

  • / / space: navigate through slides

  • cltr / alt + click to zoom