Unsampled Reports: list

अनुमति की ज़रूरत है

यह पूरे डेटा पर आधारित ऐसी रिपोर्ट की सूची बनाता है जिनका ऐक्सेस उपयोगकर्ता के पास होता है. उदाहरण देखें.

अनुरोध

एचटीटीपी अनुरोध

GET https://www.googleapis.com/analytics/v3/management/accounts/accountId/webproperties/webPropertyId/profiles/profileId/unsampledReports

पैरामीटर

पैरामीटर का नाम वैल्यू ब्यौरा
पाथ पैरामीटर
accountId string खाता आईडी, जिसकी मदद से पूरे डेटा पर आधारित रिपोर्ट को वापस पाया जा सकता है. कोई खास खाता आईडी होना चाहिए, ~सभी काम नहीं करता.
profileId string पूरे डेटा पर आधारित रिपोर्ट पाने के लिए, प्रोफ़ाइल आईडी देखें. कोई खास व्यू (प्रोफ़ाइल) आईडी होना चाहिए, ~सभी काम नहीं करता.
webPropertyId string वेब प्रॉपर्टी आईडी, जिसकी मदद से पूरे डेटा पर आधारित रिपोर्ट को वापस पाया जा सकता है. कोई खास वेब प्रॉपर्टी आईडी होना चाहिए, ~all काम नहीं करता.
वैकल्पिक क्वेरी पैरामीटर
max-results integer इस रिस्पॉन्स में शामिल की जाने वाली, पूरे डेटा पर आधारित रिपोर्ट की ज़्यादा से ज़्यादा संख्या.
start-index integer फिर से हासिल की जाने वाली पहली नमूनारहित रिपोर्ट का इंडेक्स. इस पैरामीटर का इस्तेमाल, सबसे ज़्यादा नतीजे वाले पैरामीटर के साथ-साथ पेज पर नंबर डालने के तरीके के तौर पर करें.

अनुमति

इस अनुरोध के लिए, इनमें से कम से कम एक स्कोप के साथ अनुमति देना ज़रूरी है (पुष्टि करने और अनुमति देने के बारे में ज़्यादा पढ़ें).

स्कोप
https://www.googleapis.com/auth/analytics
https://www.googleapis.com/auth/analytics.edit
https://www.googleapis.com/auth/analytics.readonly

अनुरोध का मुख्य भाग

इस तरीके का इस्तेमाल करके, अनुरोध का मुख्य हिस्सा न दें.

जवाब

अगर यह तरीका काम करता है, तो यह इस स्ट्रक्चर का इस्तेमाल करके रिस्पॉन्स का मुख्य हिस्सा दिखाता है:

{
  "kind": "analytics#unsampledReports",
  "username": string,
  "totalResults": integer,
  "startIndex": integer,
  "itemsPerPage": integer,
  "previousLink": string,
  "nextLink": string,
  "items": [
    management.unsampledReports Resource
  ]
}
प्रॉपर्टी का नाम वैल्यू ब्यौरा ज़रूरी जानकारी
kind string कलेक्शन का टाइप.
username string पुष्टि किए गए उपयोगकर्ता का ईमेल आईडी
totalResults integer नतीजे में संसाधनों की संख्या पर ध्यान दिए बिना, क्वेरी के लिए नतीजों की कुल संख्या.
startIndex integer रिसॉर्स का शुरुआती इंडेक्स, जो डिफ़ॉल्ट रूप से 1 होता है या स्टार्ट-इंडेक्स क्वेरी पैरामीटर से तय होता है.
itemsPerPage integer रिस्पॉन्स में शामिल किए जा सकने वाले संसाधनों की ज़्यादा से ज़्यादा संख्या. इससे फ़र्क़ नहीं पड़ता कि रिस्पॉन्स में कितने संसाधन वापस किए गए हैं. इसकी वैल्यू, डिफ़ॉल्ट रूप से 1,000 वैल्यू के साथ 1 से 1,000 तक की रेंज में हो सकती है. इसके अलावा, इसकी वैल्यू 'सबसे ज़्यादा नतीजे वाले क्वेरी' पैरामीटर से भी तय की जा सकती है.
items[] list पूरे डेटा पर आधारित रिपोर्ट की सूची.

