/
API: Booking commands

API: Booking commands

The examples are based on the Geodis Leaps system, but the same applies to any other Leaps system, just replaced the URL etc.

Accessing the API

The API is accessed using the following URL:

https://portal.ff.geodis.com/api/endpoint.php

All communication with the API is facilitated using UTF-8 encoded JSON.

When communicating with the API, the JSON should be provided in the parameter json using either POST or GET ex.

https://portal.ff.geodis.com/api/endpoint?json=...

Other Leaps systems (e.g. GLS) use different URLs.

Definitions

All communications are facilitated using JSON. In this documentation we use the following terms, to reference different JSON structures.

Set

A set is defined as field:value pairs, defined in JSON as:

{field1: value1, field2: value2,...}

A value can be a basic type, another set or a collection.

Collection

A collection is defined as a list of values, defined in JSON as:

[value1, value2,...]

A value can be a basic type, a set or another collection.

Basic types

The API uses the following basic types:

TypeExampleFormat, when sending to APIFormat, when receiving from API
stringHello WorldHello WorldHello World
number (integer)292929
float12.5912.59 / 12,5912.59
booleantruetrue / 1 / yes1

falsefalse / 0 / no0
emailtest@invalid.invtest@invalid.invtest@invalid.inv
date5. august 20112011-08-052011-08-05


05-08-2011


5-8-2011


05/08/2011


(etc)
time18:4518:45:0018:45:00


18:45


18.45


(etc)
binaryN/AN/AN/A


Concept

The API is used to pass one or more commands to Leaps. The commands are given in a collection, which again is wrapped in an envelope containing identification information such as the API-key, user name and/or password. When all commands has been executed, a structure is returned with the result of each command.

Versioning

Fields and commands are never removed from the API, but new fields can be implemented both in objects and command results. Therefore it is important that implementations against the API allows for this, in order to be forward-compatible.

Envelope

All communication to the API must be contained in an envelope, as described in this section. The envelope is a set containing the following fields:


contractnumberA contract number (provided by Geodis)
apikeystringAn API key (provided by Geodis)
usernamestringA user name (provided by Geodis)
passwordstringA password (provided by Geodis)
commandscollectionA collection of the commands which are to be executed.


The envelope can also contain the following field:

haltonerror0 or 1If set to 1, the API will halt execution if a command throws an error, otherwise the API will just continue to the next command (default behavior)
remoteagentstringThe API client can identify itself by providing a short identifier string, which will be recorded in the Leaps log and help troubleshooting.


An example envelope can look like this in JSON:

{"contract": xxx,"apikey":"xxx","username":"xxx","password":"xxx","commands": []}

If there is an error in the envelope, the following set will be returned:

statusbooleanAlways 0 when an error occurred.
msgstringAn error message.
datedateThe date on the server, when the envelope was received.
timetimeThe time on the server, when the envelope was received.


If the envelope is correct, the following set will be returned:

statusbooleanAlways 1 when envelope is correct. This isn't an indicator for whether the commands executed.
msgstringOK
resultscollectionA collection of results for each of the provided commands.
datedateThe date on the server, when the command execution started
timetimeThe time on the server, when the command execution started


Command

A command is a set containing at least the following field:

commandstringThe command to be executed.


The rest of the fields in the set is determined by the command executed.

If the command fails it will return the following set:

statusbooleanAlways 0 when an error occurred.
msgstringAn error message.


If the command succeeds it will return a set containing at least the following field:

statusbooleanAlways 1 when command succeeded.


The rest of the fields in the set is determined by the command executed.

Testing the API / Example

Connection to the API can be tested using the Echo command, which take a parameter text which is just returned as a result in the field answer.

The JSON for calling the Echo command looks like this:

{"portal":"XXX","apikey":"","username":"X","password":"X","commands":[{"command":"Echo","text":"Hello World"}]}

