Launch process

Choose a data submission method

Once you have a valid Realtime feed (even one that doesn't contain any data), you can specify the method you’ll use to deliver data to Google.

You can deliver real-time transit data two ways:

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

For service alert data, if you can't provide service alerts via fetch or push methods, you can manually create service alerts via the Service alerts editor.

Publish service alerts

If you can't provide service alerts via fetch or push methods, you can manually create service alerts via the Service alerts editor.

Fetch

You can host each of your realtime feeds at their own web location. Google pulls (or "fetches") the data from these locations 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
If you choose to use basic authentication, please provide the appropriate credentials to the 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 data via HTTP POST, using OAuth2.0 authentication to ensure the security of your Realtime data feed.

To provide users with the most accurate and up-to-date transit information possible, we recommend that you push real-time data 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.

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 the Transit Data Sharing Portal
  • One Google Account that can open Google Cloud
  • The realtime feed file you want to push in the Transit Data Sharing Portal
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 Data Sharing Portal 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 Data Sharing Portal, click  Open Invite Dialog in the top right of the page.
  2. In the dialog box, enter the service account email.
  3. To allow the push of new real-time feeds, make sure your service account has the "Manage" permission.
  4. Click Invite.

For more information on adding users, see Manage users for the Transit Data Sharing Portal

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 in the Transit Data Sharing Portal. For the required scope, use https://googleapis.com/auth/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://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())

Need more help?

Try these next steps:

Is there something we can help you with?

Chat with a member of Transit team

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