Difference between revisions of "Client API"

From floodzilla-wiki
Jump to navigation Jump to search
Line 28: Line 28:
  
 
Returns: Array of ApiLocationInfo objects:
 
Returns: Array of ApiLocationInfo objects:
<code>
+
<code>public class ApiLocationInfo
    public class ApiLocationInfo
+
{
    {
+
    // Id corresponds to SensorLocationBase.PublicLocationId
        // Id corresponds to SensorLocationBase.PublicLocationId
+
    public string Id { get; set; }
        public string Id { get; set; }
+
    public string LocationName { get; set; }
        public string LocationName { get; set; }
+
    public string ShortName { get; set; }
        public string ShortName { get; set; }
+
    public double? Latitude { get; set; }
        public double? Latitude { get; set; }
+
    public double? Longitude { get; set; }
        public double? Longitude { get; set; }
+
    public bool IsOffline { get; set; }
        public bool IsOffline { get; set; }
+
    public double? Rank { get; set; }
        public double? Rank { get; set; }
+
    public double? MaxChangeThreshold { get; set; }
        public double? MaxChangeThreshold { get; set; }
+
    public double? YMin { get; set; }
        public double? YMin { get; set; }
+
    public double? YMax { get; set; }
        public double? YMax { get; set; }
+
    public double? DischargeMin { get; set; }
        public double? DischargeMin { get; set; }
+
    public double? DischargeMax { get; set; }
        public double? DischargeMax { get; set; }
+
    public double? DischargeStageOne { get; set; }
        public double? DischargeStageOne { get; set; }
+
    public double? DischargeStageTwo { get; set; }
        public double? DischargeStageTwo { get; set; }
+
    public double? GroundHeight { get; set; }
        public double? GroundHeight { get; set; }
+
    public double? YellowStage { get; set; }
        public double? YellowStage { get; set; }
+
    public double? RedStage { get; set; }
        public double? RedStage { get; set; }
+
    public double? RoadSaddleHeight { get; set; }
        public double? RoadSaddleHeight { get; set; }
+
    public string RoadDisplayName { get; set; }
        public string RoadDisplayName { get; set; }
+
    public string DeviceTypeName { get; set; }
        public string DeviceTypeName { get; set; }
+
    public string TimeZoneName { get; set; }
        public string TimeZoneName { get; set; }
+
    public bool HasDischarge { get; set; }
        public bool HasDischarge { get; set; }
+
    public int UsgsSiteId { get; set; }
        public int UsgsSiteId { get; set; }
+
    public string NoaaSiteId { get; set; }
        public string NoaaSiteId { get; set; }
+
    public bool IsCurrentlyOffline { get; set; }            // DEPRECATED: true if either IsOffline or no recent readings have come in
        public bool IsCurrentlyOffline { get; set; }            // DEPRECATED: true if either IsOffline or no recent readings have come in
+
    public List<string> LocationImages { get; set; }
        public List<string> LocationImages { get; set; }
+
    public List<ApiFloodEvent> FloodEvents { get; set; }    // The list of historical floods that this gage has data for.
        public List<ApiFloodEvent> FloodEvents { get; set; }    // The list of historical floods that this gage has data for.
+
}</code>
</code>
 
  
 
====GetMetagages====
 
====GetMetagages====
Line 68: Line 67:
  
 
Returns: Array of MetagageInfo objects:
 
Returns: Array of MetagageInfo objects:
<code>
+
<code>public class MetagageInfo
    public class MetagageInfo
+
{
    {
+
    public string Id;
        public string Id;
+
    public string SiteId;
        public string SiteId;
+
    public string Name;
        public string Name;
+
    public string ShortName;
        public string ShortName;
+
    public double StageOne;
        public double StageOne;
+
    public double StageTwo;
        public double StageTwo;
+
}</code>
    }
 
</code>
 
  
 
====GetLocations====
 
====GetLocations====

Revision as of 18:45, 9 March 2023

Gage Status and Metadata

All object definitions below are in C#, but mapping them to other languages should be straightforward.

All date/time fields are in UTC.

All distances (including water height) are in feet. Water heights are Feet ASL (Above Sea Level).

All water discharge numbers are in CFS (Cubic Feet per Second).

"Stage One" and "Stage Two" refer to flood warning stages. Stage One is the level at which we consider the gage "Near Flooding". Stage Two is Flooding.

Yellow and Red are legacy names to refer to Stage One and Stage Two respectively.

If a method name has a prefix API, it is probably just to disambiguate it from an existing method with a similar name; eventually these will all be renamed.

The "RegionID" parameter should be added to all methods if it is not already there. The Region ID for the Snoqualmie Valley sensors is 1, and it's ok to hardcode this number for now. This parameter will eventually be used so that we can support multiple unrelated flood zones.

Methods

APIGetLocationInfo

Returns the list of all available gages and their metadata. A lot of the metadata isn't directly useful to clients (e.g. MaxChangeThreshold is used by the system to determine if an incoming reading is invalid; clients probably don't care).

