gorte

package module
v1.0.9 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Aug 15, 2022 License: Apache-2.0 Imports: 12 Imported by: 0

README

gorte

An RTE API client enabling Go programs to interact with RTE API in a simple and uniform way.

GitHub license GoDoc Go Report Card GitHub issues

Overview

RTE, the french electricity transmission system operator, provides access to various data through an API on its data portal. You can retrieve those data with gorte.

Installation

$ go get -u github.com/dhia-gharsallaoui/gorte

Quick Start

Add this import line to the file you're working in:

import "github.com/dhia-gharsallaoui/gorte"
Client Authentication

To access the API, you need to create an account, or login if you have one. Once logged, you can subscribe (create an application) to the desired API (each APIs must be subscribed individualy), you’ll obtain a base64 encoded key. Then to set up a client use the command

key:= "YmFiMWY3NjMtODhjZC00LWE5ZTgtOTRmMDc1ODcyYmNjOmU5YTIxNDVjLTBkOGUZi04YWI2LWRlNjRmODExM2M"
client, err := gorte.NewClient(gorte.ClientConfig{Key: key})

NB: the token generated with your key is only valid for two hours. So you need to recreated the client each two hours using the same key.

Usage

The package came with a useful struct called Period for calling API's with start date and end date configuration. this struct ensure the coding of the time in the suitable format.

layout := "2006-01-02 15:04"
st, err := time.Parse(layout, "2022-03-01 23:00")
if err != nil {
  fmt.Println(err)
  }
et, err := time.Parse(layout, "2022-03-09 13:00")
if err != nil {
  fmt.Println(err)
  }
opt := utils.Period{Time(st), Time(et)}

After preparing our configuration we can call an API from the available categories.

For exemple to get the "Peak Period" signals from 2022-03-01 23:00 to 2022-03-09 13:00.

signals, _, err := Client.Market.GetSignals(&opt)
Available APIs
Consumption
client.Consumption.GetAnnualForecasts(&opt)
client.Consumption.GetShortTerm(&opt)
client.Consumption.GetWeeklyForecasts(&opt)
client.Consumption.GetOperators(&opt)
client.Consumption.GetVolumes(&opt)
client.Consumption.GetQualityData(gorte.GetQualityDataOptions{
                ID:        0,
                StartDate: opt.StartDate,
                EndDate:   opt.EndDate,
                Type:      "RMS,RMS_VOLTAGE",
        })
client.Consumption.GetSignalEcowatt(&opt)
client.Consumption.GetTempoLikeCalendars(&opt)
Exchanges

Not implemented yet.

Generation
Market
client.Market.GetAcceptedOffers(&opt)
client.Market.GetAggregatedoffersAFRREnergybids(&opt)
client.Market.GetAggregatedoffersEnergybids(&opt)
client.Market.GetDailyProcuredReserves(&opt)
client.Market.GetImbalance(&opt)
client.Market.GetIndividualoffersEnergybids(&opt)
client.Market.GetInsufficientsOffers(&opt)
client.Market.GetMarginsData(&opt)
client.Market.GetNeeds(&opt)
client.Market.GetPeakDailyMargins(&opt)
client.Market.GetProcuredReservesResp(&opt)
client.Market.GetOperators(&opt)
client.Market.GetVolumes(&opt) 
Partners

Not implemented yet.

Enjoy Coding
package main

import (
        "fmt"
        "time"

        gorte "github.com/dhia-gharsallaoui/gorte"
        "github.com/dhia-gharsallaoui/gorte/utils"
)

func main() {
        key := "YmFiMWY3NjMtODhjZC00OTViLWE5ZTgtOtNDdhZi04YWI2LWRlNjRm=="
        client, err := gorte.NewClient(gorte.ClientConfig{Key: key})
        layout := "2006-01-02 15:04"
        st, err := time.Parse(layout, "2022-03-01 23:00")
        if err != nil {
                fmt.Println(err)
        }
        et, err := time.Parse(layout, "2022-03-09 13:00")
        if err != nil {
                fmt.Println(err)
        }
        opt := utils.Period{st, et}
        signals, _, err := client.Market.GetSignals(&opt)
        if err != nil {
                fmt.Println(err)
        } else {
                fmt.Println(signals)
        }
}


