Stay organized with collections Save and categorize content based on your preferences.
Region IDThe REGION_ID
is an abbreviated code that Google assigns based on the region you select when you create your app. The code does not correspond to a country or province, even though some region IDs may appear similar to commonly used country and province codes. For apps created after February 2020, REGION_ID.r
is included in App Engine URLs. For existing apps created before this date, the region ID is optional in the URL.
Learn more about region IDs.
This page describes how to issue HTTP(S) requests from your App Engine app.
This API is supported for first-generation runtimes and can be used when upgrading to corresponding second-generation runtimes. If you are updating to the App Engine Python 3 runtime, refer to the migration guide to learn about your migration options for legacy bundled services.By default, App Engine uses the URL Fetch service to issue outbound HTTP(S) requests.
For details on request size limits and which headers are sent in a URL Fetch request, see
Outbound Requests.
If you have set up Serverless VPC Access or if you use the Sockets API, you need to stop URL Fetch from handling requests. URL Fetch causes requests to your VPC network or to the Sockets API to fail. After you disable URL Fetch, the standard Python library will handle HTTP requests. If you need the features provided by URL Fetch for specific requests, you can use the urlfetch
library directly for those specific requests.
To issue an outbound HTTP request, use the urlfetch.fetch
method. For improved code portability, you can also use the Python standard libraries urllib
, urllib2
, or httplib
to issue HTTP requests. When you use these libraries in App Engine, they perform HTTP requests using App Engine's URL Fetch service. You can also use the third-party requests
library as long as you configure it to use URLFetch.
The following snippets demonstrate how to perform a basic HTTP GET
request using urlfetch
. First, import the urlfetch
library from the App Engine SDK:
Next, use urlfetch
to perform the GET
request:
The following snippet demonstrates how to perform a more advanced request, submitting data from a web form via a HTTP POST
request using urlfetch
:
The following snippets demonstrate how to perform a basic HTTP GET
request using urllib2
. First, import the urllib2
library:
Next, use urllib2
to perform the GET
request:
To use requests, you'll need to install both requests
and requests-toolbelt
using the vendoring instructions.
Once installed, use the requests_toolbelt.adapters.appengine
module to configure requests to use URLFetch:
Once configured, you can use requests normally:
For more information about requests' support for Google App Engine, see the documentation for urllib3.contrib.appengine
and requests_toolbelt.appengine
You can adjust the default deadline by using the urlfetch.set_default_fetch_deadline()
function. This function stores the new default deadline on a thread-local variable, so it must be set for each request, for example, in a custom middleware.
If you are using URL Fetch, the underlying URL Fetch service follows up to five redirects by default. These redirects could forward sensitive information, such as authorization headers, to the redirected destination. If your app does not require HTTP redirects, it is recommended that you disable the redirects.
To instruct the URL Fetch service to not follow redirects, set the fetch
method's follow_redirects
parameter to False
.
By default, the underlying URL Fetch service validates the certificate of the host it contacts, and rejects requests if the certificate doesn't match. You don't need to explicitly secure your request.
Disable host certificate validationTo disable automatic host certificate validation in URL Fetch, issue an HTTPS request, and set the validate_certificate
parameter to False
when calling the urlfetch.fetch()
method.
HTTP(S) requests are synchronous by default. To issue an asynchronous request, your application must:
urlfetch.create_rpc()
. This object represents your asynchronous call in subsequent method calls.urlfetch.make_fetch_call()
to make the request. This method takes your RPC object and the request target's URL as parameters.get_result()
method. This method returns the result object if the request is successful, and raises an exception if an error occurred during the request.The following snippets demonstrate how to make a basic asynchronous request from a Python application. First, import the urlfetch
library from the App Engine SDK:
Next, use urlfetch
to make the asynchronous request:
To set a timeout for your request, set the urlfetch.create_rpc()
method's deadline
parameter when you create your RPC object.
You can define a callback function for your RPC object. The function will be called when your application calls a method on the object—such as wait()
, checksuccess()
, or get_result()
—that causes the object to wait for the request to complete.
To use a callback function to handle the result of your fetch call:
callback
attribute to the helper function.The following snippet demonstrates how to invoke a callback function:
Issue a request to another App Engine appWhen issuing a request to another App Engine app, your App Engine app must assert its identity by adding the header X-Appengine-Inbound-Appid
to the request. If you instruct the URL Fetch service to not follow redirects, App Engine will add this header to requests automatically.
See Disabling redirects for guidance on disabling redirects.
Note: If you are making requests to another App Engine application, use itsREGION_ID.r.appspot.com
domain name rather than a custom domain for your app. What's next
Learn about the URL Fetch service, such as the headers that are sent in a URL Fetch request in Outbound Requests.
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-08-07 UTC.
[[["Easy to understand","easyToUnderstand","thumb-up"],["Solved my problem","solvedMyProblem","thumb-up"],["Other","otherUp","thumb-up"]],[["Hard to understand","hardToUnderstand","thumb-down"],["Incorrect information or sample code","incorrectInformationOrSampleCode","thumb-down"],["Missing the information/samples I need","missingTheInformationSamplesINeed","thumb-down"],["Other","otherDown","thumb-down"]],["Last updated 2025-08-07 UTC."],[[["App Engine uses the URL Fetch service by default to issue outbound HTTP(S) requests, but if you use Serverless VPC Access or the Sockets API, you must disable URL Fetch for those requests."],["You can use `urlfetch.fetch`, `urllib`, `urllib2`, or `httplib` for making HTTP requests; these libraries utilize App Engine's URL Fetch service, and the third-party `requests` library can be used when properly configured."],["It's recommended to disable redirects when using URL Fetch to improve app security, preventing sensitive information from being forwarded."],["To issue asynchronous HTTP(S) requests, create an RPC object with `urlfetch.create_rpc()`, make the request with `urlfetch.make_fetch_call()`, and then retrieve the result using the RPC object's `get_result()` method."],["When sending a request to another App Engine app, add the `X-Appengine-Inbound-Appid` header to assert your app's identity, which is done automatically if you disable redirects."]]],[]]
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4