Skip to content

Latest commit

 

History

History
507 lines (465 loc) · 12 KB

README.md

File metadata and controls

507 lines (465 loc) · 12 KB

Héichwaasser API

This uses the Measured water levels and creates a history and a JSON Api.

This API is also published on data.public.lu.

Documentation

Important notice: The time is given in Western European Time all year, the European Summer Time is not considered. You may have to adapt the time to your needs.

Root

https://heichwaasser.lu/api/v1

Endpoints

Rivers

[
    {
        "id": 17,
        "name": "Alzette",
        "stations": [
            {
                "id": 61,
                "city": "Ettelbr\u00fcck",
                "latitude": 49.84373,
                "longitude": 6.09713,
                "trend": "rest",
                "current": {
                    "timestamp": "2017-12-27T16:45:00",
                    "value": 69.8,
                    "unit": "cm"
                },
                "minimum": {
                    "timestamp": "2017-12-27T15:30:00",
                    "value": 65.5,
                    "unit": "cm"
                },
                "maximum": {
                    "timestamp": "2017-12-27T16:45:00",
                    "value": 69.8,
                    "unit": "cm"
                },
                "alert_levels": [
                    {
                        "name": "Level 1",
                        "value": 180,
                        "unit": "cm"
                    },
                    {
                        "name": "Level 2",
                        "value": 230,
                        "unit": "cm"
                    }
                ]
            },...
        ]
    }
]
[
    {
        "id": 17,
        "name": "Alzette",
        "stations": [
            {
                "id": 61,
                "city": "Ettelbr\u00fcck",
                "latitude": 49.84373,
                "longitude": 6.09713,
                "trend": "rest",
                "current": {
                    "timestamp": "2017-12-27T16:45:00",
                    "value": 69.8,
                    "unit": "cm"
                },
                "minimum": {
                    "timestamp": "2017-12-27T15:30:00",
                    "value": 65.5,
                    "unit": "cm"
                },
                "maximum": {
                    "timestamp": "2017-12-27T16:45:00",
                    "value": 69.8,
                    "unit": "cm"
                },
                "alert_levels": [
                    {
                        "name": "Level 1",
                        "value": 180,
                        "unit": "cm"
                    },
                    {
                        "name": "Level 2",
                        "value": 230,
                        "unit": "cm"
                    }
                ]
            },...
        ]
    }
]

Stations

[
    {
        "id": 81,
        "river": {
            "id": 3,
            "name": "S\u00fbre"
        },
        "city": "Bigonville",
        "latitude": 49.86875,
        "longitude": 5.79996,
        "trend": "rest",
        "current": {
            "timestamp": "2017-12-27T16:45:00",
            "value": 108.2,
            "unit": "cm"
        },
        "minimum": {
            "timestamp": "2017-12-27T16:45:00",
            "value": 108.2,
            "unit": "cm"
        },
        "maximum": {
            "timestamp": "2017-12-27T16:45:00",
            "value": 108.2,
            "unit": "cm"
        },
        "alert_levels": [
            {
                "name": "Level 1",
                "value": 250,
                "unit": "cm"
            },
            {
                "name": "Level 2",
                "value": 300,
                "unit": "cm"
            }
        ]
    },...
]

The measurements are displayed in a descending order.

{
    "id": 81,
    "river": {
        "id": 3,
        "name": "S\u00fbre"
    },
    "city": "Bigonville",
    "latitude": 49.86875,
    "longitude": 5.79996,
    "trend": "rest",
    "current": {
        "timestamp": "2017-12-27T16:45:00",
        "value": 108.2,
        "unit": "cm"
    },
    "minimum": {
        "timestamp": "2017-12-27T16:45:00",
        "value": 108.2,
        "unit": "cm"
    },
    "maximum": {
        "timestamp": "2017-12-27T16:45:00",
        "value": 108.2,
        "unit": "cm"
    },
    "measurements": [
        {
            "timestamp": "2017-12-27T16:45:00",
            "value": 108.2,
            "unit": "cm"
        },..
    ],
    "alert_levels": [
        {
            "name": "Level 1",
            "value": 250,
            "unit": "cm"
        },
        {
            "name": "Level 2",
            "value": 300,
            "unit": "cm"
        }
    ]
}

The measurements are displayed in an ascending order.

{
    "id": 81,
    "river": {
        "id": 3,
        "name": "S\u00fbre"
    },
    "city": "Bigonville",
    "latitude": 49.86875,
    "longitude": 5.79996,
    "trend": "rest",
    "current": {
        "timestamp": "2017-12-27T16:45:00",
        "value": 108.2,
        "unit": "cm"
    },
    "minimum": {
        "timestamp": "2017-12-27T16:45:00",
        "value": 108.2,
        "unit": "cm"
    },
    "maximum": {
        "timestamp": "2017-12-27T16:45:00",
        "value": 108.2,
        "unit": "cm"
    },
    "measurements": [
        {
            "timestamp": "2017-12-27T16:45:00",
            "value": 108.2,
            "unit": "cm"
        },..
    ],
    "alert_levels": [
        {
            "name": "Level 1",
            "value": 250,
            "unit": "cm"
        },
        {
            "name": "Level 2",
            "value": 300,
            "unit": "cm"
        }
    ]
}

