SDS P4 API

<back to all web services

UsageReading

Get usagereading

The following routes are available for this service:
GET/api/v5/meteringpoints/{Ean}/usagereading/{Aggregation}/{DateFrom}Get usage/reading of a single asset with the selected aggregation starting from DateFrom
GET/api/v5/meteringpoints/{Ean}/usagereading/{Aggregation}/{DateFrom}/{DateTo}Get usage/reading of a single asset with the selected aggregation and period
import Foundation
import ServiceStack

/**
* Get usagereading
*/
// @Api(Description="Get usagereading")
public class UsageReading : Generic
{
    /**
    * Request of details of specific meteringpoint with Ean
    */
    // @ApiMember(DataType="EAN (18 numbers)", Description="Request of details of specific meteringpoint with Ean", Name="Ean")
    public var ean:String

    /**
    * 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
    */
    // @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", IsRequired=true, Name="Aggregation")
    public var aggregation:AggregationForAPI

    /**
    * Start date the usages are requested for
    */
    // @ApiMember(DataType="Date: yyyy-mm-dd", Description="Start date the usages are requested for", IsRequired=true, Name="DateFrom")
    public var dateFrom:Date

    /**
    * 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="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. ", Name="DateTo")
    public var dateTo:Date?

    /**
    * The output can be generated in a few formats. UsageReturnCombined: return values will be subtracted from the usage, UsageReturn: separate columns form usage and return (if available) and UsageReturnAndTariff: for both usage and return a column for tariff1 and tariff2. Default value: UsageReturnCombined
    */
    // @ApiMember(DataType="Enum", Description="The output can be generated in a few formats. UsageReturnCombined: return values will be subtracted from the usage, UsageReturn: separate columns form usage and return (if available) and UsageReturnAndTariff: for both usage and return a column for tariff1 and tariff2. Default value: UsageReturnCombined", Name="PayloadFormat")
    public var payloadFormat:PayloadFormat

    /**
    * See filter. Usages are available from the Detail channel. Default value: Detail
    */
    // @ApiMember(DataType="Enum", Description="See filter. Usages are available from the Detail channel. Default value: Detail", Name="Source")
    public var source:MeasurementSource

    /**
    * Add column with Dutch day (Default: false)
    */
    // @ApiMember(DataType="Boolean", Description="Add column with Dutch day (Default: false)", Name="AddDateNL")
    public var addDateNL:Bool

    /**
    * Add columns with CreatedOn and LastUpdated (Default: false)
    */
    // @ApiMember(DataType="Boolean", Description="Add columns with CreatedOn and LastUpdated (Default: false)", Name="AddTimestamps")
    public var addTimestamps:Bool

    /**
    * Add column with ean (Default: false)
    */
    // @ApiMember(DataType="Boolean", Description="Add column with ean (Default: false)", Name="AddEan")
    public var addEan:Bool

    /**
    * Create a row for each register instead of a column/field for each register (Default: false)
    */
    // @ApiMember(DataType="Boolean", Description="Create a row for each register instead of a column/field for each register (Default: false)", Name="RegistersInRows")
    public var registersInRows:Bool

    /**
    * Gridoperator doesn't provided tariff information for the detail channel, but this can be calculated (Default: false)
    */
    // @ApiMember(DataType="Boolean", Description="Gridoperator doesn't provided tariff information for the detail channel, but this can be calculated (Default: false)", Name="CalculateDetailTariff")
    public var calculateDetailTariff:Bool

    /**
    * If want to get the reading as well with the usages
    */
    // @ApiMember(DataType="Boolean", Description="If want to get the reading as well with the usages", Name="AlsoReading")
    public var alsoReading:Bool

    /**
    * CacheKey used for Internal logic
    */
    // @ApiMember(Description="CacheKey used for Internal logic", Name="CacheKey")
    public var cacheKey:String

    required public init(){ super.init() }

    private enum CodingKeys : String, CodingKey {
        case ean
        case aggregation
        case dateFrom
        case dateTo
        case payloadFormat
        case source
        case addDateNL
        case addTimestamps
        case addEan
        case registersInRows
        case calculateDetailTariff
        case alsoReading
        case cacheKey
    }

