Method: ampUrls.batchGet
Zadbaj o dobrą organizację dzięki kolekcji
Zapisuj i kategoryzuj treści zgodnie ze swoimi preferencjami.
Żądanie HTTP
POST https://acceleratedmobilepageurl.googleapis.com/v1/ampUrls:batchGet
W adresie URL jest używana składnia adnotacji HTTP interfejsów Google API.
Treść żądania
Treść żądania zawiera dane o następującej strukturze:
Zapis JSON |
{
"urls": [
string
]
"lookupStrategy": enum(LookupStrategy),
} |
Pola |
urls[] |
string
Lista adresów URL, dla których należy wyszukać sparowane adresy URL AMP. Wielkość liter w adresach URL jest rozróżniana. Maksymalnie 50 adresów URL na wyszukiwanie (patrz Limity wykorzystania).
|
lookupStrategy |
enum(LookupStrategy )
Żądana strategia wyszukiwania lookupStrategy.
|
Treść odpowiedzi
W przypadku powodzenia treść żądania zawiera dane o następującej strukturze:
Odpowiedź z serią adresów URL AMP.
Zapis JSON |
{
"ampUrls": [
{
object(AmpUrl)
}
],
"urlErrors": [
{
object(AmpUrlError)
}
],
}
|
Pola |
ampUrls[] |
object(AmpUrl )
Odpowiedź z adresem URL dla każdego adresu URL w żądaniu BatchAmpUrlsRequest. Odpowiedź może mieć inną kolejność niż adresy URL w żądaniu zbiorczym. Jeśli żądanie BatchAmpUrlsRequest zawiera duplikaty adresów URL, pole AmpUrl jest generowane tylko raz.
|
urlErrors[] |
object(AmpUrlError )
Błędy w przypadku żądanych adresów URL, dla których nie istnieją adresy URL AMP.
|
LookupStrategy
Wartości w polu enum |
FETCH_LIVE_DOC |
Strategia FETCH_LIVE_DOC obejmuje pobranie opublikowanego dokumentu w przypadku adresów URL nieznalezionych w indeksie. Każdy żądany adres URL nieznaleziony w indeksie jest indeksowany w czasie rzeczywistym, by sprawdzić, czy istnieje odpowiedni adres URL AMP. Ta strategia ma większy zasięg, ale indeksowanie w czasie rzeczywistym powoduje dodatkowe opóźnienie. Jest to strategia domyślna. W aplikacjach, które z niej korzystają, należy ustawić dłuższe limity czasu oczekiwania na wywołania interfejsu API. |
IN_INDEX_DOC |
Strategia IN_INDEX_DOC pomija pobieranie opublikowanych dokumentów w przypadku adresów URL nieznalezionych w indeksie. Jest ona zalecana w zastosowaniach, w których opóźnienie powinno być jak najkrótsze. |
AmpUrl
Odpowiedź z adresem URL AMP dla adresu URL z żądania.
Zapis JSON |
{
"originalUrl": string,
"ampUrl": string,
"cdnAmpUrl": string,
} |
Pola |
originalUrl |
string
Oryginalny adres URL (nie-AMP).
|
ampUrl |
string
Adres URL AMP wskazujący serwer WWW wydawcy.
|
cdnAmpUrl |
string
Adres URL pamięci podręcznej AMP wskazujący dokument zapisany w Google AMP Cache.
|
AmpUrlError
Zasób błędu adresu URL AMP dla nieznalezionego adresu URL z żądania.
Zapis JSON |
{
"errorCode": enum(ErrorCode),
"errorMessage": string,
"originalUrl": string,
} |
Pola |
errorCode |
enum(ErrorCode )
Kod błędu wywołania interfejsu API.
|
errorMessage |
string
Opcjonalny opisowy komunikat o błędzie.
|
originalUrl |
string
Oryginalny adres URL (nie-AMP).
|
ErrorCode
Kody błędów dla wyszukiwania serii adresów URL AMP.
Wartości w polu enum |
ERROR_CODE_UNSPECIFIED |
Nieokreślony błąd. |
INPUT_URL_NOT_FOUND |
Wskazuje, że żądany adres URL nie został znaleziony w indeksie. Prawdopodobnie nie można go znaleźć, Googlebot nie ma do niego dostępu lub wystąpił inny błąd. |
NO_AMP_URL |
Wskazuje, że nie znaleziono adresu URL AMP odpowiadającego adresowi URL z żądania. |
APPLICATION_ERROR |
Wskazuje, że na serwerze wystąpił błąd aplikacji. Klient powinien spróbować ponownie. |
URL_IS_VALID_AMP |
WYCOFANY: wskazuje, że adres URL z żądania jest prawidłowym adresem URL AMP. To nie jest stan błędu i nie należy na jego podstawie określać powodzenia lub niepowodzenia żądania. Ten stan zostanie usunięty w przyszłych wersjach interfejsu API. |
URL_IS_INVALID_AMP |
Wskazuje, że znaleziono adres URL AMP, który odpowiada adresowi URL z żądania, ale nie jest to prawidłowy kod AMP HTML. |
O ile nie stwierdzono inaczej, treść tej strony jest objęta licencją Creative Commons – uznanie autorstwa 4.0, a fragmenty kodu są dostępne na licencji Apache 2.0. Szczegółowe informacje na ten temat zawierają zasady dotyczące witryny Google Developers. Java jest zastrzeżonym znakiem towarowym firmy Oracle i jej podmiotów stowarzyszonych.
Ostatnia aktualizacja: 2025-08-04 UTC.
[null,null,["Ostatnia aktualizacja: 2025-08-04 UTC."],[[["\u003cp\u003eReturns AMP URLs and their corresponding AMP Cache URLs for given input URLs.\u003c/p\u003e\n"],["\u003cp\u003eUses a batch request containing up to 50 URLs and a lookup strategy (FETCH_LIVE_DOC or IN_INDEX_DOC).\u003c/p\u003e\n"],["\u003cp\u003eThe response includes the AMP URL and AMP Cache URL for successful lookups and error details for unsuccessful ones.\u003c/p\u003e\n"],["\u003cp\u003ePossible error codes include URL not found, no corresponding AMP URL, application error, and invalid AMP HTML.\u003c/p\u003e\n"],["\u003cp\u003eLeverages the Google AMP Cache for faster delivery of AMP content.\u003c/p\u003e\n"]]],["This API facilitates retrieving AMP URLs and their corresponding Google AMP Cache URLs. It uses a `POST` request to `ampUrls:batchGet`, taking a list of up to 50 URLs and a `lookupStrategy` (either `FETCH_LIVE_DOC` or `IN_INDEX_DOC`) in the request body. The response contains an array of `ampUrls` (with original, AMP, and cache URLs) and `urlErrors` (with error codes and messages). Error codes are specified for issues like \"URL not found\" and \"no AMP URL found.\"\n"],null,["# Method: ampUrls.batchGet\n\n- [HTTP request](#body.HTTP_TEMPLATE)\n- [Request body](#body.request_body)\n - [JSON representation](#body.request_body.SCHEMA_REPRESENTATION)\n- [Response body](#body.response_body)\n - [JSON representation](#body.BatchGetAmpUrlsResponse.SCHEMA_REPRESENTATION)\n- [LookupStrategy](#LookupStrategy)\n- [AmpUrl](#AmpUrl)\n - [JSON representation](#AmpUrl.SCHEMA_REPRESENTATION)\n- [AmpUrlError](#AmpUrlError)\n - [JSON representation](#AmpUrlError.SCHEMA_REPRESENTATION)\n- [ErrorCode](#ErrorCode)\n- [Try it!](#try-it)\n\nReturns AMP URL(s) and equivalent [AMP Cache URL(s)](/amp/cache/overview#amp-cache-url-format).\n\n### HTTP request\n\n`POST https://acceleratedmobilepageurl.googleapis.com/v1/ampUrls:batchGet`\n\nThe URL uses [Google API HTTP annotation](https://github.com/googleapis/googleapis/blob/master/google/api/http.proto) syntax.\n\n### Request body\n\nThe request body contains data with the following structure:\n\n| JSON representation ||\n|--------------------------------------------------------------------------------|---|\n| ```gdscript { \"urls\": [ string ] \"lookupStrategy\": enum(LookupStrategy), } ``` |\n\n| Fields ||\n|------------------|--------------------------------------------------------------------------------------------------------------------------------------------------------------------|\n| `urls[]` | `string` List of URLs to look up for the paired AMP URLs. The URLs are case-sensitive. Up to 50 URLs per lookup (see [Usage Limits](/amp/cache/reference/limits)). |\n| `lookupStrategy` | `enum(`[LookupStrategy](/amp/cache/reference/acceleratedmobilepageurl/rest/v1/ampUrls/batchGet#LookupStrategy)`)` The lookupStrategy being requested. |\n\n### Response body\n\nIf successful, the response body contains data with the following structure:\nBatch AMP URL response.\n\n| JSON representation ||\n|----------------------------------------------------------------------------------------------|---|\n| ```text { \"ampUrls\": [ { object(AmpUrl) } ], \"urlErrors\": [ { object(AmpUrlError) } ], } ``` |\n\n| Fields ||\n|---------------|---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|\n| `ampUrls[]` | `object(`[AmpUrl](/amp/cache/reference/acceleratedmobilepageurl/rest/v1/ampUrls/batchGet#AmpUrl)`)` For each URL in BatchAmpUrlsRequest, the URL response. The response might not be in the same order as URLs in the batch request. If BatchAmpUrlsRequest contains duplicate URLs, AmpUrl is generated only once. |\n| `urlErrors[]` | `object(`[AmpUrlError](/amp/cache/reference/acceleratedmobilepageurl/rest/v1/ampUrls/batchGet#AmpUrlError)`)` The errors for requested URLs that have no AMP URL. |\n\nLookupStrategy\n--------------\n\n| Enums ||\n|------------------|----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|\n| `FETCH_LIVE_DOC` | FETCH_LIVE_DOC strategy involves live document fetch of URLs not found in the index. Any request URL not found in the index is crawled in realtime to validate if there is a corresponding AMP URL. This strategy has higher coverage but with extra latency introduced by realtime crawling. This is the default strategy. Applications using this strategy should set higher HTTP timeouts of the API calls. |\n| `IN_INDEX_DOC` | IN_INDEX_DOC strategy skips fetching live documents of URL(s) not found in index. For applications which need low latency use of IN_INDEX_DOC strategy is recommended. |\n\nAmpUrl\n------\n\nAMP URL response for a requested URL.\n\n| JSON representation ||\n|-------------------------------------------------------------------------------|---|\n| ```text { \"originalUrl\": string, \"ampUrl\": string, \"cdnAmpUrl\": string, } ``` |\n\n| Fields ||\n|---------------|---------------------------------------------------------------------------------------------------------------------------------|\n| `originalUrl` | `string` The original non-AMP URL. |\n| `ampUrl` | `string` The AMP URL pointing to the publisher's web server. |\n| `cdnAmpUrl` | `string` The [AMP Cache URL](/amp/cache/overview#amp-cache-url-format) pointing to the cached document in the Google AMP Cache. |\n\nAmpUrlError\n-----------\n\nAMP URL Error resource for a requested URL that couldn't be found.\n\n| JSON representation ||\n|--------------------------------------------------------------------------------------------------|---|\n| ```gdscript { \"errorCode\": enum(ErrorCode), \"errorMessage\": string, \"originalUrl\": string, } ``` |\n\n| Fields ||\n|----------------|----------------------------------------------------------------------------------------------------------------------------------------|\n| `errorCode` | `enum(`[ErrorCode](/amp/cache/reference/acceleratedmobilepageurl/rest/v1/ampUrls/batchGet#ErrorCode)`)` The error code of an API call. |\n| `errorMessage` | `string` An optional descriptive error message. |\n| `originalUrl` | `string` The original non-AMP URL. |\n\nErrorCode\n---------\n\nError codes for a batch AMP URL lookup.\n\n| Enums ||\n|--------------------------|-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|\n| `ERROR_CODE_UNSPECIFIED` | Not specified error. |\n| `INPUT_URL_NOT_FOUND` | Indicates the requested URL is not found in the index, possibly because it's unable to be found, not able to be accessed by Googlebot, or some other error. |\n| `NO_AMP_URL` | Indicates no AMP URL has been found that corresponds to the requested URL. |\n| `APPLICATION_ERROR` | Indicates some kind of application error occurred at the server. Client advised to retry. |\n| `URL_IS_VALID_AMP` | DEPRECATED: Indicates the requested URL is a valid AMP URL. This is a non-error state, should not be relied upon as a sign of success or failure. It will be removed in future versions of the API. |\n| `URL_IS_INVALID_AMP` | Indicates that an AMP URL has been found that corresponds to the request URL, but it is not valid AMP HTML. |\n\nTry it!\n-------"]]