Admin.getDailyMetrics
From Facebook Developers Wiki
Contents |
[edit] Description
Returns values for the daily application metrics displayed on the Usage and HTTP Request tabs of the application's Insights page. You can view the metrics over a given date range, which must not exceed 30 days.
The list of metrics includes:
Usage Metrics
-
daily_active_users-- (The number of daily active users.) -
unique_adds-- (The number of users who added your application.) -
unique_removes-- (The number of users who removed your application.) -
unique_blocks-- (The number of users who blocked your application.) -
unique_unblocks-- (The number of users who unblocked your application.) -
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.)
HTTP Request Metrics
-
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 authentication guide. | ||
| v | string | This must be set to 1.0 to use this version of the API. | ||
| start_date | int | A Unix time for the start of the date range (inclusive). | ||
| end_date | int | A Unix time for the end of the date range (inclusive). | ||
| metrics | json array | A JSON-encoded list of daily metrics to retrieve (e.g. ["daily_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 Request
| // Fetches daily active users and canvas page views for yesterday and the day before $result = $fb->api_client->admin_getDailyMetrics(strtotime('yesterday') - 24*60*60, strtotime('yesterday'), array('daily_active_users', 'canvas_page_views')); |
[edit] Example Return XML
| <?xml version="1.0" encoding="UTF-8"?> <admin_getDailyMetrics_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"> <daily_metrics> <date>1206860400</date> <daily_active_users>182</daily_active_users> <canvas_page_views>125</canvas_page_views> </daily_metrics> <daily_metrics> <date>1206946800</date> <daily_active_users>321</daily_active_users> <canvas_page_views>304</canvas_page_views> </daily_metrics> </admin_getDailyMetrics_response> |
[edit] Response
This method returns the daily metrics specified for the given date range.
[edit] FQL Equivalent
This function is similar to doing the following FQL query:
| SELECT date, daily_active_users, canvas_page_views FROM daily_metrics WHERE date IN (1206860400, 1206946800) |
[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
- The metrics are calculated from midnight to midnight, Pacific Time, and are identified in the response by the start of the date range. Therefore, callers are advised to specify Unix times corresponding to midnight, Pacific Time.
