Commit c86d194c authored by Joel Collins's avatar Joel Collins
Browse files

Added request examples to docs

parent 1bbe2347
Loading
Loading
Loading
Loading
+10 −2
Original line number Diff line number Diff line
@@ -9,9 +9,17 @@ Summary
   :endpoints:

Details
-----------
-------
.. autoflask:: openflexure_microscope.api.app:app
   :undoc-endpoints: index
   :undoc-static:
   :endpoints:
   :order: path

Example Requests
----------------

.. toctree::
   :maxdepth: 2

   ./apirequests.rst
 No newline at end of file
+106 −0
Original line number Diff line number Diff line
Introduction
------------

In these examples, our microscope is located at the IP ``192.168.1.126``, running on port 5000.


New Image Capture
-----------------

Temprary capture, using video port.

CURL
++++
.. code-block:: none

   curl -X POST -H "Content-Type: application/json" -d \\
   '{"temporary": true, "use_video_port": true}' http://192.168.1.126:5000/api/v1/camera/capture

HTTPie
++++++
.. code-block:: none

   http POST http://192.168.1.126:5000/api/v1/camera/capture temporary:=true use_video_port:=true

Python Requests
+++++++++++++++
.. code-block:: python

   json_payload = {
        "keep_on_disk": keep_on_disk,
        "use_video_port": use_video_port
   }
   requests.post('http://192.168.1.126:5000/api/v1/camera/capture', json=json_payload)

Update Config
-------------

Example, changing picamera shutter speed to 2000, and the JPEG quality to 90.

CURL
++++
.. code-block:: none

   curl -X POST -H "Content-Type: application/json" -d \\
   '{"picamera_settings": {"shutter_speed": 2000}, "jpeg_quality": 90}' http://192.168.1.126:5000/api/v1/config

HTTPie
++++++
.. code-block:: none

   http POST http://192.168.1.126:5000/api/v1/config jpeg_quality:=90 picamera_settings:='{"shutter_speed": 2000}'

Python Requests
+++++++++++++++
.. code-block:: python

   json_payload = {
        "jpeg_quality": 90,
        "picamera_settings": {"shutter_speed": 2000}
   }
   requests.post('http://192.168.1.126:5000/api/v1/config', json=json_payload)

Read Config
-----------

CURL
++++
.. code-block:: none

   curl http://192.168.1.126:5000/api/v1/config

HTTPie
++++++
.. code-block:: none

   http GET http://192.168.1.126:5000/api/v1/config

Python Requests
+++++++++++++++
.. code-block:: python

   requests.get('http://192.168.1.126:5000/api/v1/config')

Recalibrate Picamera
--------------------

Starts the automatic recalibration plugin

CURL
++++
.. code-block:: none

   curl -X POST -H "Content-Type: application/json" \\
   http://192.168.1.126:5000/api/v1/plugin/default/camera_calibration/recalibrate

HTTPie
++++++
.. code-block:: none

   http POST http://192.168.1.126:5000/api/v1/plugin/default/camera_calibration/recalibrate

Python Requests
+++++++++++++++
.. code-block:: python

   requests.post('http://192.168.1.126:5000/api/v1/plugin/default/camera_calibration/recalibrate')
 No newline at end of file