The (mt) Media Temple API provides several query parameters that can be used across resource requests to perform common operations.
HTTP Query Parameters
The following is a list of query parameters that are globally available across resource requests.
Param | Description | Default | Example |
---|---|---|---|
apikey | The API key used to authenticate requests. See also API HTTP headers. | <empty> | /v1/stats?apikey=FbDgBldQMoKLwIXsBwq... see also API HTTP headers |
wrapRoot | Wrap the json object with the root object name | true | For a person object with a single field "name", the JSON representation would change from {escape}{ "name": "Joe" }{escape} to {escape}{ "person": { "name": "Joe" } }{escape} |
prettyPrint | Format the response output with indentation and newlines | false | ... |
fieldList | A list of all fields to include in the response (implicitly excludes all not specified) | ... | fieldList=person.name |
excludeList | A list of all fields to exclude from the response | ... | excludeList=person.name |
includeList | A list of all fields to include in the response. This can be used to include fields documented as not being returned by default | ... | includeList=person.name |
_method | This parameter is used to override the HTTP method of the request (e.g. to support PUT in an HTTP/REST client with only POST capabilities) | ... | _method=PUT |
_format | This parameter is used to specify the content type the request/response | ... | _format=json |
Field Filtering
Field filtering is useful should one want to exclude undesired fields from API responses in order to conserve bandwidth or streamline parsing on the client-side.
All fields specified in fieldList, excludeList, and includeList query parameters should be in the following form.
<rootElement>.<childElement>
Note: If wrapRoot is set to false for the JSON format, then rootElement should be omitted.
Field Filtering Example - Specifying Response Fields
To only get the timeStamp and cpu fields from a response like the following.
{
"stats" : {
"timeStamp" : 1284689449,
"cpu" : 69.51,
"memory" : 59.58,
"load1Min" : 19.86,
"load5Min" : 29.79,
"load15Min" : 39.72,
"processes" : 84,
"diskSpace" : 49.65,
"kbytesIn" : 79.44,
"kbytesOut" : 89.37,
"packetsIn" : 99.31,
"packetsOut" : 109.24,
"state" : 1
}
}
You would simply add fieldList=stats.timeStamp,stats.cpu to the request, which would result in a filtered document that looks like the following.
{
"stats" : {
"timeStamp" : 1284689449,
"cpu" : 69.51
}
}
However, if wrapRoot is set to false (JSON), then you could simply use fieldList=timeStamp,cpu in the request.
Field Filtering Example - Excluding Response Fields
To exclude timeStamp from a response like the following.
<?xml version="1.0" encoding="UTF-8"?> <stats> <timeStamp>1284686518</timeStamp> <cpu>25.86</cpu> <memory>22.17</memory> <load1Min>7.39</load1Min> <load5Min>11.08</load5Min> <load15Min>14.78</load15Min> <processes>46</processes> <diskSpace>18.47</diskSpace> <kbytesIn>29.56</kbytesIn> <kbytesOut>33.25</kbytesOut> <packetsIn>36.95</packetsIn> <packetsOut>40.64</packetsOut> <state>1</state> </stats>
You would simply add excludeList=stats.timeStamp to the request, which would result in a filtered document that looks like the following.
<?xml version="1.0" encoding="UTF-8"?> <stats> <cpu>25.86</cpu> <memory>22.17</memory> <load1Min>7.39</load1Min> <load5Min>11.08</load5Min> <load15Min>14.78</load15Min> <processes>46</processes> <diskSpace>18.47</diskSpace> <kbytesIn>29.56</kbytesIn> <kbytesOut>33.25</kbytesOut> <packetsIn>36.95</packetsIn> <packetsOut>40.64</packetsOut> <state>1</state> </stats>
The same filter would also apply to JSON with wrapRoot set to true (default). However, if wrapRoot is set to false, then you would simply use excludeList=timeStamp in the request. Multiple fields can be excluded by simply adding them to the list, using comma as a separator (e.g. excludeList=timeStamp,cpu will exclude the timeStamp and cpu fields from the response).