    required public init(from decoder: Decoder) throws {
        try super.init(from: decoder)
        let container = try decoder.container(keyedBy: CodingKeys.self)
        ean = try container.decodeIfPresent(String.self, forKey: .ean)
        aggregation = try container.decodeIfPresent(AggregationForAPI.self, forKey: .aggregation)
        dateFrom = try container.decodeIfPresent(Date.self, forKey: .dateFrom)
        dateTo = try container.decodeIfPresent(Date.self, forKey: .dateTo)
        payloadFormat = try container.decodeIfPresent(PayloadFormat.self, forKey: .payloadFormat)
        source = try container.decodeIfPresent(MeasurementSource.self, forKey: .source)
        addDateNL = try container.decodeIfPresent(Bool.self, forKey: .addDateNL)
        addTimestamps = try container.decodeIfPresent(Bool.self, forKey: .addTimestamps)
        addEan = try container.decodeIfPresent(Bool.self, forKey: .addEan)
        registersInRows = try container.decodeIfPresent(Bool.self, forKey: .registersInRows)
        calculateDetailTariff = try container.decodeIfPresent(Bool.self, forKey: .calculateDetailTariff)
        alsoReading = try container.decodeIfPresent(Bool.self, forKey: .alsoReading)
        cacheKey = try container.decodeIfPresent(String.self, forKey: .cacheKey)
    }

    public override func encode(to encoder: Encoder) throws {
        try super.encode(to: encoder)
        var container = encoder.container(keyedBy: CodingKeys.self)
        if ean != nil { try container.encode(ean, forKey: .ean) }
        if aggregation != nil { try container.encode(aggregation, forKey: .aggregation) }
        if dateFrom != nil { try container.encode(dateFrom, forKey: .dateFrom) }
        if dateTo != nil { try container.encode(dateTo, forKey: .dateTo) }
        if payloadFormat != nil { try container.encode(payloadFormat, forKey: .payloadFormat) }
        if source != nil { try container.encode(source, forKey: .source) }
        if addDateNL != nil { try container.encode(addDateNL, forKey: .addDateNL) }
        if addTimestamps != nil { try container.encode(addTimestamps, forKey: .addTimestamps) }
        if addEan != nil { try container.encode(addEan, forKey: .addEan) }
        if registersInRows != nil { try container.encode(registersInRows, forKey: .registersInRows) }
        if calculateDetailTariff != nil { try container.encode(calculateDetailTariff, forKey: .calculateDetailTariff) }
        if alsoReading != nil { try container.encode(alsoReading, forKey: .alsoReading) }
        if cacheKey != nil { try container.encode(cacheKey, forKey: .cacheKey) }
    }
}

public class Generic : Codable
{
    /**
    * Api-key. Used to provide credentials to the api. Can also be provided through the request headers with key: X-API-KEY
    */
    // @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")
    public var apiKey:String

    /**
    * 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="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")
    public var onlyPayload:Bool

    /**
    * 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="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")
    public var showRequest:Bool

    /**
    * 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
    */
    // @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")
    public var dateTimeFormat:DateTimeFormat

    required public init(){}
}

public enum DateTimeFormat : String, Codable
{
    case ISO8601
    case UTC
    case NL
    case NLOffset
    case IN
    case INOffset
    case Unix
    case UnixMillis
}

public enum AggregationForAPI : String, Codable
{
    case None
    case Hour
    case Day
    case Week
    case Month
    case Year
}

public enum PayloadFormat : String, Codable
{
    case UsageReturnCombined
    case UsageReturn
    case UsageReturnAndTariff
}

public enum MeasurementSource : String, Codable
{
    case Detail
    case Day
    case Month
    case Unknown
}


Swift UsageReading DTOs

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

To embed the response in a jsonp callback, append ?callback=myCallback

HTTP + JSON

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

GET /api/v5/meteringpoints/{Ean}/usagereading/{Aggregation}/{DateFrom} HTTP/1.1 
Host: p4v8.smartdatasolutions.nl 
Accept: application/json