NOTE: Some of the flags per location will be changing soon as we rework how "maintenance mode" and "historical mode" are handled for gages.

Endpoint: GET floodzilla.com/api/client/APIGetLocationInfo?regionId=1

Returns: Array of ApiLocationInfo objects: public class ApiLocationInfo {

   // Id corresponds to SensorLocationBase.PublicLocationId
   public string Id { get; set; }
   public string LocationName { get; set; }
   public string ShortName { get; set; }
   public double? Latitude { get; set; }
   public double? Longitude { get; set; }
   public bool IsOffline { get; set; }
   public double? Rank { get; set; }
   public double? MaxChangeThreshold { get; set; }
   public double? YMin { get; set; }
   public double? YMax { get; set; }
   public double? DischargeMin { get; set; }
   public double? DischargeMax { get; set; }
   public double? DischargeStageOne { get; set; }
   public double? DischargeStageTwo { get; set; }
   public double? GroundHeight { get; set; }
   public double? YellowStage { get; set; }
   public double? RedStage { get; set; }
   public double? RoadSaddleHeight { get; set; }
   public string RoadDisplayName { get; set; }
   public string DeviceTypeName { get; set; }
   public string TimeZoneName { get; set; }
   public bool HasDischarge { get; set; }
   public int UsgsSiteId { get; set; }
   public string NoaaSiteId { get; set; }
   public bool IsCurrentlyOffline { get; set; }            // DEPRECATED: true if either IsOffline or no recent readings have come in
   public List<string> LocationImages { get; set; }
   public List<ApiFloodEvent> FloodEvents { get; set; }    // The list of historical floods that this gage has data for.

}

GetMetagages

A "Metagage" is a list of gages that we sometimes show aggregated data for. The primary use is for the "Sum of the 3 forks" gage on the Forecasts page, which is the sum of readings and forecasts for three separate gages at the three forks of the river.

Endpoint: GET floodzilla.com/api/client/GetMetagages?regionId=1

Returns: Array of MetagageInfo objects: public class MetagageInfo {

   public string Id;
   public string SiteId;
   public string Name;
   public string ShortName;
   public double StageOne;
   public double StageTwo;

}

GetLocations

Deprecated.

GetGageReadingsUTC

Deprecated.

Authentication

Floodzilla has its own AuthZ/AuthN API; it does not use a third party service like Auth0. The primary reason is integration with ASP.NET's built-in authentication and identity services, which the existing back end and admin tools use.

[Full documentation will be added eventually]

Methods

Authenticate

Reauthenticate

CreateAccount

APIForgotPassword

APISetPassword

APICreatePassword

APIResetPassword

SendVerificationEmail

VerifyEmail

SendPhoneVerificationSMS

VerifyPhone

UpdateAccount

AuthenticateWithGoogle

Subscription

The Subscription API allows clients to subscribe to various kinds of notifications (currently just email and SMS) for gages and forecast data.

Methods

[Documentation to come]