aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorskullY <skullydazed@gmail.com>2020-02-23 22:37:25 -0800
committerskullydazed <skullydazed@users.noreply.github.com>2020-03-05 16:00:10 -0800
commit99850aabcad51dd4a46ee10c0f5349a4266084fe (patch)
treed59c25726ec8aa7209f15329a194f87f195de11d
parent3c98854044066744ad79d8abc27d93951860af6d (diff)
downloadqmk_firmware-99850aabcad51dd4a46ee10c0f5349a4266084fe.tar.gz
qmk_firmware-99850aabcad51dd4a46ee10c0f5349a4266084fe.zip
Add API documentation
-rw-r--r--docs/_summary.md27
-rw-r--r--docs/api_development_environment.md3
-rw-r--r--docs/api_development_overview.md44
-rw-r--r--docs/api_docs.md68
-rw-r--r--docs/api_overview.md15
5 files changed, 148 insertions, 9 deletions
diff --git a/docs/_summary.md b/docs/_summary.md
index baa493717..dee8a3198 100644
--- a/docs/_summary.md
+++ b/docs/_summary.md
@@ -6,12 +6,6 @@
6 * [Testing and Debugging](newbs_testing_debugging.md) 6 * [Testing and Debugging](newbs_testing_debugging.md)
7 * [Getting Help](getting_started_getting_help.md) 7 * [Getting Help](getting_started_getting_help.md)
8 8
9* Breaking Changes
10 * [Overview](breaking_changes.md)
11 * [My Pull Request Was Flagged](breaking_changes_instructions.md)
12 * History
13 * [2019 Aug 30](ChangeLog/20190830.md)
14
15* FAQs 9* FAQs
16 * [General FAQ](faq_general.md) 10 * [General FAQ](faq_general.md)
17 * [Build/Compile QMK](faq_build.md) 11 * [Build/Compile QMK](faq_build.md)
@@ -19,8 +13,14 @@
19 * [Keymap](faq_keymap.md) 13 * [Keymap](faq_keymap.md)
20 * [Driver Installation with Zadig](driver_installation_zadig.md) 14 * [Driver Installation with Zadig](driver_installation_zadig.md)
21 15
16* Configurator
17 * [Overview](newbs_building_firmware_configurator.md)
18 * [Keyboard Support](reference_configurator_support.md)
19 * QMK API
20 * [Overview](api_overview.md)
21 * [API Documentation](api_docs.md)
22
22* Using QMK 23* Using QMK
23 * [Support](getting_started_getting_help.md)
24 * Guides 24 * Guides
25 * [ARM Debugging Guide](arm_debugging.md) 25 * [ARM Debugging Guide](arm_debugging.md)
26 * [Best Git Practices](newbs_git_best_practices.md) 26 * [Best Git Practices](newbs_git_best_practices.md)
@@ -89,8 +89,13 @@
89 * [Using Eclipse with QMK](other_eclipse.md) 89 * [Using Eclipse with QMK](other_eclipse.md)
90 * [Using VSCode with QMK](other_vscode.md) 90 * [Using VSCode with QMK](other_vscode.md)
91 91
92
93* Developing QMK 92* Developing QMK
93 * Breaking Changes
94 * [Overview](breaking_changes.md)
95 * [My Pull Request Was Flagged](breaking_changes_instructions.md)
96 * History
97 * [2019 Aug 30](ChangeLog/20190830.md)
98
94 * QMK Reference 99 * QMK Reference
95 * [Translating the QMK Docs](translating.md) 100 * [Translating the QMK Docs](translating.md)
96 * [Config Options](config_options.md) 101 * [Config Options](config_options.md)
@@ -101,7 +106,6 @@
101 * [Community Layouts](feature_layouts.md) 106 * [Community Layouts](feature_layouts.md)
102 * [Unit Testing](unit_testing.md) 107 * [Unit Testing](unit_testing.md)
103 * [Useful Functions](ref_functions.md) 108 * [Useful Functions](ref_functions.md)
104 * [Configurator Support](reference_configurator_support.md)
105 * [info.json Format](reference_info_json.md) 109 * [info.json Format](reference_info_json.md)
106 110
107 * C Development 111 * C Development
@@ -121,6 +125,11 @@
121 * [QMK CLI Config](cli_configuration.md) 125 * [QMK CLI Config](cli_configuration.md)
122 * [Python CLI Development](cli_development.md) 126 * [Python CLI Development](cli_development.md)
123 127
128 * Configurator Development
129 * QMK API
130 * [Development Environment](api_development_environment.md)
131 * [Architecture Overview](api_development_overview.md)
132
124 * For a Deeper Understanding 133 * For a Deeper Understanding
125 * [How Keyboards Work](how_keyboards_work.md) 134 * [How Keyboards Work](how_keyboards_work.md)
126 * [Understanding QMK](understanding_qmk.md) 135 * [Understanding QMK](understanding_qmk.md)
diff --git a/docs/api_development_environment.md b/docs/api_development_environment.md
new file mode 100644
index 000000000..50647c429
--- /dev/null
+++ b/docs/api_development_environment.md
@@ -0,0 +1,3 @@
1# Development Environment Setup
2
3To setup a development stack head over to the [qmk_web_stack](https://github.com/qmk/qmk_web_stack).
diff --git a/docs/api_development_overview.md b/docs/api_development_overview.md
new file mode 100644
index 000000000..e55d03410
--- /dev/null
+++ b/docs/api_development_overview.md
@@ -0,0 +1,44 @@
1# QMK Compiler Development Guide
2
3This page attempts to introduce developers to the QMK Compiler. It does not go into nitty gritty details- for that you should read code. What this will give you is a framework to hang your understanding on as you read the code.
4
5# Overview
6
7The QMK Compile API consists of a few movings parts:
8
9![Architecture Diagram](https://raw.githubusercontent.com/qmk/qmk_api/master/docs/architecture.svg)
10
11API Clients interact exclusively with the API service. This is where they submit jobs, check status, and download results. The API service inserts compile jobs into [Redis Queue](https://python-rq.org) and checks both RQ and S3 for the results of those jobs.
12
13Workers fetch new compile jobs from RQ, compile them, and then upload the source and the binary to an S3 compatible storage engine.
14
15# Workers
16
17QMK Compiler Workers are responsible for doing the actual building. When a worker pulls a job from RQ it does several things to complete that job:
18
19* Make a fresh qmk_firmware checkout
20* Use the supplied layers and keyboard metadata to build a `keymap.c`
21* Build the firmware
22* Zip a copy of the source
23* Upload the firmware, source zip, and a metadata file to S3.
24* Report the status of the job to RQ
25
26# API Service
27
28The API service is a relatively simple Flask application. There are a few main views you should understand.
29
30## @app.route('/v1/compile', methods=['POST'])
31
32This is the main entrypoint for the API. A client's interaction starts here. The client POST's a JSON document describing their keyboard, and the API does some (very) basic validation of that JSON before submitting the compile job.
33
34## @app.route('/v1/compile/&lt;string:job_id&gt;', methods=['GET'])
35
36This is the most frequently called endpoint. It pulls the job details from redis, if they're still available, or the cached job details on S3 if they're not.
37
38## @app.route('/v1/compile/&lt;string:job_id&gt;/download', methods=['GET'])
39
40This method allows users to download the compiled firmware file.
41
42## @app.route('/v1/compile/&lt;string:job_id&gt;/source', methods=['GET'])
43
44This method allows users to download the source for their firmware.
diff --git a/docs/api_docs.md b/docs/api_docs.md
new file mode 100644
index 000000000..28a7dd71d
--- /dev/null
+++ b/docs/api_docs.md
@@ -0,0 +1,68 @@
1# QMK API
2
3This page describes using the QMK API. If you are an application developer you can use this API to compile firmware for any [QMK](https://qmk.fm) Keyboard.
4
5## Overview
6
7This service is an asynchronous API for compiling custom keymaps. You POST some JSON to the API, periodically check the status, and when your firmware has finished compiling you can download the resulting firmware and (if desired) source code for that firmware.
8
9#### Example JSON Payload:
10
11```json
12{
13 "keyboard": "clueboard/66/rev2",
14 "keymap": "my_awesome_keymap",
15 "layout": "LAYOUT_all",
16 "layers": [
17 ["KC_GRV","KC_1","KC_2","KC_3","KC_4","KC_5","KC_6","KC_7","KC_8","KC_9","KC_0","KC_MINS","KC_EQL","KC_GRV","KC_BSPC","KC_PGUP","KC_TAB","KC_Q","KC_W","KC_E","KC_R","KC_T","KC_Y","KC_U","KC_I","KC_O","KC_P","KC_LBRC","KC_RBRC","KC_BSLS","KC_PGDN","KC_CAPS","KC_A","KC_S","KC_D","KC_F","KC_G","KC_H","KC_J","KC_K","KC_L","KC_SCLN","KC_QUOT","KC_NUHS","KC_ENT","KC_LSFT","KC_NUBS","KC_Z","KC_X","KC_C","KC_V","KC_B","KC_N","KC_M","KC_COMM","KC_DOT","KC_SLSH","KC_RO","KC_RSFT","KC_UP","KC_LCTL","KC_LGUI","KC_LALT","KC_MHEN","KC_SPC","KC_SPC","KC_HENK","KC_RALT","KC_RCTL","MO(1)","KC_LEFT","KC_DOWN","KC_RIGHT"],
18 ["KC_ESC","KC_F1","KC_F2","KC_F3","KC_F4","KC_F5","KC_F6","KC_F7","KC_F8","KC_F9","KC_F10","KC_F11","KC_F12","KC_TRNS","KC_DEL","BL_STEP","KC_TRNS","KC_TRNS","KC_TRNS","KC_TRNS","KC_TRNS","KC_TRNS","_______","KC_TRNS","KC_PSCR","KC_SLCK","KC_PAUS","KC_TRNS","KC_TRNS","KC_TRNS","KC_TRNS","KC_TRNS","KC_TRNS","MO(2)","KC_TRNS","KC_TRNS","KC_TRNS","KC_TRNS","KC_TRNS","KC_TRNS","KC_TRNS","KC_TRNS","KC_TRNS","KC_TRNS","KC_TRNS","KC_TRNS","KC_TRNS","KC_TRNS","KC_TRNS","KC_TRNS","KC_TRNS","KC_TRNS","KC_TRNS","KC_TRNS","KC_TRNS","KC_TRNS","KC_TRNS","KC_TRNS","KC_TRNS","KC_PGUP","KC_TRNS","KC_TRNS","KC_TRNS","KC_TRNS","KC_TRNS","KC_TRNS","KC_TRNS","KC_TRNS","KC_TRNS","MO(1)","KC_LEFT","KC_PGDN","KC_RGHT"],
19 ["KC_TRNS","KC_TRNS","KC_TRNS","KC_TRNS","KC_TRNS","KC_TRNS","KC_TRNS","KC_TRNS","KC_TRNS","KC_TRNS","KC_TRNS","KC_TRNS","KC_TRNS","KC_TRNS","KC_TRNS","KC_TRNS","KC_TRNS","KC_TRNS","KC_TRNS","KC_TRNS","RESET","KC_TRNS","KC_TRNS","KC_TRNS","KC_TRNS","KC_TRNS","KC_TRNS","KC_TRNS","KC_TRNS","KC_TRNS","KC_TRNS","KC_TRNS","KC_TRNS","MO(2)","KC_TRNS","KC_TRNS","KC_TRNS","KC_TRNS","KC_TRNS","KC_TRNS","KC_TRNS","KC_TRNS","KC_TRNS","KC_TRNS","KC_TRNS","KC_TRNS","KC_TRNS","KC_TRNS","KC_TRNS","KC_TRNS","KC_TRNS","KC_TRNS","KC_TRNS","KC_TRNS","KC_TRNS","KC_TRNS","KC_TRNS","KC_TRNS","KC_TRNS","KC_TRNS","KC_TRNS","KC_TRNS","KC_TRNS","KC_TRNS","KC_TRNS","KC_TRNS","KC_TRNS","KC_TRNS","KC_TRNS","MO(1)","KC_TRNS","KC_TRNS","KC_TRNS"]
20 ]
21}
22```
23
24As you can see the payload describes all aspects of a keyboard necessary to create and generate a firmware. Each layer is a single list of QMK keycodes the same length as the keyboard's `LAYOUT` macro. If a keyboard supports mulitple `LAYOUT` macros you can specify which macro to use.
25
26## Submitting a Compile Job
27
28To compile your keymap into a firmware simply POST your JSON to the `/v1/compile` endpoint. In the following example we've placed the JSON payload into a file named `json_data`.
29
30```
31$ curl -H "Content-Type: application/json" -X POST -d "$(< json_data)" http://api.qmk.fm/v1/compile
32{
33 "enqueued": true,
34 "job_id": "ea1514b3-bdfc-4a7b-9b5c-08752684f7f6"
35}
36```
37
38## Checking The Status
39
40After submitting your keymap you can check the status using a simple HTTP GET call:
41
42```
43$ curl http://api.qmk.fm/v1/compile/ea1514b3-bdfc-4a7b-9b5c-08752684f7f6
44{
45 "created_at": "Sat, 19 Aug 2017 21:39:12 GMT",
46 "enqueued_at": "Sat, 19 Aug 2017 21:39:12 GMT",
47 "id": "f5f9b992-73b4-479b-8236-df1deb37c163",
48 "status": "running",
49 "result": null
50}
51```
52
53This shows us that the job has made it through the queue and is currently running. There are 5 possible statuses:
54
55* **failed**: Something about the compiling service has broken.
56* **finished**: The compilation is complete and you should check `result` to see the results.
57* **queued**: The keymap is waiting for a compilation server to become available.
58* **running**: The compilation is in progress and should be complete soon.
59* **unknown**: A serious error has occurred and you should [file a bug](https://github.com/qmk/qmk_compiler/issues).
60
61## Examining Finished Results
62
63Once your compile job has finished you'll check the `result` key. The value of this key is a hash containing several key bits of information:
64
65* `firmware_binary_url`: A list of URLs for the the flashable firmware
66* `firmware_keymap_url`: A list of URLs for the the `keymap.c`
67* `firmware_source_url`: A list of URLs for the full firmware source code
68* `output`: The stdout and stderr for this compile job. Errors will be found here.
diff --git a/docs/api_overview.md b/docs/api_overview.md
new file mode 100644
index 000000000..91d317f06
--- /dev/null
+++ b/docs/api_overview.md
@@ -0,0 +1,15 @@
1# QMK API
2
3The QMK API provides an asynchronous API that Web and GUI tools can use to compile arbitrary keymaps for any keyboard supported by [QMK](http://qmk.fm/). The stock keymap template supports all QMK keycodes that do not require supporting C code. Keyboard maintainers can supply their own custom templates to enable more functionality.
4
5## App Developers
6
7If you are an app developer interested in using this API in your application you should head over to [Using The API](api_docs.md).
8
9## Keyboard Maintainers
10
11If you would like to enhance your keyboard's support in the QMK Compiler API head over to the [Keyboard Support](reference_configurator_support.md) section.
12
13## Backend Developers
14
15If you are interested in working on the API itself you should start by setting up a [Development Environment](api_development_environment.md), then check out [Hacking On The API](api_development_overview.md).