Admin.getMetrics
From Facebook Developers Wiki
Contents |
[edit] Description
Returns values for the application metrics displayed on the Usage and HTTP Request tabs of the application's Insights page.
You can view the metrics in 1-day, 7-day, and 30-day increments over a given date range, which cannot exceed 30 days. This way, you can review metrics for all of the 1-day, 7-day, and 30-day periods that end within the given date range.
The list of metrics includes:
Usage Metrics
-
active_users-- (The number of active users.) -
api_calls-- (The number of API calls made by your application.) -
unique_api_calls-- (The number of users on whose behalf your application made API calls.) -
canvas_page_views-- (The number of canvas page views.) -
unique_canvas_page_views-- (The number of users who viewed your application's canvas page.) -
canvas_http_request_time_avg-- (The average time to fulfill an HTTP request to your application's canvas page.) -
canvas_fbml_render_time_avg-- (The average time to render FBML on your application's canvas page.) -
unique_adds-- (The number of users who added your application. 1-day only.) -
unique_removes-- (The number of users who removed your application. 1-day only.) -
unique_blocks-- (The number of users who blocked your application. 1-day only.) -
unique_unblocks-- (The number of users who unblocked your application. 1-day only.)
HTTP Request Metrics
The following metrics are only available for the 1-day period.
-
canvas_page_views_http_code_0-- (The number of canvas page views that timed out.) -
canvas_page_views_http_code_100-- (The number of canvas page views that returned HTTP code 100 -- Continue.) -
canvas_page_views_http_code_200-- (The number of canvas page views that returned HTTP code 200 -- OK.) -
canvas_page_views_http_code_200ND-- (The number of canvas page views that returned HTTP code 200 -- OK -- and no data.) -
canvas_page_views_http_code_301-- (The number of canvas page views that returned HTTP code 301 -- Moved Permanently.) -
canvas_page_views_http_code_302-- (The number of canvas page views that returned HTTP code 302 -- Found.) -
canvas_page_views_http_code_303-- (The number of canvas page views that returned HTTP code 303 -- See Other.) -
canvas_page_views_http_code_400-- (The number of canvas page views that returned HTTP code 400 -- Bad Request.) -
canvas_page_views_http_code_401-- (The number of canvas page views that returned HTTP code 401 -- Unauthorized.) -
canvas_page_views_http_code_403-- (The number of canvas page views that returned HTTP code 403 -- Forbidden.) -
canvas_page_views_http_code_404-- (The number of canvas page views that returned HTTP code 404 -- Not Found.) -
canvas_page_views_http_code_405-- (The number of canvas page views that returned HTTP code 405 -- Method Not Allowed.) -
canvas_page_views_http_code_413-- (The number of canvas page views that returned HTTP code 413 -- Request Entity Too Large.) -
canvas_page_views_http_code_422-- (The number of canvas page views that returned HTTP code 422 -- Unprocessable Entity.) -
canvas_page_views_http_code_500-- (The number of canvas page views that returned HTTP code 500 -- Internal Server Error.) -
canvas_page_views_http_code_502-- (The number of canvas page views that returned HTTP code 502 -- Bad Gateway.) -
canvas_page_views_http_code_503-- (The number of canvas page views that returned HTTP code 503 -- Service Unavailable.) -
canvas_page_views_http_code_505-- (The number of canvas page views that returned HTTP code 505 -- HTTP Version Not Supported.)
[edit] Parameters
| Required | Name | Type | Description | |
| required | api_key | string | The application key associated with the calling application. | |
|---|---|---|---|---|
| sig | string | An MD5 hash of the current request and your secret key, as described in the How Facebook Authenticates Your Application. | ||
| v | string | This must be set to 1.0 to use this version of the API. | ||
| start_time | int | A Unix time for the start of the range (inclusive). | ||
| end_time | int | A Unix time for the end of the range (inclusive). The end_time cannot be more than 30 days after the start_time. | ||
| period | int | The length of the period, in seconds, during which the metrics were collected. Currently, the only supported periods are 86400 (1 day), 604800 (7-days), and 2592000 (30 days). | ||
| metrics | json array | A JSON-encoded list of metrics to retrieve (e.g. ["active_users", "canvas_page_views"]). | ||
| optional | format | string | Desired response format. Either XML (default) or JSON. | |
| callback | string | Name of a function to call. This is primarily to enable cross-domain JavaScript requests using the <script> tag, also known as JSONP, and works with both the XML and JSON formats. The function will be called with the response passed as the parameter. |
[edit] Example Requests
| // Fetches active users and canvas page views for the two 7-day periods ending June 19th and June 20th. $result = $fb->api_client->admin_getMetrics(1213858800, 1213945200, 604800, array('active_users', 'canvas_page_views')); |
[edit] Example Return XML
| <?xml version="1.0" encoding="UTF-8"?> <admin_getMetrics_response xmlns="http://api.facebook.com/1.0/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://api.facebook.com/1.0/ http://api.facebook.com/1.0/facebook.xsd" list="true"> <metrics> <end_time>1213858800</end_time> <active_users>2147</active_users> <canvas_page_views>6045</canvas_page_views> </metrics> <metrics> <end_time>1213945200</end_time> <active_users>2221</active_users> <canvas_page_views>6174</canvas_page_views> </metrics> </admin_getMetrics_response> |
[edit] Response
This method returns the metrics specified for the given range and time period.
[edit] FQL Equivalent
This function is similar to doing the following FQL query:
| SELECT end_time, active_users, canvas_page_views FROM metrics WHERE end_time IN (1213858800, 1213945200) AND period = 604800 |
[edit] Error Codes
| Code | Description | |
| 1 | An unknown error occurred. Please resubmit the request. | |
|---|---|---|
| 4 | The application has reached the maximum number of requests allowed. More requests are allowed once the time window has completed. | |
| 100 | One of the parameters specified was missing or invalid. |
[edit] Notes
- A single day is defined as from midnight to midnight, Pacific Time. Each day is identified in the response by the end of the collection period.
- This method does not require a
session_key, unless it is being called by a desktop application.
