Personal tools

Difference between revisions of "API help"

From PhotoVoltaic Logger new generation

Jump to: navigation, search
m
m
Line 1: Line 1:
Here you have all the possible requests, which the API supports at the moment.
+
Here you have all the possible requests, which the [[API]] supports at the moment.
 
<pre><nowiki>
 
<pre><nowiki>
 
   "ANY /api/r3/help": {
 
   "ANY /api/r3/help": {

Revision as of 09:30, 28 February 2014

Here you have all the possible requests, which the API supports at the moment.

  "ANY /api/r3/help": {
    "since": "v1",
    "description": "This help, overview of valid calls"
  },
  "GET /api/r3/:guid": {
    "since": "v2",
    "description": "Fetch attributes",
    "conditions": {
      "guid": "(\\w{4}-){7}\\w{4}"
    }
  },
  "GET /api/r3/:guid/:attribute": {
    "since": "v2",
    "description": "Fetch single channel attribute",
    "conditions": {
      "guid": "(\\w{4}-){7}\\w{4}",
      "attribute": "\\w+"
    }
  },
  "GET /api/r3/attributes/:guid(/:attribute)": {
    "since": "v2",
    "description": "Fetch all channel attributes or specific channel attribute",
    "conditions": {
      "guid": "(\\w{4}-){7}\\w{4}",
      "attribute": "\\w+"
    }
  },
  "GET /api/r3/channels": {
    "since": "v3",
    "description": "Fetch attributes"
  },
  "GET /api/r3/channel/:guid": {
    "since": "v3",
    "description": "Fetch single channel attribute",
    "conditions": {
      "guid": "(\\w{4}-){7}\\w{4}"
    }
  },
  "GET /api/r3/channel/:guid/:attribute": {
    "since": "v3",
    "description": "Fetch all channel attributes or specific channel attribute",
    "conditions": {
      "guid": "(\\w{4}-){7}\\w{4}",
      "attribute": "\\w+"
    }
  },
  "PUT /api/r3/data/:guid": {
    "since": "v2",
    "description": "Save a reading value",
    "payload": "{\"<data>\":\"<value>\"}",
    "conditions": {
      "guid": "(\\w{4}-){7}\\w{4}"
    }
  },
  "GET /api/r3/data/:guid(/:p1(/:p2))": {
    "since": "v2",
    "description": "Read reading values",
    "parameters": {
      "start": {
        "description": "Start timestamp for readout, default today 00:00",
        "value": [
          "YYYY-mm-dd HH:ii:ss",
          "seconds since 1970",
          "relative from now, see http://php.net/manual/en/datetime.formats.relative.php",
          "sunrise - needs location in config/config.php"
        ]
      },
      "end": {
        "description": "End timestamp for readout, default today midnight",
        "value": [
          "YYYY-mm-dd HH:ii:ss",
          "seconds since 1970",
          "relative from now, see http://php.net/manual/en/datetime.formats.relative.php",
          "sunset - needs location in config/config.php"
        ]
      },
      "period": {
        "description": "Aggregation period, default none",
        "value": [
          "[0-9.]+minutes",
          "[0-9.]+hours",
          "[0-9.]+days",
          "[0-9.]+weeks",
          "[0-9.]+month",
          "[0-9.]+quarters",
          "[0-9.]+years",
          "last",
          "readlast",
          "all"
        ]
      },
      "attributes": {
        "description": "Return channel attributes as 1st line",
        "value": [
          1,
          "true"
        ]
      },
      "full": {
        "description": "Return all data, not only timestamp and value",
        "value": [
          1,
          "true"
        ]
      },
      "short": {
        "description": "Return data as array, not object",
        "value": [
          1,
          "true"
        ]
      }
    },
    "conditions": {
      "guid": "(\\w{4}-){7}\\w{4}"
    }
  },
  "DELETE /api/r3/data/:guid/:timestamp": {
    "since": "v2",
    "description": "Delete a reading value",
    "conditions": {
      "guid": "(\\w{4}-){7}\\w{4}"
    }
  },
  "PUT /api/r3/batch/:guid": {
    "since": "v2",
    "description": "Save multiple reading values",
    "payload": {
      "<timestamp>,<value>;...": "Semicolon separated timestamp and value data sets",
      "<date time>,<value>;...": "Semicolon separated date time and value data sets",
      "<date>,<time>,<value>;...": "Semicolon separated date, time and value data sets"
    },
    "conditions": {
      "guid": "(\\w{4}-){7}\\w{4}"
    }
  },
  "PUT /api/r3/csv/:guid": {
    "since": "v2",
    "description": "Save multiple reading values",
    "payload": {
      "<timestamp>;<value>": "Semicolon separated timestamp and value data rows",
      "<date time>;<value>": "Semicolon separated date time and value data rows",
      "<date>;<time>;<value>": "Semicolon separated date, time and value data rows"
    },
    "conditions": {
      "guid": "(\\w{4}-){7}\\w{4}"
    }
  },
  "PUT /api/r3/log": {
    "since": "v2",
    "description": "Store new log entry, scope defaults to 'API r2'",
    "payload": "{\"scope\":\"...\", \"message\":\"...\"}"
  },
  "GET /api/r3/log/:id": {
    "since": "v2",
    "description": "Read a log entry",
    "conditions": {
      "id": "\\d+"
    }
  },
  "GET /api/r3/log/all(/:page(/:count))": {
    "since": "v2",
    "description": "Read all log entries, paginated for :page, :count entries"
  },
  "POST /api/r3/log/:id": {
    "since": "v2",
    "description": "Update a log entry",
    "payload": "{\"scope\":\"...\", \"message\":\"...\"}",
    "conditions": {
      "id": "\\d+"
    }
  },
  "DELETE /api/r3/log/:id": {
    "since": "v2",
    "description": "Delete a log entry",
    "conditions": {
      "id": "\\d+"
    }
  },
  "GET /api/r3/sunrise/(/:date)": {
    "since": "v3",
    "description": "Get sunrise of day, using configured loaction",
    "conditions": {
      "date": "\\d{4}-\\d{2}-\\d{2}"
    }
  },
  "GET /api/r3/sunrise/:latitude/:longitude(/:date)": {
    "since": "v3",
    "description": "Get sunrise for location and day",
    "conditions": {
      "latitude": "[\\d.-]+",
      "longitude": "[\\d.-]+",
      "date": "\\d{4}-\\d{2}-\\d{2}"
    }
  },
  "GET /api/r3/sunset/(/:date)": {
    "since": "v3",
    "description": "Get sunset of day, using configured loaction",
    "conditions": {
      "date": "\\d{4}-\\d{2}-\\d{2}"
    }
  },
  "GET /api/r3/sunset/:latitude/:longitude(/:date)": {
    "since": "v3",
    "description": "Get sunset of day",
    "conditions": {
      "latitude": "[\\d.-]+",
      "longitude": "[\\d.-]+",
      "date": "\\d{4}-\\d{2}-\\d{2}"
    }
  },
  "GET /api/r3/daylight/(/:offset)": {
    "since": "v3",
    "description": "Check for daylight for configured location, accept additional minutes before/after",
    "conditions": {
      "offset": "\\d+"
    }
  },
  "GET /api/r3/daylight/:latitude/:longitude(/:offset)": {
    "since": "v3",
    "description": "Check for daylight, accept additional minutes before/after",
    "conditions": {
      "latitude": "[\\d.-]+",
      "longitude": "[\\d.-]+",
      "offset": "\\d+"
    }
  },
  "GET /api/r3/json/:path+": {
    "description": "Extract a section/value from given JSON data from query string",
    "payload": "...json/path/to/node/?json=<JSON data>"
  },
  "POST /api/r3/json/:path+": {
    "description": "Extract a section/value from given JSON data sended in request body e.g. from a file"
  },
  "GET /api/r3/views": {
    "since": "v3",
    "description": "Fetch chart view data via slug"
  },
  "PUT /api/r3/view": {
    "since": "v3",
    "description": "Create chart view data, return slug"
  },
  "GET /api/r3/view/:slug": {
    "since": "v3",
    "description": "Fetch chart view data via slug",
    "conditions": {
      "slug": "[@\\w\\d-]+"
    }
  },
  "POST /api/r3/view/:slug": {
    "since": "v3",
    "description": "Update chart view data via slug",
    "conditions": {
      "slug": "[@\\w\\d-]+"
    }
  },
  "DELETE /api/r3/view/:slug": {
    "since": "v3",
    "description": "Detele chart view data by slug",
    "conditions": {
      "slug": "[@\\w\\d-]+"
    }
  },
  "GET|POST /api/r3/hash": {
    "since": "v3",
    "description": "Create MD5 and SHA1 hashes and a slug for the given text",
    "parameters": {
      "text": {
        "description": "Text to make hashes for"
      }
    }
  },
  "GET /api/r3/status": {
    "since": "v2",
    "description": "System status"
  },
  "GET /api/r3/translation": {
    "since": "v3",
    "description": "Extract english texts for translation"
  }