OpenFisca package that model Spain legislation from Barcelona point of view
Switch branches/tags
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Type Name Latest commit message Commit time
Failed to load latest commit information.

OpenFisca Barcelona


OpenFisca package that model Spain legislation from Barcelona point of view. This project is intended to be used as a simulator to determine which benefits can be opted by a person or family.

As domain language Catalan has been choosen as all project documentation and team uses this language. We use English in all non domain specific documentation to enable collaboration with other openfisca teams and developers in general.


We recommend that you use a virtualenv:

virtualenv ${HOME}/.virtualenvs/openfisca-barcelona/

and activate it (You will need to do this every time you work with openfisca):

. ~/.virtualenvs/openfisca-barcelona/bin/activate

to install OpenFisca. If you don't, you may need to add --user at the end of all commands starting by pip.

To install your country package, run:

pip install -e ".[test]"

You can make sure that everything is working by running the provided tests:

make test

Learn more about tests

Serving with the OpenFisca web API

You can plug the OpenFisca web api to your country package.

First, install the OpenFisca web API:

pip install -e '.[api]'

Then run:

make run

You can make sure that the api is working by requesting:

curl "http://localhost:2000/api/2/formula/edat?data_naixement=1978-01-15"

A more complex example, create this file:

  "output_format": "variables",
  "scenarios": [
      "test_case": {
        "families": [
            "adults": ["pare1"],
			"menors": ["infant1"]
        "persones": [
            "id": "pare1",
            "data_naixement": "1961-01-15",
            "ingressos_bruts": "7000",
            "es_usuari_serveis_socials": true,
            "ciutat_empadronament": "Barcelona"
            "id": "infant1",
            "data_naixement": "2002-01-15",
            "es_usuari_serveis_socials": true,
            "ciutat_empadronament": "Barcelona"
      "period": "2017-1"
  "variables": ["AE_230_mensual"]

and run:

curl http://localhost:2000/api/1/calculate -X POST --data @./the_file_you_created.json --header 'Content-type: application/json'

Learn more about the API