The measurements are displayed in a descending order and limited to :count items.

{
    "id": 81,
    "river": {
        "id": 3,
        "name": "S\u00fbre"
    },
    "city": "Bigonville",
    "latitude": 49.86875,
    "longitude": 5.79996,
    "trend": "rest",
    "current": {
        "timestamp": "2017-12-27T16:45:00",
        "value": 108.2,
        "unit": "cm"
    },
    "minimum": {
        "timestamp": "2017-12-27T16:45:00",
        "value": 108.2,
        "unit": "cm"
    },
    "maximum": {
        "timestamp": "2017-12-27T16:45:00",
        "value": 108.2,
        "unit": "cm"
    },
    "measurements": [
        {
            "timestamp": "2017-12-27T16:45:00",
            "value": 108.2,
            "unit": "cm"
        },..
    ],
    "alert_levels": [
        {
            "name": "Level 1",
            "value": 250,
            "unit": "cm"
        },
        {
            "name": "Level 2",
            "value": 300,
            "unit": "cm"
        }
    ]
}

The measurements are displayed in an ascending order and limited to :count items.

{
    "id": 81,
    "river": {
        "id": 3,
        "name": "S\u00fbre"
    },
    "city": "Bigonville",
    "latitude": 49.86875,
    "longitude": 5.79996,
    "trend": "rest",
    "current": {
        "timestamp": "2017-12-27T16:45:00",
        "value": 108.2,
        "unit": "cm"
    },
    "minimum": {
        "timestamp": "2017-12-27T16:45:00",
        "value": 108.2,
        "unit": "cm"
    },
    "maximum": {
        "timestamp": "2017-12-27T16:45:00",
        "value": 108.2,
        "unit": "cm"
    },
    "measurements": [
        {
            "timestamp": "2017-12-27T16:45:00",
            "value": 108.2,
            "unit": "cm"
        },..
    ],
    "alert_levels": [
        {
            "name": "Level 1",
            "value": 250,
            "unit": "cm"
        },
        {
            "name": "Level 2",
            "value": 300,
            "unit": "cm"
        }
    ]
}

The returned measurements are strictly greater than the start timestamp and strictly smaller than the end timestamp.

The measurements are displayed in a descending order.

:timestamp must be provided as UNIX timestamp in seconds since Jan 01 1970.

{
    "id": 81,
    "river": {
        "id": 3,
        "name": "S\u00fbre"
    },
    "city": "Bigonville",
    "latitude": 49.86875,
    "longitude": 5.79996,
    "trend": "rest",
    "current": {
        "timestamp": "2017-12-27T16:45:00",
        "value": 108.2,
        "unit": "cm"
    },
    "minimum": {
        "timestamp": "2017-12-27T16:45:00",
        "value": 108.2,
        "unit": "cm"
    },
    "maximum": {
        "timestamp": "2017-12-27T16:45:00",
        "value": 108.2,
        "unit": "cm"
    },
    "measurements": [
        {
            "timestamp": "2017-12-20T00:15:00",
            "value": 133.6,
            "unit": "cm"
        },..
    ],
    "alert_levels": [
        {
            "name": "Level 1",
            "value": 250,
            "unit": "cm"
        },
        {
            "name": "Level 2",
            "value": 300,
            "unit": "cm"
        }
    ]
}

The returned measurements are strictly greater than the start timestamp and strictly smaller than the end timestamp.

The measurements are displayed in an ascending order.

:timestamp must be provided as UNIX timestamp in seconds since Jan 01 1970.

{
    "id": 81,
    "river": {
        "id": 3,
        "name": "S\u00fbre"
    },
    "city": "Bigonville",
    "latitude": 49.86875,
    "longitude": 5.79996,
    "trend": "rest",
    "current": {
        "timestamp": "2017-12-27T16:45:00",
        "value": 108.2,
        "unit": "cm"
    },
    "minimum": {
        "timestamp": "2017-12-27T16:45:00",
        "value": 108.2,
        "unit": "cm"
    },
    "maximum": {
        "timestamp": "2017-12-27T16:45:00",
        "value": 108.2,
        "unit": "cm"
    },
    "measurements": [
        {
            "timestamp": "2017-12-20T00:15:00",
            "value": 133.6,
            "unit": "cm"
        },..
    ],
    "alert_levels": [
        {
            "name": "Level 1",
            "value": 250,
            "unit": "cm"
        },
        {
            "name": "Level 2",
            "value": 300,
            "unit": "cm"
        }
    ]
}
Explanation of "trend" field

On import the new water level is compared to the previous one, and the trend field is updated.

  • down new level < previous level
  • rest new level = previous level
  • up new level > previous level

Admin Interface

The Admin Interface located at <installed directory>/admin allows you to update the river and station names. You can also add and modify alert levels. Don't change the Shortname Field on River and Station classes, as this field is used on the import command to correctly map the new measurements.

Development

  • Install Composer.
  • Run composer install in the project's root.
  • Make sure you have a MariaDB/MySQL server running and run php bin/console doctrine:schema:update --force to initiate the database

If you want to access the /admin page, you have to set up a user:

  • Run bin/console fos:user:create and enter a username, email and password.
  • Run bin/console fos:user:promote [created username] ROLE_ADMIN to promote your user and enable access to \admin page.

License

Check out the LICENSE file.