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, and Google pulls (or "fetches") the data from this location every 30 seconds.

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.

Note: You don't need to create additional API or client IDs for push uploads.

Before you begin
Before tests or any implementation make sure you have the following:
  • One Google Account registered in Partner Dash
  • Download the client_secrets.json
  • The realtime feed file you want to push to Partner Dash
Get an authorization code
Typically, you'll only need to get an authorization code once. For simplicity, we'll build the request that can be completed in a browser using this scope: www.googleapis.com/auth/partnerdash.upload
The client_secrets.json contains the following required fields:
  • auth_uri
  • client_id
  • redirect_uri

Note: You're not required to create your client_id.

Example:

https://accounts.google.com/o/oauth2/auth?scope=https%3A%2F%2Fwww.googleapis.com%2Fauth%2Fpartnerdash.upload&redirect_uri=urn%3Aietf%3Awg%3Aoauth%3A2.0%3Aoob&response_type=code&client_id=477490027766-m394r1456hdu2hbgke5i8g3v0l068p3g.apps.googleusercontent.com&access_type=offline

Authorize push delivery

  1. Copy the request in the previous example.
  2. Enter the request in your web browser.
  3. Sign in with the Google Account associated with Partner Dash.
  4. Click Allow.
  5. Copy the code on the screen and paste it into your application.
Request access & refresh tokens
With an authorization code, you can request your access and refresh tokens. Access tokens are used in the API code, while refresh tokens are used when your access token expires without need to get another authorization code. Learn more about exchanging authorization codes for tokens.
The client_secrets.json contains the following required fields:
  • token_uri
  • client_id
  • client_secret
  • redirect_uri
Note: You're not required to create your client_secret.
Example:
curl \
-F "code={PUT AUTHORIZATION CODE HERE}" \
-F "client_id=477490027766-m394r1456hdu2hbgke5i8g3v0l068p3g.apps.googleusercontent.com" \
-F "client_secret=KsYQi0qdJ4OCUXoPSPmzzLW2" \
-F "redirect_uri=urn:ietf:wg:oauth:2.0:oob" \
-F "grant_type=authorization_code" \
https://accounts.google.com/o/oauth2/token

To upload feed files, save your access and refresh tokens from this call's response.

Refresh access token
When an access token expires, you don't need to authorize again unless you revoke permissions. Instead, use the refresh token you got from your previous request. To learn more, check the official documentation.
Example:
curl \
-F "client_id=477490027766-m394r1456hdu2hbgke5i8g3v0l068p3g.apps.googleusercontent.com" \
-F "client_secret=KsYQi0qdJ4OCUXoPSPmzzLW2" \
-F "refresh_token={YOUR REFRESH TOKEN}" \
-F "grant_type=refresh_token" \
https://accounts.google.com/o/oauth2/token
Basic implementation should work like this:
manual input (or read file with) authorization code
request access token
while true
   do
      if credentials are expired
         Regenerate credentials
     upload feed file with credentials
   Done
done
Upload your realtime feed
With the access token, use an HTTP POST request to upload your realtime feed to Partner Dash. The upload URL is: https://partnerdash.google.com/push-upload
Important:​ Uploads to Partner Dash are not supported by Google APIs.
Example:
curl \
    --header "authorization: Bearer {YOUR_ACCESS_TOKEN}" \
    -F "alkali_application_name=transit" \
    -F "alkali_account_id={YOUR ACCOUNT ID}" \
    -F "alkali_upload_type=realtime_push_upload" \
    -F "alkali_application_id=100003100" \
    -F "realtime_feed_id={YOUR FEED ID}" \
    -F "file=@/path/to/file" \
    https://partnerdash.google.com/push-upload 

Note: The "alkali_account_id" is the value of the "a" parameter in the Transit Partner Dashboard page URL. 

Was this helpful?
How can we improve it?