Skip to content
Route4Me edited this page Apr 18, 2016 · 4 revisions

Installation

To get started with the SDK you have to import the package:

import "https://github.com/route4me/route4me-go-sdk"

After doing so, you can execute go get ./... to download the source code. The root package name is route4me.

First steps

The first step to start using Route4Me Go SDK is to create a client.

Demo API Key Restrictions

The default demo API Key 11111111111111111111111111111111 only permits you to test and optimize routes using a predefined list of lat/lng coordinates.

Creating client with default timeout

client := &route4me.NewClient("11111111111111111111111111111111")

Creating client with custom timeout and/or API URL

client := &route4me.NewClientWithOptions("11111111111111111111111111111111", time.Minute*10, route4me.BaseURL)

The client does nothing on it's own, you will need it to construct Services which are mentioned below.

SDK Design

SDK is divided into sub-packages, where each subpackage is a service. Each service is responsible for controlling different part of Route4Me infrastructure.

You will probably rely on the routing service most of the time, it allows you to work with Optimizations and Routes.

Let's create a Service instance.

import (
	"github.com/route4me/route4me-go-sdk"
	"github.com/route4me/route4me-go-sdk/routing"
)

func main() {
	client := route4me.NewClient("11111111111111111111")
	service := &routing.Service{Client: client}
	//do something with the service
}

Most of the time any function associated with the Service takes *Query instance as a parameter. For instance: routing.GetRoute(*RouteQuery)

You can read more about each service by clicking appropriate links in the sidebar.

Look at _test.go files, they contain basic use-case examples for specific services.