(remember to substitute the X's for the info received from Geodis).

Using GET the command can be executed calling this URL:

https://portal.ff.geodis.com/api/endpoint.php?json=%7B%22portal%22%3A%22X%22%2C%22apikey%22%3A%22X%22%2C%22username%22%3A%22X%22%2C%22password%22%3A%22X%22%2C%22commands%22%3A%5B%7B%22command%22%3A%22Echo%22%2C%22text%22%3A%22Hello+World%22%7D%5D%7D

If the envelope is correct, the server will respond with:

{"status":1,"msg":"OK","results":[{"status":1,"answer":"Hello World"}]}

Complex types

All complex types are sets, describing objects in Leaps. All fields in bold are required. If an optional field is omitted and the command operates on existing data, the current value of the field will be preserved.

(X) This field is only provided when receiving objects from the API. It is ignored when transmitting to the API.

address

NameTypeMeaningExample
idnumberInternal ID used by Leaps to reference this address
gidstring

namestring
“MegaCorp Inc.”
addr1string

addr2string

postcodestring

citystring

statestring

countrystringThe 2-letter country code“UK”
contactstringName of contact person“Tony Blair”
emailstring
“tony@megacorp.co.uk
phonestring

mobilestring


The id field can be 0 if this is a temporary address, instead of an address from the address book.

countryandlocation

The locations set holds a list of location names, indexed by internal IDs.

NameTypeMeaningExample
idnumber
222
namestring
“UNITED KINGDOM”
locationsset
{ 125: “London”, 145: “Leeds”, 160: “Heathrow”, 181: “Dover” }


package

width, height, length, weight, volume are specified in the units used by the portal, see GetUnits.

NameTypeMeaningExample
idnumberInternal ID used by Leaps to reference this package
pcsnumberNumber of pieces1
packtypenumberThe package type, see GetPackageTypes20
descriptionstring

shippingmarkstring

widthfloat

heightfloat

lengthfloat

weightfloat

volumefloat


priceline

NameTypeMeaning
titlestringThe name of a fee or some other cost
amountfloat
originalstringThe amount in the original currency


sheet

NameTypeMeaning
titlestringName of a pricesheet
validbooleanTrue of this is a valid pricesheet, false if pricesheet doesn't apply
notestringOnly if valid is true
errorstringOnly if valid is false
total_exclfloatTotal price
addonfloat
currencystringThe currency used, eg. “DKK”
transittimenumber
linescollection[priceline]


shipment

NameTypeMeaningExample
slinostringThe SLI number of this shipment
senderaddress

receiveraddress

pickupaddress

deliveryaddress

notifyaddress

incotermsstring
“EXW”
notestring

deliverynotestring

pickupnotestring

confirmationnotestring

distributionnotestring

statusstring
“Delivered”
deliverytypestring
“DD”
datedateWhen the shipment was created in Leaps, GMT
timetimeWhen the shipment was created in Leaps, GMT
pickupdatedate

pickuptimeearlytime

pickuptimelatetime

productstring

etadatedate

awbnostring

packagescollection[package]


Possible statuses: Booked, Pending, In transit, Deviation, Delivered, Confirmed, Cancelled, Cancelled by CCS.

statusmessage

NameTypeMeaning
id (X)numberInternal ID used by Leaps to reference this status message
slinostringSLI number of the shipment this status message belongs to
datedateDate when the status message was generated
timetimeTime when the status message was generated
descriptionstring
location (X)string
awbnostringAWB number of the shipment, if available
carrierstringThe carrier for the shipment


Miscellaneous commands

Echo


Input

textstring

Output

answerstringThe text field from the input

Price commands

GetCountriesAndLocations

Retrieves a list of countries and locations.

Input

NameTypeMeaning
None--


Output

from_countriescollection[countryandlocation]
to_countriescollection[countryandlocation]

GetCurrencies

Get a list of available currencies.

Input

None--


Output

NameTypeMeaningExample
currenciesset
{ “DKK”:“DKK”, “EUR”:“EUR”, “SEK”:“SEK” }

GetPackageTypes

Get list of the available package types. The result is a set with the names of the package types, indexed by the package type numbers.

Input

None--


Output

NameTypeMeaningExample
packtypesset
{ 100: “Bag”, 107: “Basket”, 29: “Tube” }

GetProducts

Get list of the available products.

Input

None--


Output

productscollection

Each item in the collection contains two fields: id and title.

GetUnits

Get the units being used, ie. kg or lb, m3 or ft3.

Input

NameTypeMeaning
None--


Output

NameTypeMeaning
weightstringEither kg or lb
volumestringEither m3 or ft3

GetPriceCalculation

Calculate the prices for a shipment.

Input

The number of packages, their packtype and weight and volume should be specified in fields named pcs1, packtype1, weight1, volume1, width1,height1,length1pcs2, packtype2, weight2, volume2, pcs3 etc.

Weight and volume is specified per package.

NameTypeMeaningExample
from_countrynumberThe ID of a country3
from_locationnumberThe ID of a location in the from_country, or 0 for no location
to_countrynumberThe ID of a country4
to_locationnumberThe ID of a location in the to_country, or 0 for no location
pcs<N>number

packtype<N>numberType of package, one of the values retrieved by the API call GetPackageTypes
weight<N>floatUnits should be as returned by the API call GetUnits12.5
volume<N>floatUnits should be as returned by the API call GetUnits0.0012
width<N>floatUnits should be centimeters50
height<N>floatUnits should be centimeters
length<N>floatUnits should be centimeters
addon_costfloatAdditional fee to add, see fee_type5.5
fee_typestringIf addon_cost is a flat fee or a percentagepercent or flat
currencystringThe code for a currency, only used if addon_cost is set, in which case it is requiredDKK


If addon_cost isn't set then the result is returned in EUR. Otherwise the result is returned in the currency specified by currency.

Output

sheetscollection[sheet]

Booking commands


GetBookingsByLastChange

Get the SLI numbers of all shipments that have changed since a given date/time.

Input

NameTypeMeaning
changedatedateThe date of the oldest shipment to retrieve
changetimetimeThe time of the oldest shipment to retrieve


Output

NameTypeMeaning
slinoscollectionA list of SLI numbers, each is a string

GetBookingBySLIno

Get details about a shipment.

Input

NameTypeMeaning
slinostringThe SLI number of a shipment


Output

NameTypeMeaning
shipmentshipment

GetStatusMessagesBySLIno

Get list of status messages for a shipment.

Input

NameTypeMeaning
slinostringThe SLI number of a shipment


Output

NameTypeMeaning
statusmessagescollection[statusmessage]

GetLabelBySLIno

Get the label for a shipment.

Input

NameTypeMeaning
slinostringThe SLI number of a shipment


Output

NameTypeMeaning
labelstringThe label, base 64 encoded
fromcarrierbooleanTrue if the label is a carrier label

GetLabels

Get the labels for the shipments for a period. The period can be no longer than 14 days. The dates refer to the creation date of the shipments. Only carrier labels are returned.

Input

NameTypeMeaning
slinoscollection[string]Only get labels for these SLI numbers
startdatedate
enddatedate


Output

NameTypeMeaning
labelscollection[string]The labels, base 64 encoded
slinoscollection[string]List of SLI numbers, in same order as the labels

AddStatusMessage

Add a status message to a shipment. The message will simply appear in the list of status messages for the shipment, it will not be emailed to those who may subscribe to status messages.

Input

NameTypeMeaning
statusmessagestatusmessage


Output

NameTypeMeaning
statusmessagestatusmessage

Related content

API: Basic concepts
More like this
Basic types
More like this
API: Getting started
API: Getting started
More like this
EDI specification
More like this
API: Price commands
More like this
Booking XML format
More like this