Todo

  • Tests
  • Add other RTE API

Issues

Sponsored by

Skilld

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func URLGenerator

func URLGenerator(ur *url.URL, path string) (*url.URL, error)

Types

type AcceptedOffersResp

type AcceptedOffersResp struct {
	AcceptedOffers []struct {
		StartDate time.Time `json:"start_date"`
		EndDate   time.Time `json:"end_date"`
		Type      string    `json:"type"`
		Values    []struct {
			StartDate   time.Time `json:"start_date"`
			EndDate     time.Time `json:"end_date"`
			Direction   string    `json:"direction"`
			Value       int       `json:"value"`
			UpdatedDate time.Time `json:"updated_date"`
		} `json:"values"`
	} `json:"accepted_offers"`
}

type AggregatedoffersAFRREnergybidsResp

type AggregatedoffersAFRREnergybidsResp struct {
	AggregatedoffersAFRREnergybids []struct {
		StartDate  time.Time `json:"start_date"`
		EndDate    time.Time `json:"end_date"`
		Chronicles []struct {
			StartDate time.Time `json:"start_date"`
			EndDate   time.Time `json:"end_date"`
			Values    struct {
				DownwardOfferedVolumeaFRR int     `json:"DownwardOfferedVolumeaFRR"`
				UpwardOfferedVolumeaFRR   int     `json:"UpwardOfferedVolumeaFRR"`
				DownwardSharedVolumeaFRR  int     `json:"DownwardSharedVolumeaFRR"`
				UpwardSharedVolumeaFRR    int     `json:"UpwardSharedVolumeaFRR"`
				DownwardAveragePriceaFRR  float64 `json:"DownwardAveragePriceaFRR"`
				UpwardAveragePriceaFRR    float64 `json:"UpwardAveragePriceaFRR"`
			} `json:"values"`
		} `json:"chronicles"`
	} `json:"aggregatedoffers_aFRR_energybids"`
}

type AggregatedoffersEnergybidsResp

type AggregatedoffersEnergybidsResp struct {
	AggregatedoffersEnergybids []struct {
		StartDate          time.Time `json:"start_date"`
		EndDate            time.Time `json:"end_date"`
		OfferedRRstdVolume []struct {
			StartDate time.Time `json:"start_date"`
			EndDate   time.Time `json:"end_date"`
			Values    struct {
				DownwardOfferedVolumeRRStdRestricted float64 `json:"DownwardOfferedVolumeRRStdRestricted"`
				UpwardOfferedVolumeRRStd             float64 `json:"UpwardOfferedVolumeRRStd"`
				DownwardOfferedVolumeRRStd           float64 `json:"DownwardOfferedVolumeRRStd"`
				UpwardOfferedVolumeRRStdRestricted   float64 `json:"UpwardOfferedVolumeRRStdRestricted"`
			} `json:"values"`
		} `json:"Offered_RRstd_Volume"`
		OfferedVolume []struct {
			StartDate time.Time `json:"start_date"`
			EndDate   time.Time `json:"end_date"`
			Values    struct {
				UpwardOfferedVolumemFRR         int `json:"UpwardOfferedVolumemFRR"`
				UpwardOfferedVolumeRRSpecific   int `json:"UpwardOfferedVolumeRRSpecific"`
				DownwardOfferedVolumeFCR        int `json:"DownwardOfferedVolumeFCR"`
				DownwardOfferedVolumeRRSpecific int `json:"DownwardOfferedVolumeRRSpecific"`
				UpwardOfferedVolumeFCR          int `json:"UpwardOfferedVolumeFCR"`
				UpwardOfferedVolumeaFRR         int `json:"UpwardOfferedVolumeaFRR"`
				DownwardOfferedVolumeaFRR       int `json:"DownwardOfferedVolumeaFRR"`
				DownwardOfferedVolumemFRR       int `json:"DownwardOfferedVolumemFRR"`
			} `json:"values"`
		} `json:"Offered_Volume"`
	} `json:"aggregatedoffers_energybids"`
}

