{
  "openapi": "3.0.0",
  "showCommonExtensions": "true",
  "info": {
    "title": "IGS-RF API",
    "description": "API documentation for IGS-RF API endpoints, dedicated to the <a href='https://webigs-rf.ign.fr/'>https://webigs-rf.ign.fr</a> website.",
    "version": "1.0.0"
  },
  "servers": [
    {
      "url": "/api",
      "description": "Base path for all API routes"
    }
  ],
  "tags": [
    { "name": "Stations", "description": "Endpoints related to stations" },
    { "name": "Coordinates", "description": "Endpoints related to station coordinates" },
    { "name": "Graphs", "description": "Graph data retrieval" },
    { "name": "Seismic", "description": "Coseismic data handling" }
  ],
  "paths": {
    "/stations": {
      "get": {
        "summary": "Provides IGS station list",
        "tags": ["Stations"],
        "responses": {
          "200": {
            "description": "Returns a dictionary with station bbol (True if station part of station ",
            "content": {
              "application/json": {
                "schema": { "type": "object" }
              }
            }
          }
        }
      }
    },
    "/stations_coords/{name_station}": {
      "get": {
        "summary": "Provides station coordinates",
        "tags": ["Coordinates"],
        "parameters": [
          {
            "name": "name_station",
            "in": "path",
            "required": false,
            "schema": { "type": "string" },
            "example": "GOLD"
          }
        ],
        "responses": {
          "200": {
            "description": "Returns station coordinates as JSON",
            "content": {
              "application/json": {
                "schema": { "type": "object" },
                "example": {
		  "id": "GOLD",
		  "igscumul": true,
		  "position": {
		    "lat": 35.42515583178638,
		    "lng": -116.88925086217307
		  },
		  "sitelog": "https://files.igs.org/pub/station/log/gold00usa_20250130.log",
		  "solutions": [
		    "IGb20",
		    "IGb14",
		    "IGS20",
		    "IGS14",
		    "IGS"
		  ]
		}
              }
            }
          }
        }
      }
    },
    "/coord/{name_station}": {
      "get": {
        "summary": "Provides model info for coordinate plotting",
        "tags": ["Coordinates"],
        "parameters": [
          {
            "name": "name_station",
            "in": "path",
            "required": true,
            "schema": { "type": "string" },
            "example": "GOLD"
          }
        ],
        "responses": {
          "200": {
            "description": "Returns coordinate graph data",
            "content": {
              "application/json": {
                "schema": { "type": "object" }
              }
            }
          }
        }
      }
    },
    "/img/{name_station}": {
      "get": {
        "summary": "Provides PNG coordinate plots",
        "tags": ["Graphs"],
        "parameters": [
          {
            "name": "name_station",
            "in": "path",
            "required": true,
            "schema": { "type": "string" },
            "example": "GOLD"
          }
        ],
        "responses": {
          "200": {
            "description": "Returns PNG image of coordinate plots",
            "content": {
              "image/png": {}
            }
          }
        }
      }
    },
    "/extract_crd/": {
      "post": {
        "summary": "Processes extract coordinate request",
        "tags": ["Coordinates"],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "solution": { "type": "string" },
                  "format": { "type": "string" },
                  "type_of_coordinates": { "type": "string" },
                  "epoch": { "type": "string" },
                  "station": { "type": "string" }
                },
                "example": {
                  "solution": "IGS Solution",
                  "format": "JSON",
                  "type_of_coordinates": "Geodetic",
                  "epoch": "2024.3",
                  "station": "GOLD"
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Returns extracted coordinate data",
            "content": {
              "text/plain": {}
            }
          }
        }
      }
    },
    "/coseismic": {
      "get": {
        "summary": "Provides coseismic table file for IGS stations.",
        "tags": ["Seismic"],
        "responses": {
          "200": {
            "description": "Returns coseismic data as plain text",
            "content": {
              "text/plain": {}
            }
          }
        }
      }
    },
    "/coseismic_request": {
      "post": {
        "summary": "Compute station co-seismic displacements",
        "tags": ["Seismic"],
        "description": "<div>Computes co-seismic displacements for one or more stations with optional global or per-station date ranges. The calculation of co-seismic displacements relies on <a href='https://www.globalcmt.org/'>the Global Centroid-Moment-Tensor (CMT) catalog</a>. For every earthquake in the CMT catalog, the width, length and slip of the rupture are estimated from: <ul> <li> <a href='https://doi.org/10.1785/0120100046'>Yen & Ma (2012)</a>'s scaling law if the earthquake magnitude is less than 7.6;</li> <li> <a href='https://doi.org/10.1785/0119990126'>Mai & Beroza (2000)</a>'s scaling law it the earthquake magnitude is larger.</li>(See justification for these choices in <a href='https://doi.org/10.1002/2014JB011280'>Métivier et al. (2014)</a>.)</ul> For every earthquake, based on its estimated CMT and rupture parameters, co-seismic displacements are calculated at all requested points using <a href='https://doi.org/10.1785/BSSA0750041135'>Okada (1985)</a>'s approach. Given that the CMT inversion from seismic waves gives rise to two possible solutions for the rupture plane, two possible co-seismic displacements are calculated for every point and earthquake.<br><br> If any calculated 3D co-seismic displacement exceeds the specified threshold (dmin - at least 1 mm), it is included in the request output.<br><br><b>Warning:</b> The co-seismic displacements thus calculated rely on several coarse approximations. They should not be used as estimates of the actual co-seismic displacements, but only as rough orders of magnitude.</div>",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "required": ["stations"],
                "properties": {
                  "start_date": {
                    "type": "string",
                    "format": "date",
                    "description": "Global start date (YYYY-MM-DD format, optional). If not set, defaults to 1976-01-01.",
                    "example": "1980-01-01"
                  },
                  "end_date": {
                    "type": "string",
                    "format": "date",
                    "description": "Global end date (YYYY-MM-DD format, optional). If not set, defaults to today.",
                    "example": "2020-01-01"
                  },
                  "dmin": {
                    "type": "float",
                    "description": "Minimal requested displacement [mm]. Must be >= 1. If not set, defaults: dmin=1 [mm].",
                    "example": "1"
                  },
                  "stations": {
                    "type": "array",
                    "minItems": 1,
                    "description": "List of seismic stations with coordinates and optional per-station date overrides.",
                    "items": {
                      "type": "object",
                      "required": ["name", "latlng"],
                      "properties": {
                        "name": {
                          "type": "string",
                          "description": "Station ID or name",
                          "example": "GOLD"
                        },
                        "latlng": {
                          "type": "array",
                          "minItems": 2,
                          "maxItems": 2,
                          "items": {
                            "type": "number"
                          },
                          "description": "Latitude and longitude [lat, lon]",
                          "example": [35.425, -116.889]
                        },
                        "start_date": {
                          "type": "string",
                          "format": "date",
                          "description": "Optional per-station start date (overrides global)",
                          "example": "1985-01-01"
                        },
                        "end_date": {
                          "type": "string",
                          "format": "date",
                          "description": "Optional per-station end date (overrides global)",
                          "example": "2021-12-31"
                        }
                      }
                    }
                  }
                }
              },
              "example": {
                "start_date": "1980-01-01",
                "end_date": "2020-01-01",
                "dmin":1,
                "stations": [{
                    "name": "BRAZ",
                    "latlng": [-15.947, -47.878],
                    "start_date":"2003-01-01"
                  },
                  {
                    "name": "GOLD",
                    "latlng": [35.425, -116.889]
                  }
                ]
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Successful computation result",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "result": {
                      "type": "object",
                      "properties": {
                        "status": {
                          "type": "string",
                          "example": "success"
                        },
                        "data_length": {
                          "type": "integer",
                          "example": 1
                        }
                      }
                    },
                    "info": {
                      "type": "array",
                      "items": {
                        "type": "string"
                      },
                      "example": []
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "Invalid input or missing fields",
            "content": {
              "application/json": {
                "example": {
                  "error": "Missing or invalid 'stations' list"
                }
              }
            }
          }
        }
      }
    }
  }
}

