Indexing API로 요청을 보내려면 먼저 Google에 클라이언트에 관해 알리고 API에 대한 액세스 권한을 활성화해야 합니다. Google API 콘솔을 사용하여 프로젝트(설정과 API 액세스 정보를 묶어 이름을 지정한 모음)를 만든 다음 애플리케이션을 등록하면 됩니다.
Indexing API를 사용하려면 먼저
설정
도구를 사용하여 Google API 콘솔에서 프로젝트를 만들고, API를 사용 설정하고,
사용자 인증 정보를 생성하는 방법을 알아보시기 바랍니다.
add서비스 계정 만들기를 클릭한 다음 서비스 계정의 이름과 설명을 입력합니다. 기본 서비스 계정 ID를 사용하거나 다른 고유한 ID를 선택할 수도 있습니다. 완료하면 만들기를 클릭합니다.
이어지는 서비스 계정 권한(선택사항) 섹션은 선택하지 않아도 됩니다. 계속을 클릭합니다.
사용자에게 이 서비스 계정에 대한 액세스 권한 부여 화면에서 키 만들기 섹션이 나올 때까지 아래로 스크롤합니다. add키 만들기를 클릭합니다.
표시되는 측면 패널에서 키에 사용할 형식을 선택합니다. JSON을 사용하는 것이 좋습니다.
만들기를 클릭합니다. 새로운 공개 키/비공개 키 쌍이 생성되어 기기에 다운로드됩니다.
생성된 파일은 이 키의 유일한 사본으로 사용됩니다. 키를 안전하게 보관하는 방법을 자세히 알아보려면 서비스 계정 키 관리를 참조하세요.
비공개 키가 컴퓨터에 저장됨 대화상자에서 닫기를 클릭한 다음
완료를 클릭하여 서비스 계정 표로 돌아갑니다.
서비스 계정을 사이트 소유자로 추가하기
서비스 계정을 사이트 소유자로 추가하려면 다음 안내를 따르세요.
먼저 Search Console을 사용하여 사이트의 소유자임을 입증합니다.
서비스 계정을 소유자로 추가합니다.
1. 사이트 소유자임을 증명
Search Console을 사용하여 사이트의 소유권을 인증받아야 합니다.
Search Console에서 지원되는 모든 인증 방법을 사용할 수 있습니다. 도메인 속성(example.com) 또는 URL 접두어 속성(https://example.com 또는 https://example.com/some/path/)을 만들어 사이트를 나타낼 수 있습니다(Search Console에서는 사이트를 속성이라고 함).
이메일 주소의 형식은 다음과 같습니다. my-service-account@project-name.google.com.iam.gserviceaccount.com 예: my-service-account@test-project-42.google.com.iam.gserviceaccount.com
액세스 토큰 가져오기
모든 Indexing API 호출은 비공개 키 대신 가져오는 OAuth 토큰을 사용하여 인증해야 합니다. 각 토큰은 일정 기간 동안 유효합니다.
Google에서는 여러 언어로 OAuth 토큰을 가져올 수 있는
API 클라이언트 라이브러리를 제공합니다.
fromoauth2client.service_accountimportServiceAccountCredentialsimporthttplib2SCOPES=["https://www.googleapis.com/auth/indexing"]ENDPOINT="https://indexing.googleapis.com/v3/urlNotifications:publish"# service_account_file.json is the private key that you created for your service account.JSON_KEY_FILE="service_account_file.json"credentials=ServiceAccountCredentials.from_json_keyfile_name(JSON_KEY_FILE,scopes=SCOPES)http=credentials.authorize(httplib2.Http())# Define contents here as a JSON string.# This example shows a simple update request.# Other types of requests are described in the next step.content="""{\"url\": \"http://example.com/jobs/42\",\"type\": \"URL_UPDATED\"}"""response,content=http.request(ENDPOINT,method="POST",body=content)
Stringscopes="https://www.googleapis.com/auth/indexing";StringendPoint="https://indexing.googleapis.com/v3/urlNotifications:publish";JsonFactoryjsonFactory=newJacksonFactory();// service_account_file.json is the private key that you created for your service account.InputStreamin=IOUtils.toInputStream("service_account_file.json");GoogleCredentialcredentials=GoogleCredential.fromStream(in,this.httpTransport,jsonFactory).createScoped(Collections.singleton(scopes));GenericUrlgenericUrl=newGenericUrl(endPoint);HttpRequestFactoryrequestFactory=this.httpTransport.createRequestFactory();// Define content here. The structure of the content is described in the next step.Stringcontent="{"+"\"url\": \"http://example.com/jobs/42\","+"\"type\": \"URL_UPDATED\","+"}";HttpRequestrequest=requestFactory.buildPostRequest(genericUrl,ByteArrayContent.fromString("application/json",content));credentials.initialize(request);HttpResponseresponse=request.execute();intstatusCode=response.getStatusCode();
require_once 'google-api-php-client/vendor/autoload.php';$client = new Google_Client();// service_account_file.json is the private key that you created for your service account.$client->setAuthConfig('service_account_file.json');$client->addScope('https://www.googleapis.com/auth/indexing');// Get a Guzzle HTTP Client$httpClient = $client->authorize();$endpoint = 'https://indexing.googleapis.com/v3/urlNotifications:publish';// Define contents here. The structure of the content is described in the next step.$content = '{ "url": "http://example.com/jobs/42", "type": "URL_UPDATED"}';$response = $httpClient->post($endpoint, [ 'body' => $content ]);$status_code = $response->getStatusCode();
varrequest=require("request");var{google}=require("googleapis");varkey=require("./service_account.json");constjwtClient=newgoogle.auth.JWT(key.client_email,null,key.private_key,["https://www.googleapis.com/auth/indexing"],null);jwtClient.authorize(function(err,tokens){if(err){console.log(err);return;}letoptions={url:"https://indexing.googleapis.com/v3/urlNotifications:publish",method:"POST",// Your options, which must include the Content-Type and auth headersheaders:{"Content-Type":"application/json"},auth:{"bearer":tokens.access_token},// Define contents here. The structure of the content is described in the next step.json:{"url":"http://example.com/jobs/42","type":"URL_UPDATED"}};request(options,function(error,response,body){// Handle the responseconsole.log(body);});});
이 예시를 통해 토큰을 받는 방법뿐 아니라 요청 메시지 본문을 어디에 추가할 수 있는지도 알 수 있습니다. 가능한 호출 유형과 이러한 호출의 메시지 본문 구조를 자세히 알아보려면 API 사용을 참조하세요.
[[["이해하기 쉬움","easyToUnderstand","thumb-up"],["문제가 해결됨","solvedMyProblem","thumb-up"],["기타","otherUp","thumb-up"]],[["필요한 정보가 없음","missingTheInformationINeed","thumb-down"],["너무 복잡함/단계 수가 너무 많음","tooComplicatedTooManySteps","thumb-down"],["오래됨","outOfDate","thumb-down"],["번역 문제","translationIssue","thumb-down"],["샘플/코드 문제","samplesCodeIssue","thumb-down"],["기타","otherDown","thumb-down"]],["최종 업데이트: 2025-09-03(UTC)"],[[["\u003cp\u003eTo utilize the Indexing API, you must first create a project, a service account, and add the service account as a site owner in Search Console.\u003c/p\u003e\n"],["\u003cp\u003eAfter setup, each API call needs an OAuth token, which you get in exchange for your private key using Google's API client libraries and adhering to specific requirements.\u003c/p\u003e\n"],["\u003cp\u003eWhen making a request, you must define the request body and use the appropriate endpoint as detailed in the Indexing API documentation's "Using the API" section.\u003c/p\u003e\n"],["\u003cp\u003eGoogle provides API client libraries in multiple programming languages, such as Python, Java, PHP, and Node.js, to simplify the process of getting OAuth tokens and making API calls.\u003c/p\u003e\n"]]],["To use the Indexing API, you must first create a project in the Google API Console, create a service account with a JSON key, and then add this service account as a delegated owner of your site in Search Console. Finally, get an OAuth access token using your private key to authenticate API calls. Each request must use `https://www.googleapis.com/auth/indexing` as the scope, and include the service account access token. The content gives examples in different programming languages.\n"],null,["Prerequisites for the Indexing API\n\nBefore you can start using the Indexing API, there are a few\nthings you need to do, if you haven't done them already:\n\n- [Create a project for your client](#create-project)\n- [Create a service account](#create-service-account)\n- [Add your service account as a site owner](#verify-site)\n- [Get an access token](#oauth)\n\nCreate a project for your client\n\nBefore you can send requests to the Indexing API, you need to tell Google about your client and\nactivate access to the API. You do this by using the Google API Console to create a project,\nwhich is a named collection of settings and API access information, and register your application.\n\nTo get started using Indexing API, you need to first\n[use\nthe setup tool](https://console.cloud.google.com/start/api?id=indexing.googleapis.com&credential=client_key), which guides you through creating a project in the\nGoogle API Console, enabling the API, and creating credentials.\n\nCreate a service account\n\n1. Open the [**Service accounts** page](https://console.cloud.google.com/iam-admin/serviceaccounts). If prompted, select a project.\n2. Click add **Create Service Account** , enter a name and description for the service account. You can use the default service account ID, or choose a different, unique one. When done click **Create**.\n3. The **Service account permissions (optional)** section that follows is not required. Click **Continue**.\n4. On the **Grant users access to this service account** screen, scroll down to the **Create key** section. Click add **Create key**.\n5. In the side panel that appears, select the format for your key: **JSON** is recommended.\n6. Click **Create** . Your new public/private key pair is generated and downloaded to your machine; it serves as the only copy of this key. For information on how to store it securely, see [Managing service account keys](https://cloud.google.com/iam/docs/understanding-service-accounts#managing_service_account_keys).\n7. Click **Close** on the **Private key saved to your computer** dialog, then click **Done** to return to the table of your service accounts.\n\nAdd your service account as a site owner\n\n\nTo add your service account as a site owner:\n\n1. First prove that you own the site, using Search Console, then\n2. Add your service account as an owner.\n\n1. Prove that you own the site\n\n\n[Verify ownership of your site](https://support.google.com/webmasters/answer/9008080)\nusing Search Console.\nYou can use any verification method supported by Search Console. You can create either\na Domain property (`example.com`) or a URL-prefix property (`https://example.com`\nor `https://example.com/some/path/`) to represent your site (note that sites are called\n*properties* in Search Console).\n\n2. Grant owner status to your service account\n\nNext, add your service account as a\n([delegated](https://support.google.com/webmasters/answer/7687615#permissions-section))\nsite owner:\n\n1. Open [Search Console](https://www.google.com/webmasters/verification/home).\n2. Click the property for which you verified ownership.\n3. In the **Verified owner** list, click **Add an owner**.\n4. Provide your service account email as the delegated owner. You can find your service account email address in two places:\n - The `client_email` field in the JSON private key that you downloaded when you [created your project](#create-project).\n - The **Service account ID** column of the Service Accounts view in the Google Cloud console.\n\n The email address has a format like this: \n \u003cvar translate=\"no\"\u003emy-service-account\u003c/var\u003e`@`\u003cvar translate=\"no\"\u003eproject-name\u003c/var\u003e`.google.com.iam.gserviceaccount.com` \n **For example:** my-service-account@test-project-42.google.com.iam.gserviceaccount.com\n\nGet an access token\n\nEvery call to the Indexing API must be authenticated with an OAuth token that you get\nin exchange for your private key. Each token is good for a span of time.\nGoogle provides [API client libraries](/api-client-library)\nto get OAuth tokens for a number of languages.\n\nRequirements\n\nWhen submitting a request to the Indexing API, your request must:\n\n1. Use `https://www.googleapis.com/auth/indexing` as the scope.\n2. Use one of the endpoints described in [Using the API](/search/apis/indexing-api/v3/using-api).\n3. Include the [service account access token](#create-service-account).\n4. Define the body of the request as described in [Using the API](/search/apis/indexing-api/v3/using-api).\n\nExamples\n\nThe following examples show how to obtain an OAuth access token: \n\nPython\n\nObtains an OAuth token using the [Google API Client library for Python](/api-client-library/python): \n\n```python\nfrom oauth2client.service_account import ServiceAccountCredentials\nimport httplib2\n\nSCOPES = [ \"https://www.googleapis.com/auth/indexing\" ]\nENDPOINT = \"https://indexing.googleapis.com/v3/urlNotifications:publish\"\n\n# service_account_file.json is the private key that you created for your service account.\nJSON_KEY_FILE = \"service_account_file.json\"\n\ncredentials = ServiceAccountCredentials.from_json_keyfile_name(JSON_KEY_FILE, scopes=SCOPES)\n\nhttp = credentials.authorize(httplib2.Http())\n\n# Define contents here as a JSON string.\n# This example shows a simple update request.\n# Other types of requests are described in the next step.\n\ncontent = \"\"\"{\n \\\"url\\\": \\\"http://example.com/jobs/42\\\",\n \\\"type\\\": \\\"URL_UPDATED\\\"\n}\"\"\"\n\nresponse, content = http.request(ENDPOINT, method=\"POST\", body=content)\n```\n\nJava\n\nObtains an OAuth token using the [API Client Library for Java](/api-client-library/java): \n\n```java\nString scopes = \"https://www.googleapis.com/auth/indexing\";\nString endPoint = \"https://indexing.googleapis.com/v3/urlNotifications:publish\";\n\nJsonFactory jsonFactory = new JacksonFactory();\n\n// service_account_file.json is the private key that you created for your service account.\nInputStream in = IOUtils.toInputStream(\"service_account_file.json\");\n\nGoogleCredential credentials =\n GoogleCredential.fromStream(in, this.httpTransport, jsonFactory).createScoped(Collections.singleton(scopes));\n\nGenericUrl genericUrl = new GenericUrl(endPoint);\nHttpRequestFactory requestFactory = this.httpTransport.createRequestFactory();\n\n// Define content here. The structure of the content is described in the next step.\nString content = \"{\"\n + \"\\\"url\\\": \\\"http://example.com/jobs/42\\\",\"\n + \"\\\"type\\\": \\\"URL_UPDATED\\\",\"\n + \"}\";\n\nHttpRequest request =\n requestFactory.buildPostRequest(genericUrl, ByteArrayContent.fromString(\"application/json\", content));\n\ncredentials.initialize(request);\nHttpResponse response = request.execute();\nint statusCode = response.getStatusCode();\n```\n\nPHP\n\nObtains an OAuth token using the [API Client Library for PHP](/api-client-library/php): \n\n```php\nrequire_once 'google-api-php-client/vendor/autoload.php';\n\n$client = new Google_Client();\n\n// service_account_file.json is the private key that you created for your service account.\n$client-\u003esetAuthConfig('service_account_file.json');\n$client-\u003eaddScope('https://www.googleapis.com/auth/indexing');\n\n// Get a Guzzle HTTP Client\n$httpClient = $client-\u003eauthorize();\n$endpoint = 'https://indexing.googleapis.com/v3/urlNotifications:publish';\n\n// Define contents here. The structure of the content is described in the next step.\n$content = '{\n \"url\": \"http://example.com/jobs/42\",\n \"type\": \"URL_UPDATED\"\n}';\n\n$response = $httpClient-\u003epost($endpoint, [ 'body' =\u003e $content ]);\n$status_code = $response-\u003egetStatusCode();\n```\n\nNode.js\n\nObtains an OAuth token using the [Node.js Client Library](https://github.com/google/google-api-nodejs-client): \n\n```javascript\nvar request = require(\"request\");\nvar { google } = require(\"googleapis\");\nvar key = require(\"./service_account.json\");\n\nconst jwtClient = new google.auth.JWT(\n key.client_email,\n null,\n key.private_key,\n [\"https://www.googleapis.com/auth/indexing\"],\n null\n);\n\njwtClient.authorize(function(err, tokens) {\n if (err) {\n console.log(err);\n return;\n }\n let options = {\n url: \"https://indexing.googleapis.com/v3/urlNotifications:publish\",\n method: \"POST\",\n // Your options, which must include the Content-Type and auth headers\n headers: {\n \"Content-Type\": \"application/json\"\n },\n auth: { \"bearer\": tokens.access_token },\n // Define contents here. The structure of the content is described in the next step.\n json: {\n \"url\": \"http://example.com/jobs/42\",\n \"type\": \"URL_UPDATED\"\n }\n };\n request(options, function (error, response, body) {\n // Handle the response\n console.log(body);\n });\n});\n```\n\nIn addition to showing how to obtain a token, these examples show where you can add the body of\nthe request message. For information about the types of calls you can make, and the structure of the\nmessage bodies for those calls, see [Using the API](/search/apis/indexing-api/v3/using-api)."]]