type AnnualForecastsResp

type AnnualForecastsResp struct {
	AnnualForecasts []struct {
		StartDate time.Time `json:"start_date"`
		EndDate   time.Time `json:"end_date"`
		Values    []struct {
			StartDate                   time.Time `json:"start_date"`
			EndDate                     time.Time `json:"end_date"`
			AverageLoadSaturdayToFriday int       `json:"average_load_saturday_to_friday"`
			AverageLoadMondayToSunday   int       `json:"average_load_monday_to_sunday"`
			WeeklyMinimum               int       `json:"weekly_minimum"`
			WeeklyMaximum               int       `json:"weekly_maximum"`
			AverageLoadUpdatedDate      string    `json:"average_load_updated_date"`
			MarginUpdatedDate           string    `json:"margin_updated_date"`
			ForecastMargin              int       `json:"forecast_margin"`
		} `json:"values"`
	} `json:"annual_forecasts"`
}

type AuthToken

type AuthToken struct {
	AccessToken string    `json:"access_token"`
	TokenType   string    `json:"token_type"`
	ExpiresIn   int       `json:"expires_in"`
	ExpiryDate  time.Time `json:"expiry_date"`
}

type Client

type Client struct {
	Market      *market
	Consumption *consumption
	Partners    *partners
	Generation  *generation
	Exchanges   *exchanges
	// contains filtered or unexported fields
}

func NewClient

func NewClient(config ClientConfig) (*Client, error)

func (*Client) Do

func (c *Client) Do(req *retryablehttp.Request, v interface{}) (*http.Response, error)

func (*Client) NewRequest

func (c *Client) NewRequest(method, path string, opt interface{}) (*retryablehttp.Request, error)

type ClientConfig

type ClientConfig struct {
	Logger  log.Logger
	Key     string
	BaseURL string `default:"https://digital.iservices.rte-france.com/"`
}

type DailyProcuredReservesResp

type DailyProcuredReservesResp struct {
	DailyProcuredReserves []struct {
		StartDate time.Time     `json:"start_date"`
		EndDate   time.Time     `json:"end_date"`
		Type      string        `json:"type"`
		Values    []interface{} `json:"values"`
	} `json:"daily_procured_reserves"`
}

type ForecastsResp

type ForecastsResp struct {
	Forecasts []struct {
		StartDate      time.Time `json:"start_date"`
		EndDate        time.Time `json:"end_date"`
		Type           string    `json:"type"`
		ProductionType string    `json:"production_type"`
		Values         []struct {
			StartDate   time.Time `json:"start_date"`
			EndDate     time.Time `json:"end_date"`
			UpdatedDate time.Time `json:"updated_date"`
			Value       int       `json:"value"`
		} `json:"values"`
		SubType string `json:"sub_type,omitempty"`
	} `json:"forecasts"`
}

type GetForecastsOptions

type GetForecastsOptions struct {
	StartDate utils.Time `url:"start_date"`
	EndDate   utils.Time `url:"end_date"`
	ProdType  string     `url:"production_type"`
	Type      string     `url:"type"`
}

type GetMarginsDataOptions

type GetMarginsDataOptions struct {
	Date utils.Time `url:"date"`
	Sens string     `url:"sens"`
	Type string     `url:"type"`
}

type GetQualityDataOptions

type GetQualityDataOptions struct {
	ID        int        `url:"quality_meter_point_id"`
	StartDate utils.Time `url:"start_date"`
	EndDate   utils.Time `url:"end_date"`
	Type      string     `url:"data_type"`
}

type ImbalanceResp

