Set Up Your Application
Stay organized with collections
Save and categorize content based on your preferences.
Before you can make requests to the API, you must set up authorization. If you are using a client library, you must also create a Service
object.
The following code demonstrates how to configure your client and authorize requests using an API key.
Java
import com.google.api.client.http.HttpTransport;
import com.google.api.client.http.javanet.NetHttpTransport;
import com.google.api.client.json.jackson.JacksonFactory;
import com.google.api.services.abusiveexperiencereport.v1.AbusiveExperienceReport;
import com.google.api.services.abusiveexperiencereport.v1.AbusiveExperienceReportRequestInitializer;
import com.google.api.services.abusiveexperiencereport.v1.model.SiteSummaryResponse;
import com.google.api.services.abusiveexperiencereport.v1.model.ViolatingSitesResponse;
...
public static void main(String[] args) {
HttpTransport httpTransport = new NetHttpTransport();
JacksonFactory jsonFactory = new JacksonFactory();
AbusiveExperienceReportRequestInitializer reqInitializer =
new AbusiveExperienceReportRequestInitializer("YOUR_API_KEY");
AbusiveExperienceReport service = new AbusiveExperienceReport.Builder(httpTransport, jsonFactory, null)
.setAbusiveExperienceReportRequestInitializer(reqInitializer)
.setApplicationName("YOUR_APPLICATION_NAME")
.build();
ViolatingSitesResponse response = service.violatingSites().list().execute();
...
}
...
Python
from apiclient.discovery import build
api_key = 'YOUR_API_KEY'
service = build('abusiveexperiencereport', 'v1', developerKey=api_key)
response = service.violatingSites().list().execute()
...
PHP
$client = new Google_Client();
$client->setApplicationName("YOUR_APPLICATION_NAME");
$client->setDeveloperKey("YOUR_API_KEY");
$service = new Google_Service_AbusiveExperienceReport($client);
$response = $service->violatingSites;
...
.NET
using Google.Apis.AbusiveExperienceReport.v1.AbusiveExperienceReportService;
using Google.Apis.Services.BaseClientService.Initializer;
...
public static void Main(string[] args)
{
var service = new AbusiveExperienceReportService(new BaseClientService.Initializer
{
ApplicationName = "YOUR_APPLICATION_NAME",
ApiKey = "YOUR_API_KEY",
});
var response = await service.ViolatingSites.List().ExecuteAsync();
...
}
Except as otherwise noted, the content of this page is licensed under the Creative Commons Attribution 4.0 License, and code samples are licensed under the Apache 2.0 License. For details, see the Google Developers Site Policies. Java is a registered trademark of Oracle and/or its affiliates.
Last updated 2025-05-07 UTC.
[[["Easy to understand","easyToUnderstand","thumb-up"],["Solved my problem","solvedMyProblem","thumb-up"],["Other","otherUp","thumb-up"]],[["Missing the information I need","missingTheInformationINeed","thumb-down"],["Too complicated / too many steps","tooComplicatedTooManySteps","thumb-down"],["Out of date","outOfDate","thumb-down"],["Samples / code issue","samplesCodeIssue","thumb-down"],["Other","otherDown","thumb-down"]],["Last updated 2025-05-07 UTC."],[[["\u003cp\u003eAuthorization must be set up before making API requests.\u003c/p\u003e\n"],["\u003cp\u003eIf using a client library, a \u003ccode\u003eService\u003c/code\u003e object must be created.\u003c/p\u003e\n"],["\u003cp\u003eAPI requests can be authorized using an API key, as demonstrated in examples in Java, Python, PHP, and .NET.\u003c/p\u003e\n"],["\u003cp\u003eEach code example uses the API key, along with the application name, to configure the \u003ccode\u003eService\u003c/code\u003e object for making requests.\u003c/p\u003e\n"]]],["To interact with the API, authorization must be set up. Client libraries require a `Service` object. The provided examples demonstrate client configuration and request authorization using an API key across Java, Python, PHP, and .NET. These involve creating a service object, setting the application name and API key, and then executing a request to list `ViolatingSites`. In Java, an `AbusiveExperienceReportRequestInitializer` is used.\n"],null,["Before you can make requests to the API, you must set up [authorization](/abusive-experience-report/v1/how-tos/authorizing). If you are using a [client library](/abusive-experience-report/v1/libraries), you must also create a `Service` object.\n\nThe following code demonstrates how to configure your client and authorize requests using an API key. \n\nJava \n\n```java\nimport com.google.api.client.http.HttpTransport;\nimport com.google.api.client.http.javanet.NetHttpTransport;\nimport com.google.api.client.json.jackson.JacksonFactory;\n\nimport com.google.api.services.abusiveexperiencereport.v1.AbusiveExperienceReport;\nimport com.google.api.services.abusiveexperiencereport.v1.AbusiveExperienceReportRequestInitializer;\n\nimport com.google.api.services.abusiveexperiencereport.v1.model.SiteSummaryResponse;\nimport com.google.api.services.abusiveexperiencereport.v1.model.ViolatingSitesResponse;\n...\n\n public static void main(String[] args) {\n HttpTransport httpTransport = new NetHttpTransport();\n JacksonFactory jsonFactory = new JacksonFactory();\n AbusiveExperienceReportRequestInitializer reqInitializer =\n new AbusiveExperienceReportRequestInitializer(\"\u003cvar translate=\"no\"\u003eYOUR_API_KEY\u003c/var\u003e\");\n\n AbusiveExperienceReport service = new AbusiveExperienceReport.Builder(httpTransport, jsonFactory, null)\n .setAbusiveExperienceReportRequestInitializer(reqInitializer)\n .setApplicationName(\"\u003cvar translate=\"no\"\u003eYOUR_APPLICATION_NAME\u003c/var\u003e\")\n .build();\n\n ViolatingSitesResponse response = service.violatingSites().list().execute();\n ...\n }\n...\n```\n\nPython \n\n```python\nfrom apiclient.discovery import build\n\napi_key = '\u003cvar translate=\"no\"\u003eYOUR_API_KEY\u003c/var\u003e'\nservice = build('abusiveexperiencereport', 'v1', developerKey=api_key)\n\nresponse = service.violatingSites().list().execute()\n...\n```\n\nPHP \n\n```php\n$client = new Google_Client();\n$client-\u003esetApplicationName(\"\u003cvar translate=\"no\"\u003eYOUR_APPLICATION_NAME\u003c/var\u003e\");\n$client-\u003esetDeveloperKey(\"\u003cvar translate=\"no\"\u003eYOUR_API_KEY\u003c/var\u003e\");\n$service = new Google_Service_AbusiveExperienceReport($client);\n\n$response = $service-\u003eviolatingSites;\n...\n```\n\n.NET \n\n```gdscript\nusing Google.Apis.AbusiveExperienceReport.v1.AbusiveExperienceReportService;\nusing Google.Apis.Services.BaseClientService.Initializer;\n...\n\n public static void Main(string[] args)\n {\n var service = new AbusiveExperienceReportService(new BaseClientService.Initializer\n {\n ApplicationName = \"\u003cvar translate=\"no\"\u003eYOUR_APPLICATION_NAME\u003c/var\u003e\",\n ApiKey = \"\u003cvar translate=\"no\"\u003eYOUR_API_KEY\u003c/var\u003e\",\n });\n\n var response = await service.ViolatingSites.List().ExecuteAsync();\n ...\n }\n```"]]