SDS P4 API

<back to all web services

Graph

Get data for graph, usages and some statistical information

The following routes are available for this service:
GET/api/v6/meteringpoints/{Ean}/graph/{Aggregation}/{DateFrom}/{DateTo}Get usages based on aggregation starting from DateFrom to endDate
import datetime
import decimal
from marshmallow.fields import *
from servicestack import *
from typing import *
from dataclasses import dataclass, field
from dataclasses_json import dataclass_json, LetterCase, Undefined, config
from enum import Enum, IntEnum


class DateTimeFormat(str, Enum):
    IS_O8601 = 'ISO8601'
    UTC = 'UTC'
    NL = 'NL'
    NL_OFFSET = 'NLOffset'
    IN_ = 'IN'
    IN_OFFSET = 'INOffset'
    UNIX = 'Unix'
    UNIX_MILLIS = 'UnixMillis'


@dataclass_json(letter_case=LetterCase.CAMEL, undefined=Undefined.EXCLUDE)
@dataclass
class Generic:
    # @ApiMember(DataType="String", Description="Api-key. Used to provide credentials to the api. Can also be provided through the request headers with key: X-API-KEY", IsRequired=true, Name="ApiKey")
    api_key: Optional[str] = None
    """
    Api-key. Used to provide credentials to the api. Can also be provided through the request headers with key: X-API-KEY
    """


    # @ApiMember(DataType="Boolean", Description="Normally the result of the request is put inside a resultobject with some status information about the request. If you want the output as csv this outer object can be irritating. Default value: FALSE ", Name="OnlyPayload")
    only_payload: bool = False
    """
    Normally the result of the request is put inside a resultobject with some status information about the request. If you want the output as csv this outer object can be irritating. Default value: FALSE 
    """


    # @ApiMember(DataType="Boolean", Description="Show the request as interpreted by the api. Useful to see how filters / dates are parsed. If no value us provided, the default value is: FALSE ", Name="ShowRequest")
    show_request: bool = False
    """
    Show the request as interpreted by the api. Useful to see how filters / dates are parsed. If no value us provided, the default value is: FALSE 
    """


    # @ApiMember(DataType="Enum", Description="Format all DateTime in the response object. If used in browser, sometimes ISO8601 is not correctly transformed. Enum options: ISO8601 (DEFAULT), UTC, NL, NLOffset, Unix, UnixMillis", Name="DateTimeFormat")
    date_time_format: Optional[DateTimeFormat] = None
    """
    Format all DateTime in the response object. If used in browser, sometimes ISO8601 is not correctly transformed. Enum options: ISO8601 (DEFAULT), UTC, NL, NLOffset, Unix, UnixMillis
    """


class AggregationForAPI(str, Enum):
    NONE = 'None'
    HOUR = 'Hour'
    DAY = 'Day'
    WEEK = 'Week'
    MONTH = 'Month'
    YEAR = 'Year'


# @Api(Description="Get data for graph, usages and some statistical information")
@dataclass_json(letter_case=LetterCase.CAMEL, undefined=Undefined.EXCLUDE)
@dataclass
class Graph(Generic):
    """
    Get data for graph, usages and some statistical information
    """

    # @ApiMember(DataType="EAN (18 numbers)", Description="Request of details of specific meteringpoint with Ean", IsRequired=true, Name="Ean")
    ean: Optional[str] = None
    """
    Request of details of specific meteringpoint with Ean
    """


    # @ApiMember(DataType="Enum", Description="Aggregation level. The None-'level' will give the most detailed level available for the requested asset. If a level is requested that is not available or can be calculate, no data is returned. Enum options: None, Hour, Day, Week, Month", IsRequired=true, Name="Aggregation")
    aggregation: Optional[AggregationForAPI] = None
    """
    Aggregation level. The None-'level' will give the most detailed level available for the requested asset. If a level is requested that is not available or can be calculate, no data is returned. Enum options: None, Hour, Day, Week, Month
    """


    # @ApiMember(DataType="Date: yyyy-mm-dd", Description="Start date the usages are requested for", IsRequired=true, Name="DateFrom")
    date_from: datetime.datetime = datetime.datetime(1, 1, 1)
    """
    Start date the usages are requested for
    """


    # @ApiMember(DataType="Date: yyyy-mm-dd", Description="End date the usages are requested for (this is included in the response). If no date is provided the DateTo will seven days from the DateFrom. ", IsRequired=true, Name="DateTo")
    date_to: datetime.datetime = datetime.datetime(1, 1, 1)
    """
    End date the usages are requested for (this is included in the response). If no date is provided the DateTo will seven days from the DateFrom. 
    """


    # @ApiMember(DataType="Boolean", Description="calculate the usage of that period and divide it over the missing hours or 15 minute periods, but this can be calculated (Default: false)", Name="CalculateMissingUsages")
    calculate_missing_usages: bool = False
    """
    calculate the usage of that period and divide it over the missing hours or 15 minute periods, but this can be calculated (Default: false)
    """

Python Graph DTOs

To override the Content-type in your clients, use the HTTP Accept Header, append the .other suffix or ?format=other

HTTP + OTHER

The following are sample HTTP requests and responses. The placeholders shown need to be replaced with actual values.

GET /api/v6/meteringpoints/{Ean}/graph/{Aggregation}/{DateFrom}/{DateTo} HTTP/1.1 
Host: p4v8.smartdatasolutions.nl 
Accept: text/jsonl