type ImbalanceResp struct {
	Imbalance []struct {
		StartDate time.Time `json:"start_date"`
		EndDate   time.Time `json:"end_date"`
		Values    []struct {
			StartDate   time.Time `json:"start_date"`
			EndDate     time.Time `json:"end_date"`
			Value       int       `json:"value"`
			UpdatedDate time.Time `json:"updated_date"`
		} `json:"values"`
	} `json:"imbalance"`
}

type IndividualoffersEnergybidsResp

type IndividualoffersEnergybidsResp struct {
	IndividualoffersEnergybids []struct {
		StartDate        time.Time `json:"start_date"`
		EndDate          time.Time `json:"end_date"`
		TotalPagesNumber int       `json:"total_pages_number"`
		TotalItemsNumber int       `json:"total_items_number"`
		CurrentPage      int       `json:"current_page"`
		Mesure           []struct {
			StartDate time.Time `json:"start_date"`
			EndDate   time.Time `json:"end_date"`
			Values    []struct {
				Quantity     int     `json:"Quantity"`
				PriceAmount  float64 `json:"PriceAmount"`
				OfferType    string  `json:"OfferType"`
				Dmo          int     `json:"DMO"`
				ReserveType  string  `json:"ReserveType"`
				RowDirection string  `json:"RowDirection"`
				Status       string  `json:"Status"`
			} `json:"values"`
		} `json:"mesure"`
	} `json:"individualoffers_energybids"`
}

type InsufficientsOffersResp

type InsufficientsOffersResp struct {
	InsufficientsOffers struct {
		StartDate time.Time `json:"start_date"`
		EndDate   time.Time `json:"end_date"`
		Values    []struct {
			StartDate   time.Time `json:"start_date"`
			EndDate     time.Time `json:"end_date"`
			UpdatedDate time.Time `json:"updated_date"`
			Type        string    `json:"type"`
			Nature      string    `json:"nature"`
			Direction   string    `json:"direction"`
		} `json:"values"`
	} `json:"insufficients_offers"`
}

type MarginsDataResp

type MarginsDataResp []struct {
	StartDate       string `json:"startDate"`
	ComputationTime string `json:"computationTime"`
	ProjectionTime  string `json:"projectionTime"`
	MarginsData     []struct {
		StudiedTime                       string `json:"studiedTime"`
		ForecastedImbalanceRs             int    `json:"forecastedImbalanceRs"`
		AvailableMarginsNormalUp          int    `json:"availableMarginsNormalUp"`
		AvailableMarginsNormalDown        int    `json:"availableMarginsNormalDown"`
		AvailableMarginsComplementaryUp   int    `json:"availableMarginsComplementaryUp"`
		AvailableMarginsComplementaryDown int    `json:"availableMarginsComplementaryDown"`
		AvailableMarginsReliefUp          int    `json:"availableMarginsReliefUp"`
		AvailableMarginsReliefDown        int    `json:"availableMarginsReliefDown"`
		RequiredMarginsOperationnalUp     int    `json:"requiredMarginsOperationnalUp"`
		RequiredMarginsOperationnalDown   int    `json:"requiredMarginsOperationnalDown"`
	} `json:"marginsData"`
}

type NeedsResp

type NeedsResp struct {
	Needs []struct {
		StartDate     time.Time `json:"start_date"`
		EndDate       time.Time `json:"end_date"`
		Product       string    `json:"product"`
		FlowDirection string    `json:"flow_direction"`
		Volume        int       `json:"volume"`
	} `json:"needs"`
}

type OperatorsResp

type OperatorsResp struct {
	Operators []struct {
		StartDate                    time.Time `json:"start_date"`
		EndDate                      time.Time `json:"end_date"`
		UpdatedDate                  time.Time `json:"updated_date"`
		EicCode                      string    `json:"eic_code"`
		Name                         string    `json:"name"`
		TrialNebefRulesAgreement     bool      `json:"trial_nebef_rules_agreement"`
		TrialNebefRulesQualification bool      `json:"trial_nebef_rules_qualification"`
		NebefRulesRecognition        bool      `json:"nebef_rules_recognition"`
		NebefRulesQualification      bool      `json:"nebef_rules_qualification"`
	} `json:"operators"`
}