उदाहरण

ध्यान दें: इस तरीके के लिए दिए गए कोड के उदाहरणों में इसके साथ काम करने वाली सभी प्रोग्रामिंग भाषाएं नहीं दिखाई गई हैं (इसके साथ काम करने वाली भाषाओं की सूची के लिए क्लाइंट लाइब्रेरी वाला पेज देखें).

Java

Java क्लाइंट लाइब्रेरी का इस्तेमाल करता है.

/*
 * Note: This code assumes you have an authorized Analytics service object.
 * See the Unsampled Reports Developer Guide for details.
 */

/*
 * Example #1:
 * Requests a list of all unsampled reports for the authorized user.
 */

try {
  UnsampledReports reports = analytics.management().
      unsampledReports().list("123456", "UA-123456-1", "7654321").execute();
} catch (GoogleJsonResponseException e) {
  System.err.println("There was a service error: "
      + e.getDetails().getCode() + " : "
      + e.getDetails().getMessage());
}

/*
 * Example 2:
 * The results of the list method are stored in the reports object.
 * The following code shows how to iterate through them.
 */
for (UnsampledReport report : reports.getItems()) {
  System.out.println("Account Id = " + report.getAccountId());
  System.out.println("Property Id  = " + report.getWebPropertyId());
  System.out.println("Report Id = " + report.getId());
  System.out.println("Report Title = " + report.getTitle());
  System.out.println("Report Kind = " + report.getKind());
  System.out.println("Report start-date = " + report.getStartDate());
  System.out.println("Report end-date = " + report.getEndDate());
  System.out.println("Report metric = " + report.getMetrics());
  System.out.println("Report dimensions = " + report.getDimensions());
  System.out.println("Report filters = " + report.getFilters());
  System.out.println("Report Status = " + report.getStatus());
  System.out.println("Report downloadType = " + report.getDownloadType());
  DriveDownloadDetails drive = report.getDriveDownloadDetails();
  CloudStorageDownloadDetails cloud = report.getCloudStorageDownloadDetails();
  System.out.println("Drive Document id = " + drive.getDocumentId());
  System.out.println("Cloud Bucket Id = " + cloud.getBucketId());
  System.out.println("Cloud Object Id = " + cloud.getObjectId());
}

PHP

PHP क्लाइंट लाइब्रेरी का इस्तेमाल किया जाता है.

/**
 * Note: This code assumes you have an authorized Analytics service object.
 * See the Unsampled Reports Developer Guide for details.
 */

/**
 * Example #1:
 * Requests a list of all unsampled reports for the authorized user.
 */
try {
  $reports = $analytics->management_unsampledReports
      ->listManagementUnsampledReports('123456', 'UA-123456-1', '7654321');

} catch (apiServiceException $e) {
  print 'There was an Analytics API service error '
      . $e->getCode() . ':' . $e->getMessage();

} catch (apiException $e) {
  print 'There was a general API error '
      . $e->getCode() . ':' . $e->getMessage();
}


/**
 * Example #2:
 * The results of the list method are stored in the reports object.
 * The following code shows how to iterate through them.
 */
foreach ($reports->getItems() as $report) {
  $drive = $report->getDriveDownloadDetails();
  $cloud = $report->getCloudStorageDownloadDetails();
  $html = <<<HTML
<pre>
Account Id          = {$report->getAccountId()}
Property Id         = {$report->getWebPropertyId()}
Report Id           = {$report->getId()}
Report Title        = {$report->getTitle()}
Report Kind         = {$report->getKind()}
Report start-date   = {$report->getStartDate()}
Report end-date     = {$report->getEndDate()}
Report metric       = {$report->getMetrics()}
Report dimensions   = {$report->getDimensions()}
Report filters      = {$report->getFilters()}
Report Status       = {$report->getStatus()}
Report downloadType = {$report->getDownloadType()}
Drive Document id   = {$drive->getDocumentId()}
Cloud Bucket Id     = {$cloud->getBucketId()}
Cloud Object Id     = {$cloud->getObjectId()}
</pre>

HTML;
  print $html;
}

