Motion - Motion Http API

API for HTTP Interface for Motion

Output Modes

The HTTP Interface have two output modes :

  • HTML : To use it from a web browser.
  • RAW : To easily be parsed from any fronted ( php , python , perl , GTK , etc ... ).

The URL

URL consists of the following parts

http://motionhost.mydomain.tld:port/thread/command/subcommand?parameter=value

URL with no path

http://motionhost.mydomain.tld:port

makes Motion returns a webpage that gives a short status and lists the threads as links.

Example with 3 thread config files ( HTML Mode ).

<body>
Motion version 3.1.20 running 3 threads.
[[/0][All]]
[[/1][Thread 1]]
[[/2][Thread 2]]
[[/3][Thread 3]]
</body>

  • RAW Mode

Motion version 3.1.20 running 3 threads.\n
0\n
1\n
2\n
3\n

And clicking thread 1 will give you the next section.

URL with only thread number

Thread 0 represents the default values. If there is only one camera and no thread files it is the one and only camera you control.

The URL

http://motionhost.mydomain.tld:port/thread

Example

http://motionhost.mydomain.tld:port/2

Returns this HTML, here shown as example with thread 1.

<body>
[[/2/config][Configuration]]<br />
[[/2/action][Action]]<br />
[[/2/detection][Detection]]<br />
[[/2/track][Tracking]]<br />
[[/2][
</body>]]

* RAW Mode

config\n
action\n
detection\n
track\n

Config Parameters

http://motionhost.mydomain.tld:port/2/config

<body>
[[/2/config/list][list]]<br />
[[/2/config/write][write]]<br />
[[/2/config/set][set]]<br />
[[/2/config/get][get]]<br />
[[/2/][
</body>]]

* RAW Mode

list\n
write\n
set\n
get\n

Config List

http://motionhost.mydomain.tld:port/2/config/list

Simply lists all parameters - maybe with their current values.

Write config

That option will write the current settings to config file. Only for HTML mode write command will ask for confirmation.

http://motionhost.mydomain.tld:port/2/config/write

<body>
Are you sure? [[/%d/config/writeyes][Yes]]<br />
[[/%d/config][No]]
</body>

  • RAW mode

Thread %d write\n
Done\n

Write directly without confirmation

http://motionhost.mydomain.tld:port/2/config/writeyes

<body>
<b>Thread %d</b> write done !<br />
[[/%d/config][
</body>]]

  • RAW mode

Thread %d write\n
Done\n

Set config option value

Set a value for a parameter.

http://motionhost.mydomain.tld:port/2/config/set?user_text=value

returns something like this


<head></head>
<body>

   * [[/2/config/set?user_text][user_text]] = value

<b>Done</b><br />
[[/2/config/list][
</body>]]

  • RAW Mode

user_text = value\n
Done\n

You can also clear/disable config options.

http://motionhost.mydomain.tld:port/2/config/set?despeckle=

Parameters will do this conversion:

   string will become (null)
   int will become 0
   boolean will become false

the value will be urlencoded .

Get config option value

Get the value of the requested parameter.

http://motionhost.mydomain.tld:port/2/config/get?query=user_text

returns something like this

<body>
Motion thread 2<br />

   * user_text = "value"

[[/2/config/list][
</body>]]

  • RAW Mode

Motion thread 2\n
user_text = value\n
Done\n

Action Commands

  • makemovie , force to make a movie.
  • snapshot , force to take a snapshot.
  • restart , restart motion , reading again the config files for all threads.
  • quit , exit motion.

http://motionhost.mydomain.tld:port/2/action

makes Motion return a webpage that looks like this

<body>
[[/2/action/makemovie][Make Movie]]<br />
[[/2/action/snapshot][Snapshot]]<br />
[[/2/action/restart][Restart]]<br />
[[/2/action/quit][Quit]]<br />
[[/2][
</body>]]

  • RAW Mode

makemovie\n
snapshot\n
restart\n
quit\n

http://motionhost.mydomain.tld:port/2/action/makemovie

Makes a movie. This is the response

<body>
Movie Made for Thread 2<br />
[[/2/action][
</body>]]

  • RAW Mode

Movie Made for Thread 2\n
Done\n

Detection Commands

  • status , returns the detection status.
  • start , enable detection.
  • pause , pauses detection.
  • connection, show the status device connection. ( from 3.2.8 )

http://motionhost.mydomain.tld:port/2/detection

makes Motion return a webpage that looks like this

<body>
[[/2/detection/status][status]]<br />
[[/2/detection/start][start]]<br />
[[/2/detection/pause][pause]]<br />
[[/2/detection/connection][connection]]<br />
[[/2][
</body>]]

  • RAW Mode

status\n
start\n
pause\n
connection\n

http://motionhost.mydomain.tld:port/2/detection/start

Start detection. This is the response

<body>
Detection start for Thread 2<br />
[[/2/detection][
</body>]]

  • RAW Mode

Detection start for Thread 2\n
Done\n

Track Commands

http://motionhost.mydomain.tld:port/2/track

makes Motion return a webpage that looks like this

<body>
[[/2/track/set][Track Set Pan/Tilt]]<br />
[[/2/track/auto][Track Auto]]<br />
[[/2][
</body>]]

  • RAW Mode

set\n
auto\n

Track Set

Sets absoute or relative position for tracking devices.

http://motionhost.mydomain.tld:port/2/track/set?pan=10&tilt=5

makes Motion return a webpage that looks like this

<body>
Track Set relative 10 5 for Thread 2<br />
[[/2/track][
</body>]]

  • RAW Mode

Track Set relative 10 5 for Thread 2\n
Done\n

Track Set Absolute

Set an absolute position.

http://motionhost.mydomain.tld:port/2/track/set?x=5&y=10

makes Motion return a webpage that looks like this

<body>
Track Set Absolute Pan 5 Tilt 10 for Thread 2<br />
[[/2/track][
</body>]]

  • RAW Mode

Track Set Absolute Pan 5 Tilt 10 for Thread 2\n
Done\n

Track Set relative

Set a relative position to current one .

http://motionhost.mydomain.tld:port/2/track/set?pan=10&tilt=-5

makes Motion return a webpage that looks like this

<body>
Track Relative Pan 10 Tilt -5 for Thread 2<br />
[[/2/track][
</body>]]

  • RAW Mode

Track Relative Pan 10 Tilt -5 for Thread 2\n
Done\n

Track Auto

  • 0 Disable, Auto tracking feature.
  • 1 Enable, Auto tracking feature.
  • status Check the status of Auto tracking feature.

http://motionhost.mydomain.tld:port/2/track/auto?value=1

makes Motion return a webpage that looks like this

<body>
Track Auto Enable for Thread 2<br />
[[/2/track][
</body>]]

  • RAW Mode

Track Auto Enable for Thread 2\n
Done\n

Authentication

The deal of authentication is to provide a level of security to grant/deny access to motion configuration using HttpAPI.

Basic Auth

This method is the same that supports apache, so login/pass will be added as a new parameter to motion.conf only :

http_authentication login:pass

The client should send that as HTTP RFC specifies, http browsers will work without any problem.

-- AngelCarpintero - 11 Nov 2007
Topic revision: r34 - 28 Feb 2015, AlAl
Copyright © 1999-2016 by the contributing authors. All material on this collaboration platform is the property of the contributing authors.
Please do not email Kenneth for support questions (read why). Use the Support Requests page or join the Mailing List.
This website only use harmless session cookies. See Cookie Policy for details. By using this website you accept the use of these cookies.