Last Mile Fleet Solution is currently available only to select customers. Contact sales to learn more.

Client libraries

We recommend using our language-specific client libraries for a better experience than developing over raw REST or gRPC.

If libraries do not exist in your application's language, we recommend usig gRPC or the Fleet Engine REST endpoints.

In order to authenticate with Fleet engine, you must have a signed JSON web token. See Authentication and Authorization for details.

Java

Java libraries are published under google.maps.fleetengine.delivery.v1.

Gradle

plugins {
  id "maven-publish"
  id "com.google.cloud.artifactregistry.gradle-plugin" version "2.1.4"
}

publishing {
  repositories {
    maven {
      url "artifactregistry://us-maven.pkg.dev/fleetengine-gapic/maven"
    }
  }
}

repositories {
  maven {
    url "artifactregistry://us-maven.pkg.dev/fleetengine-gapic/maven"
  }
}

dependencies {
  implementation 'com.google.maps:gapic-google-maps-fleetengine-delivery-v1-java:latest.release'
}

Maven

<project>
  <distributionManagement>
    <snapshotRepository>
      <id>artifact-registry</id>
      <url>artifactregistry://us-maven.pkg.dev/fleetengine-gapic/maven</url>
    </snapshotRepository>
    <repository>
      <id>artifact-registry</id>
      <url>artifactregistry://us-maven.pkg.dev/fleetengine-gapic/maven</url>
    </repository>
  </distributionManagement>

  <repositories>
    <repository>
      <id>artifact-registry</id>
      <url>artifactregistry://us-maven.pkg.dev/fleetengine-gapic/maven</url>
      <releases>
        <enabled>true</enabled>
      </releases>
      <snapshots>
        <enabled>true</enabled>
      </snapshots>
    </repository>
  </repositories>

  <build>
    <extensions>
      <extension>
        <groupId>com.google.cloud.artifactregistry</groupId>
        <artifactId>artifactregistry-maven-wagon</artifactId>
        <version>2.1.4</version>
      </extension>
    </extensions>
  </build>

  <dependency>
    <groupId>com.google.maps</groupId>
    <artifactId>gapic-google-maps-fleetengine-delivery-v1-java</artifactId>
    <version>LATEST</version>
  </dependency>
</project>

Node.js / TypeScript

npm

You may specify the library URL in the dependencies section of package.json:

{
  "dependencies": {
    "@googlemaps/fleetengine-delivery": "https://storage.googleapis.com/fleetengine-gapic/dist/793/2022-07-19/maps-fleetengine-delivery-v1-nodejs.tar.gz",
    "google-auth-library": "^7.14.0"
  }
}

Sample code:

const fleetengine = require("@googlemaps/fleetengine-delivery");
const { GoogleAuth } = require('google-auth-library');

const token = process.env.FLEETENGINE_TOKEN;
const project_id = 'project-id';

async function main() {
    let auth = new GoogleAuth();
    auth.cachedCredential = new AuthorizationHeaderProvider();
    const client = new fleetengine.DeliveryServiceClient({ auth: auth });

    client.listDeliveryVehicles({parent: `providers/${project_id}`}).then(function(resp) {
      console.log(resp);
    }, function(err) {
      console.log(err);
    });
}

class AuthorizationHeaderProvider {
    getRequestMetadata(url, callback) {
        callback(null, {'authorization': `Bearer ${token}`});
    }
}

main().catch(console.error);

Go

The Go library is packaged as a module at https://pkg.go.dev/google.golang.org/genproto/googleapis/maps/fleetengine/delivery/v1

package main

import (
  "context"
  "fmt"
  "os"
  "google.golang.org/grpc"
  "google.golang.org/grpc/credentials"
  "google.golang.org/grpc/metadata"
  delivery "google.golang.org/genproto/googleapis/maps/fleetengine/delivery/v1"
)

func main() {
  provider := "gcp-project-id"
  vehicle := "vehicle-id"
  token := os.Getenv("FLEETENGINE_TOKEN")

  opts := []grpc.DialOption{
    grpc.WithTransportCredentials(credentials.NewClientTLSFromCert(nil, "")),
  }
  auth_header := string(fmt.Sprintf("Bearer %s", token))

  address := "fleetengine.googleapis.com:443"
  ctx := context.Background()
  ctx = metadata.AppendToOutgoingContext(ctx, "authorization", auth_header)
  conn, _ := grpc.DialContext(ctx, address, opts...)

  request := &delivery.GetDeliveryVehicleRequest {
    Name: fmt.Sprintf("providers/%s/deliveryVehicles/%s", provider, vehicle),
  }
  svc := delivery.NewDeliveryServiceClient(conn)

  response, err := svc.GetDeliveryVehicle(ctx, request)

  if (err != nil) {
    fmt.Println(err)
    return
  }

  fmt.Println(response)
}

Python

pip

pip install https://storage.googleapis.com/fleetengine-gapic/dist/793/2022-07-19/maps-fleetengine-delivery-v1-py.tar.gz

C#

The C# library can be downloaded from https://storage.googleapis.com/fleetengine-gapic/dist/793/2022-07-19/google-maps-fleetengine-delivery-v1-csharp.tar.gz

PHP

The PHP library can be downloaded from https://storage.googleapis.com/fleetengine-gapic/dist/793/2022-07-19/google-maps-fleetengine-delivery-v1-php.tar.gz

Ruby

The Ruby library can be downloaded from https://storage.googleapis.com/fleetengine-gapic/dist/793/2022-07-19/google-maps-fleetengine-delivery-v1-ruby.tar.gz