type PeakDailyMarginsResp

type PeakDailyMarginsResp struct {
	PeakDailyMargins []struct {
		StartDate time.Time `json:"start_date"`
		EndDate   time.Time `json:"end_date"`
		Values    []struct {
			StartDate         time.Time `json:"start_date"`
			EndDate           time.Time `json:"end_date"`
			UpdatedDate       time.Time `json:"updated_date"`
			MorningPeakPeriod struct {
				DurationBeforeMarginPeriod string `json:"DURATION_BEFORE_MARGIN_PERIOD"`
				BeginMarginPeriod          string `json:"BEGIN_MARGIN_PERIOD"`
				EndMarginPeriod            string `json:"END_MARGIN_PERIOD"`
				RequiredMargin             string `json:"REQUIRED_MARGIN"`
				MaOffers                   string `json:"MA_OFFERS"`
				CompOffers                 string `json:"COMP_OFFERS"`
				RESCUE                     string `json:"RESCUE "`
				IMBALANCE                  string `json:"IMBALANCE "`
				SimulatedMaOffers          string `json:"SIMULATED_MA_OFFERS"`
				SimulatedCompOffers        string `json:"SIMULATED_COMP_OFFERS"`
				SimulatedRescue            string `json:"SIMULATED_RESCUE"`
				SIMULATEDREQUIREDMARGIN    string `json:"SIMULATED_REQUIRED_MARGIN "`
			} `json:"morning_peak_period"`
			EveningPeakPeriod struct {
				DURATIONBEFOREMARGINPERIOD string `json:"DURATION_BEFORE_MARGIN_PERIOD "`
				BEGINMARGINPERIOD          string `json:"BEGIN_MARGIN_PERIOD "`
				ENDMARGINPERIOD            string `json:"END_MARGIN_PERIOD "`
				RequiredMargin             string `json:"REQUIRED_MARGIN"`
				MaOffers                   string `json:"MA_OFFERS"`
				CompOffers                 string `json:"COMP_OFFERS"`
				Rescue                     string `json:"RESCUE"`
				Imbalance                  string `json:"IMBALANCE"`
				SimulatedMaOffers          string `json:"SIMULATED_MA_OFFERS"`
				SimulatedCompOffers        string `json:"SIMULATED_COMP_OFFERS"`
				SimulatedRescue            string `json:"SIMULATED_RESCUE"`
				SIMULATEDREQUIREDMARGIN    string `json:"SIMULATED_REQUIRED_MARGIN "`
			} `json:"evening_peak_period"`
		} `json:"values"`
	} `json:"peak_daily_margins"`
}

type ProcuredReservesResp

type ProcuredReservesResp struct {
	ProcuredReserves []struct {
		StartDate time.Time `json:"start_date"`
		EndDate   time.Time `json:"end_date"`
		Type      string    `json:"type"`
		Values    []struct {
			StartDate   time.Time `json:"start_date"`
			EndDate     time.Time `json:"end_date"`
			Direction   string    `json:"direction"`
			Value       int       `json:"value"`
			Price       float64   `json:"price"`
			UpdatedDate time.Time `json:"updated_date"`
		} `json:"values"`
	} `json:"procured_reserves"`
}

type QualityDataResp

