Was this helpful?

Creating Itineraries

You can create itineraries directly with GraphQL, allowing you to integrate functionality such as creating curated lists, shortlists, planning road-trips or offering itinerary planning features into your website or app. The Alpaca Travel itineraries support a wide range of functionality and can transition from simple lists to multi-day, multi-modal itineraries able to model all travel movements. Itineraries also support detailed mapping data and GPS tracks, enabling you to also have powerful maps to assist users.

Prerequisites

  • GraphQL development environment (or GraphQL Playground)

  • Your API Key

1# Creates an Itinerary you can use for a wide range of use cases such as lists
2# or sequenced itieraries.
3
4mutation CreateItinerary {
5  # Leverages the "createItinerary" mutation operation to create an itinerary
6  # with some initial content
7  createItinerary(
8    # Supply the initial content about the itinerary
9    itinerary: {
10      # Include a title
11      title: "Basic Itinerary Example"
12      # Recommended: Include a BCP-47 Locale
13      defaultLocale: "en"
14    }
15  ) {
16    # Read back the created itinerary
17    itinerary {
18      # Access the Identifier, required for further query/mutations
19      id
20    }
21  }
22}

Sandbox: Configure | Try Operation

If successful, the response will read back the created itinerary ID which can be used in subsequent queries or mutations.

1{
2  "data": {
3    "createItinerary": {
4      "itinerary": {
5        "id": "itinerary/123"
6      }
7    }
8  }
9}

Association to a Profile

By default, if you don't assign a profile, content is psueo-anonymous and is public writable/editable. This allows anyone with the ID to be able to modify the itinerary, so can suit for use cases such as public visitors to your website.

If you wish to have content assigned to your profile you will need to supply your profile during creation.

Itineraries with a profile assigned will enforce authorisation contraints.

1# Creates an itinerary and associates it to the supplied profile ID. If you need
2# to identify your profile ID, use the query authorizedProfiles
3
4mutation CreateItineraryAssociatedToProfile {
5  createItinerary(
6    # Provide the profile to assign the itinerary
7    profileId: "profile/ABC123"
8    # Initial itinerary content
9    itinerary: { title: "Itinerary associated to profile ID" }
10  ) {
11    # Read back the created itinerary
12    itinerary {
13      # Access the ID
14      id
15    }
16  }
17}

Sandbox: Configure | Try Operation

Creating an itinerary with Auto Routing

Alpaca can manage creating navigation routes between each of the itinerary locations that are added to your itinerary. You can enable this by creating your itinerary with the autoRoute feature enabled with a default route mode supplied.

1# Creates an itinerary, and configures it to assign automatic routes. Automatic
2# routes will assist basic itineraries by sequentially linking locations that
3# are added with directions, providing information about moving between these
4# locations.
5
6mutation CreateItineraryWithCarAutoRoute {
7  # When using the createItinerary mutation to create our itinerary
8  createItinerary(
9    itinerary: {
10      # Add our basic required fields
11      title: "Example Itinerary"
12      # Indicate the behaviour to auto route using Car as the default mode
13      autoRoute: { defaultMode: Car }
14    }
15  ) {
16    # Read back the created itinerary
17    itinerary {
18      # Access the Identifier, required for further query/mutations
19      id
20    }
21  }
22}

Sandbox: Configure | Try Operation

Learn more about

alpaca.tech

Copyright © 2024 - Made with love ❤️ in Australia.