Python

Python क्लाइंट लाइब्रेरी का इस्तेमाल करता हो.

# Note: This code assumes you have an authorized Analytics service object.
# See the Unsampled Reports Developers Guide for details.

# Example #1:
# Requests a list of all Unsampled Reports for the authorized user.
try:
  reports = analytics.management().unsampledReports().list(
      accountId='1234567',
      webPropertyId='UA-1234567-1',
      profileId='7654321'
  ).execute()

except TypeError, error:
  # Handle errors in constructing a query.
  print 'There was an error in constructing your query : %s' % error

except HttpError, error:
  # Handle API errors.
  print ('There was an API error : %s : %s' %
         (error.resp.status, error.resp.reason))


# Example #2:
# The results of the list method are stored in the reports object.
# The following code shows how to iterate through them.
for report in reports.get('items', []):
  driveDownloadDetails = report.get('driveDownloadDetails', {})
  cloudStorageDownloadDetails = report.get('cloudStorageDownloadDetails', {})

  print 'Account Id            = %s' % report.get('accountId')
  print 'Property Id           = %s' % report.get('webPropertyId')
  print 'Report Id             = %s' % report.get('id')
  print 'Report Title          = %s' % report.get('title')
  print 'Report Kind           = %s' % report.get('kind')
  print 'Report start-date = %s' % report.get('start-date')
  print 'Report end-date = %s' % report.get('end-date')
  print 'Report metrics        = %s' % report.get('metrics')
  print 'Report dimensions = %s' % report.get('dimensions')
  print 'Report filters = %s' % report.get('filters')
  print 'Report Status         = %s\n' % report.get('status')
  print 'Report downloadType = %s' % report.get('downloadType')
  print 'Drive Document Id = %s' % driveDownloadDetails.get('document Id')
  print 'Cloud Bucket Id = %s' % cloudStorageDownloadDetails.get('bucketId')
  print 'Cloud Object Id = %s' % cloudStorageDownloadDetails.get('objectId')
  print 'Report Created = %s' % report.get('created')
  print 'Report Updated = %s' % report.get('updated')






JavaScript

JavaScript क्लाइंट लाइब्रेरी का इस्तेमाल करता हो.

/*
 * Note: This code assumes you have an authorized Analytics client object.
 * See the Unsampled Reports Developer Guide for details.
 */

/*
 * Example 1:
 * Requests a list of all unsampled reports for the authorized user.
 */
function listUnsampledReports() {
  var request = gapi.client.analytics.management.unsampledReports.list({
    'accountId': '123456',
    'webPropertyId': 'UA-123456-1',
    'profileId': '7654321'
  });
  request.execute(printViews);
}

/*
 * Example 2:
 * The results of the list method are passed as the results object.
 * The following code shows how to iterate through them.
 */
function printUnsampledReports(results) {
  if (results && !results.error) {
    var reports = results.items;
    for (var i = 0, report; report = reports[i]; i++) {
      console.log('Account Id: ' + report.accountId);
      console.log('Property Id: ' + report.webPropertyId);
      console.log('Report Id: ' + report.id);
      console.log('Report Title: ' + report.title);
      console.log('Report Kind: ' + report.kind);
      console.log('Report start-date:' + report.start-date);
      console.log('Report end-date:' + report.end-date);
      console.log('Report metrics: ' + report.metrics);
      console.log('Report dimensions:' + report.dimensions);
      console.log('Report filters: ' + report.filters);
      console.log('Report Status: ' + report.status);
      console.log('Report downloadType: ' + report.downloadType);

      // Drive document details.
      if (report.driveDownloadDetails) {
        var details = report.driveDownloadDetails;
        console.log('Drive doc id: ' + details.documentId);
      }

      // Cloud storage download details.
      if (report.cloudStorageDownloadDetails) {
        var details = report.cloudStorageDownloadDetails;
        console.log('Cloud bucket id: ' + details.bucketId);
        console.log('Cloud object id: ' + details.objectId);
      }

      console.log('Report Created: ' + report.created);
      console.log('Report Updated: ' + report.updated);
    }
  }
}