type QualityDataResp struct {
	QualityData []struct {
		QualityMeterPointID string `json:"quality_meter_point_id"`
		DataList            []struct {
			DataType  string    `json:"data_type"`
			Phase     string    `json:"phase"`
			Unit      string    `json:"unit"`
			StartDate time.Time `json:"start_date,omitempty"`
			EndDate   time.Time `json:"end_date,omitempty"`
			Data      []struct {
				Timestamp time.Time `json:"timestamp"`
				Value     float64   `json:"value"`
			} `json:"data"`
			ValueType         string      `json:"value_type,omitempty"`
			NominalDataPeriod int         `json:"nominal_data_period,omitempty"`
			HarmonicNumber    interface{} `json:"harmonic_number,omitempty"`
		} `json:"data_list"`
	} `json:"quality_data"`
}

type ShortTermResp

type ShortTermResp struct {
	ShortTerm []struct {
		Type      string    `json:"type"`
		StartDate time.Time `json:"start_date"`
		EndDate   time.Time `json:"end_date"`
		Values    []struct {
			StartDate   time.Time `json:"start_date"`
			EndDate     time.Time `json:"end_date"`
			UpdatedDate time.Time `json:"updated_date"`
			Value       int       `json:"value"`
		} `json:"values"`
	} `json:"short_term"`
}

type Signal

type Signal []struct {
	StartDate time.Time     `json:"start_date"`
	EndDate   time.Time     `json:"end_date"`
	Type      string        `json:"type"`
	Values    []SignalValue `json:"values"`
}

type SignalEcowatt

type SignalEcowatt struct {
	Signals []struct {
		StartDate time.Time `json:"start_date"`
		EndDate   time.Time `json:"end_date"`
		Values    struct {
			Pdl []string `json:"PDL"`
			Hdf []string `json:"HDF"`
			Naq []string `json:"NAQ"`
			Bfc []string `json:"BFC"`
			Bre []string `json:"BRE"`
			Pac []string `json:"PAC"`
			Ara []string `json:"ARA"`
			Occ []string `json:"OCC"`
			Nor []string `json:"NOR"`
			Idf []string `json:"IDF"`
			Cvl []string `json:"CVL"`
			Ges []string `json:"GES"`
		} `json:"values"`
	} `json:"signals"`
}

type SignalValue

type SignalValue struct {
	StartDate   time.Time `json:"start_date"`
	EndDate     time.Time `json:"end_date"`
	Value       bool      `json:"value"`
	UpdatedDate time.Time `json:"updated_date"`
}

type Signals

type Signals struct {
	Signal `json:"signals"`
}

type TempoLikeCalendarsResp

type TempoLikeCalendarsResp struct {
	TempoLikeCalendars struct {
		StartDate time.Time `json:"start_date"`
		EndDate   time.Time `json:"end_date"`
		Values    []struct {
			StartDate   time.Time `json:"start_date"`
			EndDate     time.Time `json:"end_date"`
			Value       string    `json:"value"`
			UpdatedDate time.Time `json:"updated_date"`
		} `json:"values"`
	} `json:"tempo_like_calendars"`
}

type VolumesResp

type VolumesResp struct {
	Volumes []struct {
		StartDate time.Time `json:"start_date"`
		EndDate   time.Time `json:"end_date"`
		Values    []struct {
			StartDate        time.Time `json:"start_date"`
			EndDate          time.Time `json:"end_date"`
			ProgramsRetained int       `json:"programs_retained"`
			UpdatedDate      time.Time `json:"updated_date"`
		} `json:"values"`
	} `json:"volumes"`
}

type WeeklyForecastsResp

type WeeklyForecastsResp struct {
	WeeklyForecasts []struct {
		EndDate time.Time `json:"end_date"`
		Values  []struct {
			EndDate   time.Time `json:"end_date"`
			Value     int       `json:"value"`
			StartDate time.Time `json:"start_date"`
		} `json:"values"`
		UpdatedDate time.Time `json:"updated_date"`
		Peak        struct {
			TemperatureDeviation float64   `json:"temperature_deviation"`
			Value                int       `json:"value"`
			PeakHour             time.Time `json:"peak_hour"`
			Temperature          float64   `json:"temperature"`
		} `json:"peak"`
		StartDate time.Time `json:"start_date"`
	} `json:"weekly_forecasts"`
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL