Launch process

Choose a data submission method

Once you have a feed that's syntactically valid (even if it doesn't contain any data), you’re ready to set up the method you’ll use to provide your data to Google.

You can deliver realtime transit data 2 ways:

  • Fetch, which allows Google to retrieve your data from a web-location
  • Push, which allows you to upload your data via HTTP POST

If you can't provide service alerts via fetch or push methods, you can manually enter service alerts via the Service Alerts Editor in your Transit partner dashboard.

Fetch

You can host each of your realtime feeds at their own web-location. Google pulls (or "fetches") the data from this location every 30 seconds.

To securely allow data fetches from Google, you can use one of the following authentication options:

  • Basic authentication (username and password)
  • Specific headers to add in the request

Tip: If you choose to set the authentication, please provide the details to Transit support team.

Push

You can actively transfer, or “push,” your data to Google with push delivery. With push delivery, you set up automatic uploads of your GTFS-realtime via HTTP POST, using OAuth2.0 authentication to ensure the security of your realtime feed.

To provide users with the most accurate and up-to-date transit information possible, we recommend that you push realtime updates frequently. Ideally, you should push trip update and vehicle position data every 30 seconds and service alert data every 30 seconds to 2 minutes.

Tip: If you set up push delivery before 2023, your setup uses a different OAuth method. To ensure that your feed pushes continue to work, update the push setup to the new method described below.

Before you begin
Before tests or any implementation, make sure you have the following:
  • One Google Account registered in Transit Partner Dashboard
  • One Google Account that can open Google Cloud
  • The realtime feed file you want to push to Transit Partner Dashboard
Create a cloud.google.com project
Important: To create a cloud.google.com project, you need a Google Cloud account.
On cloud.google.com, create a new Cloud project. You don't need to pay to share your data, but you need to provide a payment method for security purposes.
Create a service account & service account key
  1. On the left under the "APIs & Services" tab, click Credentials.
  2. At the top, click Create Credentials and then Service account.
  3. In the "Service account name" field, enter a name.
  4. Click Create and continue and then Done.

You can choose anything for the service account name. We call it "push-uploads" for this example. This step creates an email address for the service account. It's used later in the Transit Partner Dashboard to authorize the service account for edit use. If this email address needs no permissions and no user access to the dashboard, you can skip steps 2 and 3.
To create a key for authenticated push requests:
  1. On the Google Cloud console, click Menu More and then IAM & Admin.
  2. On the left, click Service Accounts and then Add Key.
  3. Under "Key type," select JSON.
  4. Click Create.

Authorize the service account
  1. To add the service account as a user to the Transit Partner Dashboard, click Share this account Add people.
  2. In the "Invite others to" field, enter the service account email.
  3. To push new realtime feeds, select Writer or Owner.
  4. Click Invite.

Authenticate upload requests
To make authorized server-to-server requests through Python, Java, and REST, learn how to use OAuth 2.0 for server-to-server applications.
With the downloaded service account key (service-account-key.json), you can perform an authorized POST request on the Transit Partner Dashboard. For the required scope, use https://www.googleapis.com/autho/partnerdash.upload. The request contains an html form (Content-Type: multipart/form-data) with 2 fields:
  • realtime_feed_id: The ID of the realtime feed being uploaded
  • file: The uploaded GTFS-RT file content
Here's an example implementation for feed uploader code in Python:

#!/usr/bin/env python3

import requests

from google.oauth2 import service_account

from google.auth.transport.requests import AuthorizedSession

SCOPES = ["https://www.googleapis.com/auth/partnerdash.upload"]

SERVICE_ACCOUNT_FILE = 'service-account-key.json'

credentials = service_account.Credentials.from_service_account_file(SERVICE_ACCOUNT_FILE, scopes=SCOPES)

form = {'realtime_feed_id': '[REALTIME_FEED_NAME]'}

files = {'file': open("feed_version.pb", 'rb')}

req = requests.Request( 'POST', 'https://partnerdash.google.com/push-upload',data=form, files=files).prepare()

authed_session = AuthorizedSession(credentials)

resp = authed_session.request(url="https://partnerdash.google.com/push-upload",method="POST",

data=req.body,

headers={

'Content-Length': req.headers["Content-Length"],

'Content-Type': req.headers["Content-Type"]})

print(resp.headers)

print(resp.reason)

print(resp.raise_for_status())

Was this helpful?
How can we improve it?

Need more help?

Try these next steps:

Search
Clear search
Close search
Google apps
Main menu
Search Help Center
true
true
false
true
true
82656
false
false