Skip to content
bsmmoon edited this page Mar 31, 2016 · 17 revisions

GET Requests

  1. Status
    Description: Returns the status of the server in the form of a JSON response
    Usage: GET /status

JSON POST Requests

General usage: The following API requests are to be POST-ed to /{authorization_key}/v2
Note: The version field may be omitted in the following API calls. In such cases, we will check if the partner calling the API (identified using the partner's authorization key) has a preferred version for the requested library. If such preference exists, we will assume that the partner is requesting for his/her preferred version of the library. Otherwise, we will assume that the partner is requesting for the latest version of the library.

1. List

Description: List all libraries and examples
Request body: {"type":"list"}

Example:
{"type":"list"}

{
  "success": true,
  "text": "Successful Request!",
  "categories": {
    "Examples": {
      "01.Basics": {
        "description": "",
        "examples": [
          {
            "name": "ReadAnalogVoltage"
          },
        (rest of the examples)
        ]
      (rest of the libraries)
      }
    },
    "Builtin Libraries": {
      "EEPROM": {
        "default": {
          "description": "Built-in library EEPROM",
          "name": "EEPROM",
          "url": "http://github.com//",
          "examples": [
            "eeprom_clear",
            (rest of the examples)
          ]
        (rest of the versions)
        },
      (rest of the libraries)
      }
    },
    "External Libraries": {
      "Binary": {
        "1.0.0": {
          "description": "A library containing non-text files",
          "name": "Binary content Library",
          "url": "http://github.com//",
          "examples": []
        }
      (rest of the versions)
      },
    (rest of the libraries)
    }
  }
}

2. Fetch

Description: Fetches a specific version of a library
Request body: {"type":"fetch", "library":"<default_header_of_library>", "version":"<library_version>"}

Example:
{ "type":"fetch", "library":"default", "version": "1.0.0" }

{
  "success": true,
  "message": "Library found",
  "files": {
    "1.0.0": [
      {
        "filename": "default.h",
        "content": <the content of the default.h>
      },
    (reset of the files)
    ]
  (rest of the versions)
  }
}

3. Get examples

Description: Returns all examples belonging to a library version
Request body: {"type":"getExamples", "library":"<default_header_of_library>", "version":"<library_version>"}

Example:
{"type":"getExamples", "library":"default", "version":"1.0.0"}

{
  "success": true,
  "examples": {
    "example_one": [
      {
        "filename": "example_one.ino",
        "content": <the content of the example_one.ino>
      }
    ]
    (rest of the examples)
  }
}

4. Get example code

Description: Returns a specific example file from a library version
Request body: {"type":"getExampleCode", "library":"<default_header_of_library>", "version":"<library_version>", "example":"<example_name>"}

Example:
{"type":"getExampleCode", "library":"default", "version": "1.0.0", "example":"example_one"}

{
  "success": true,
  "examples": {
    "example_one": [
      {
        "filename": "example_one.ino",
        "content": <the content of the example_one.ino>
      }
    ]
  }
}

5. Get keywords

Description: Returns a list of keywords found in the keywords.txt file of a library version
Request body: {"type":"getKeywords", "library":"<default_header_of_library>", "version":"<library_version>"}

Example:
{"type":"getKeywords", "library":"EEPROM", "version": "default"}

{
  "success": true,
  "keywords": {
    "KEYWORD1": [
      "EEPROM"
    ]
  }
}

6. Get versions

Description: Returns a list of versions that Eratosthenes has for a library
Request body: {"type":"getVersions", "library":"<default_header_of_library>"}

Example:
{"type":"getVersions", "library":"default"}

{
  "success": true,
  "versions": [
    "1.0.0",
    "1.1.0"
  ]
}

7. Check for Github updates

Description: Checks if any Github libraries need to be updated
Request body: {"type":"checkGithubUpdates"}

Example:
{"type":"checkGithubUpdates"}

{
  "success": true,
  "message": "1 external libraries need to be updated",
  "libraries": [
    {
      "Machine Name": "DynamicArrayHelper",
      "Human Name": "Dynamic Array Helper Arduino Library",
      "Git Owner": "codebendercc",
      "Git Repo": "DynamicArrayHelper-Arduino-Library",
      "Git Branch": "1.0.x",
      "Path in Git Repo": ""
    }
  ]
}

Clone this wiki locally