Skip to content
Derek Edwards edited this page Mar 15, 2017 · 140 revisions

General API Notes

Format of URL

<base_url>/api/v1/<object>/<method>

Authentication

In order to make trip requests, save personal POIs and other actions that require a user to be logged in a X-User-Email and X-User-Token must be passed along with the request as a header.

Example:

--header "X-User-Email: dedwards@camsys.com" --header "X-User-Token: vEUuxxx5zH9Z1wgZQ7PU"

If these headers are not provided, then it is assumed that a guest users is making the request.

Places & POIs

The Google Place format is used to represent all places.

Relevant section of the API document is here: https://developers.google.com/places/webservice/details#PlaceDetailsResults

API Calls

1. Sign In

Description

Establishes user identity for further interaction with the system.

URL

POST /api/v1/sign_in 

Request

Include the following Parameters

  • email
  • password

Example

{
  "session": 
    {
      "email": "dedwards@camsys.com",
      "password": "welcome1"
    }
}

Results

Success

  • email address string
  • authentication_token string
  • first_name string
  • last_name string
  • last_origin Google Place The origin of the last trip planned by this traveler.
  • last_destination Google Place The destination of the last trip planned for this traveler.

Email address and an authentication token. The Authentication token must be passed in all future API requests.

{"email":"dedwards@camsys.com","authentication_token":"vEUuxxx5zH9Z1wgZQ7PU"}

Failure

An error message.

2. Sign Out

Description

Logout a user. (Invalidate the authentication token.)

URL

POST api/v1/sign_out

Request

Include the following Parameters

  • user_token

Example

{"user_token":"dt8bjR77UV3sP1u7S6U-"}

Results

Success

True

Failure

False

3. Points of Interest Search

Description

Returns a list of named locations whose names match the supplied search term. The semantics of the search (i.e. starts with, contains, wildcard, etc) are abstracted from the client. Default max results limit is something sensible (10?). If an authentication token is present in the request and includeUserPois = true, then search user’s POIs as well as global POIs, default is global only.

URL

GET /api/v1/places/search

Request

Include the following Parameters in the url

  • search_string string
  • maxresults int
  • includeUserPois boolean
  • pageSize int
  • resultsPerPage int

Note 1: Use a % sign for wildcards. Otherwise an exact match will be required.

Note 2: %25 is the URL code for the % sign.

Example

http://oneclick-pa.herokuapp.com/api/v1/places/search?search_string=%25college%25

Results

Success

  • an array of locations, with the name attribute containing the POI name, and scope indicating global or user-defined.
  • resultsPerPage int
  • page int
  • recordcount int (count of all records matching criteria)

4. Get Trip Purposes

Description

Description: Retrieves a list of trip purposes in presentation order. The server may silently filter the list based on the user identity. ‘Selected’ flag is set to true for the purpose that the server has deemed to be most appropriate based on the destination parameter posted.

This service is needed for 1-Click/Ecolane integration in Pennsylvania.

URL

POST /api/v1/trip_purposes/list 

Request

There are two ways to request this.

As a logged-in user, no parameters are needed except for the user's login credentials

As a guest user, pass the following parameter in the header

  • geometry google_place This location will be used to filter the list of trip purposes

Results

Returns the follwoing:

  • trip_purposes array Array of JSON trip purposes
  • top_trip_purposes array Array of 4 trip purposes that are most likely to be selected by the traveler. All four of these trip purposes will also be present in the trip_purposes array.
  • default_trip_purposes string The String Id of the default trip purposes.

Each Trip Purpose JSON object present in the trip_purposes and top_trip_purposes arrays contains the following information

  • name string Display name of the trip purpose
  • code string Identifier of the trip purpose
  • sort_order int Indicates order that the purposes should be shown.

Example

{
   "top_trip_purposes": [
    {
      "name": "Medical Appointment",
      "code": "Medical",
      "sort_order": 1
    },
    {
      "name": "Grocery Shopping",
      "code": "Grocery",
      "sort_order": 2
    },
    {
      "name": "Dialysis",
      "code": "Dialysis",
      "sort_order": 3
    },    
    {
      "name": "Recreation",
      "code": "Recreation",
      "sort_order": 4
    }         
  ],
  "trip_purposes": [
    {
      "name": "Medical Appointment",
      "code": "Medical",
      "sort_order": 1
    },
    {
      "name": "Other",
      "code": "Other",
      "sort_order": 2
    },
    {
      "name": "Grocery Shopping",
      "code": "Grocery",
      "sort_order": 3
    },
    {
      "name": "Dialysis",
      "code": "Dialysis",
      "sort_order": 4
    }     
    {
      "name": "Senior Center",
      "code": "Senior",
      "sort_order": 5
    },
    {
      "name": "Recreation",
      "code": "Recreation",
      "sort_order": 6
    }         
  ],
  "default_trip_purpose": "Other"
}

5. Plan (Get Itineraries)

Description

Retrieves a list of itineraries in presentation order.

URL

POST /api/v1/itineraries/plan

Request

Include the following Parameters

  • user_profile json A json that updates the user's profile. This will be done before the plan call is run.
  • trip_purpose string
  • trip_token:string
  • optimize string can be ‘TIME’, ‘TRANSFERS’, or ‘WALKING’, Set to ‘TIME’ time to minimize total trip time. Set to ‘TRANSFERS’ to minimize transfers, or set to ‘WALKING’ to minimize time spent walking. If not included, ‘TIME’ is assumed.
  • itinerary_requests array of trip requests
  • segment_index int (starting with 0)
  • start_location Google Place
  • end_location: Google Place
  • trip_time ISO8601 DateTime
  • departure_type string (valid values are ‘arrive’, ‘depart’)
  • max_walk_miles (optional) float Maximum distance the traveler is willing to walk. 2 Miles is default.
  • max bicycle_miles (optional) float Maximum distance the traveler is willing to bike. 5 miles is default.
  • max_walk_seconds (optional) integer Maximum time the traveler is willing to walk. Infinity is default.
  • walk_mph (optional) float Traveler's walking speed in MPH (Used to calculate maximum distance when max_walk_seconds is specified. Also sent to OpenTripPlanner to determine trip times. Default is 3MPH. For travelers with a walking speed set in their profiles, this parameter will overwrite that parameter for the given trip.
  • num_itineraries (optional) integer The maximum number of itineraries to be returned from OTP. The default is 3.
  • modes (optional) array an array of strings for the modes that you want returned. For example ['mode_transit', 'mode_taxi', 'mode_paratransit', 'mode_bicycle', 'mode_bicycle_transit']. If modes is NULL, mode_transit, and mode_paratransit will be the default.

Modes Accepted

  • mode_transit = bus and rail
  • mode_taxi = taxi
  • mode_paratransit = shared ride / paratransit
  • mode_bicycle = bicycle only
  • mode_bicycle_transit = bike to transit and being bicycle onto the transit vehicle
  • mode_walk = walk only
  • mode_park_transit = Drive to a Park&Ride and then take transit

Example

{
  "user_profile":
  {
    "attributes": 
    {
      "email": "dedwards@camsys.com", 
      "walking_speed": "average", 
      "walking_distance": "2.5"
    },
    "characteristics":
    {
      "veteran": true,
      "ada_eligible": false
    },
    "accommodations":
    {
      "stretcher": false,
      "folding_wheelchair": true
    }
  },      
  "trip_purpose": trip_purpose_code,
  "trip_token": unique_trip_token (optional),
  "optimize": optimization_code (optional),
  "modes": ['mode_transit', 'mode_taxi', 'mode_paratransit', 'mode_bicycle', 'mode_bicycle_transit'],
  "itinerary_request": [
    {
      "segment_index": 1,
      "start_location": location element as shown above,
      "end_location": location element as shown above,
      "trip_time”: "2015-03-25T19:30:00.000-04:00",
      "departure_type": "depart"
    },
    {
      "segment_index": 2,
      "start_location": location element as shown above,
      "end_location": location element as shown above,
      "trip_time": "2015-03-25T20:30:00.000-04:00",
      "departure_type": "depart"
    }
  ]
}

Results

  • trip_id integer
  • trip_token string Optionally, if specified on the call to create the trip.
  • purposes array Array of relevant purposes for the itineraries returned. Name and Code.
  • characteristics array Array of relevant characteristics for the itineraries returned. Name, Code, and Question.
  • accommodations array Array of relevant accommodations for the itineraries returned. Name, Code, and Question.
  • itineraries array An array of itinerary objects. See below for more details.

Itinerary

Each Itinerary object contains the following:

  • cost float (Optional) Cost of the itinerary, if it is known
  • duration int Duration of trip in seconds
  • walk_time int Time spent walking in seconds
  • transit_time int Time spent on a vehicle in seconds
  • wait_time int Time spent waiting in seconds
  • walk_distance float Walk distance in meters
  • transfers int Number of vehicle transfers
  • bookable boolean Does this service allow online booking through 1-Click?
  • user_registered boolean Does the current user have valid credentials stored to book with this service?
  • start_time ISO8601 Trip starting time
  • end_time ISO8601 Trip ending time
  • discounts Array This is a json array of potential discounts. It is used for guest users only. For guest users who are interested in shared ride trips, a list of potential fares, comments, and funding sources will be returned. This information is the format: [{"fare"=>2.35, "comment"=>"Senior Citizens", "funding_source"=>"Lottery"}]
  • start_location Google Place Origin of the itinerary
  • end_location Google Place Destination of the itinerary
  • service_name string The name of the service. e.g., Rabbit Transit, MBTA, etc.
  • segment_index int indicates which segment of the itinerary request the itinerary is related to.
  • json_legs array the individual trip legs. E.g., 1) walk to the bus, 2) take bus #12, 3) walk to destination. This information is provided directly from OpenTripPlanner legs and includes service names, route names, etc.
  • pre-booking questions array {code, options, question} For bookable itineraries, This parameter defines additional questions that need to be answered by the traveler before booking.

Example

{
  "trip_id": 16,
  "trip_token": null,
  "purposes": [
    {
      "name": "Grocery",
      "code": "grocery"
    },
    {
      "name": "Medical",
      "code": "medical"
    }
  ],
  "characteristics": [
    {
      "name": "Disabled",
      "code": "disabled",
      "note": "Do you have a permanent or temporary disability?"
    },
    {
      "name": "Veteran",
      "code": "veteran",
      "note": "Are you a military veteran?"
    }
  ],
  "accommodations": [
    {
      "name": "Folding wheelchair accessible.",
      "code": "folding_wheelchair_accessible",
      "note": "Do you need a vehicle that has space for a folding wheelchair?"
    },
    {
      "name": "Motorized wheelchair accessible.",
      "code": "motorized_wheelchair_accessible",
      "note": "Do you need a vehicle than has space for a motorized wheelchair?"
    },
    {
      "name": "Curb-to-curb",
      "code": "curb_to_curb",
      "note": "Do you need delivery to the curb in front of your home?"
    }
  ],
  "itineraries": [ <ITINERARIES LISTED HERE> ]
}

6. Book Itineraries

Description

Book one or more itineraries

URL

POST /api/v1/itineraries/book

Request

Include the following Parameters in the request

  • itinerary_id int
  • assistant boolean (optional: Ecolane only) Are you traveling with a certified assistant?
  • children int (optional: Ecolane only) How many children are traveling with you?
  • companions int (optional: Ecolane Only) How many companions are traveling with you?
  • other_passengers int (optional: Ecolane Only) How many other passengers are traveling with you?
  • comments string (optional: Ecolane Only) Leave comments for the driver.
  • guests int (optional: RidePilot only) How many guests are traveling with you?
  • attendants int (optional: RidePilot only) How many attendants are traveling with you?
  • purpose int (optional: RidePilot only) What is the purpose code for this trip?
  • return_time iso8601 Time (optional) For 1-way trips, providing a return_time will automatically create a round trip and book both parts of the trip.

Example with Ecolane Parameters

{
  "booking_request": [
    {
      "itinerary_id": "3",
      "assistant": true,
      "children": 1,
      "companions": 1,
      "note": "Honk twice.",
    },
    {
      "itinerary_id": "4",
      "assistant": true,
      "other_passengers": 3,
      "note": "I'm in door #3.",
    }   
  ]
}

Example with RidePilot Parameters

{
  "booking_request": [
    {
      "itinerary_id": "44413",
      "guests": 1,
      "purpose": 1,
      "attendants": 0,
      "return_time": "2017-01-25T18:07:12+00:00"
    }
 ] 
}

Results

  • booking_results array array of itinerary booking results

(each element in the booking_results array contains the following:)

  • trip_id int
  • itinerary_id int
  • booked boolean True: Trip booked, False: Trip failed to book
  • confirmation_id text Give this number to the traveler, this is their trip confirmation number.
  • wait_start ISO8601 datetime Start of estimated pickup window.
  • wait_end ISO8601 datetime End of estimated pickup window.
  • arrival ISO8601 datetime Estimated arrival time.
  • message string Used when the trip fails to book
  • negotiated_duration float Estimated total trip duration in minutes.

Example

{
  "booking_results": [
    {
      "trip_id": "2",
      "itinerary_id": "1",
      "booked": true,
      "confirmation": "12345",
      "wait_start": "ISO8601 Time",
      "wait_end": "ISO8601 TIME",
      "arrival": "ISO8601 Time",
      "message": "Optional Message"
    },
    {
      "trip_id": "2",
      "itinerary_id": "2",
      "booked": true,
      "confirmation": “12346”, 
      "wait_start": "ISO8601 Time",
      "wait_end": "ISO8601 TIME",
      "arrival": "ISO8601 Time",
      "message": "Optional Message"
    }
  ]
}

7. Cancel Booked Itineraries

Description

Cancel 1 or more booked itineraries

URL

POST /api/v1/itineraries/cancel

Request

Include the following Parameters in the url

  • bookingcancellation_request array of itinerary ids or booking_confirmations
  • itinerary_id int (Optional: If this isn't specified then the booking_confirmation must be specified.) points to the id of a trip booked through 1-Click
  • booking_confirmation string (Optional: If this isn't specified then the itinerary_id must be specified.) the booking confirmation of a trip that was not necessarily booked through 1-Click.

Example

{
  "bookingcancellation_request": [
    {
      "itinerary_id": "3"
    },
    {
      "itinerary_id": "4"
    } ,
    {
      "booking_confirmation": "3423424"
    }
  ]
}

Results

  • cancellation_results array Array of results for each requested cancellation
  • trip_id int
  • itinerary_id int
  • success boolean
  • confirmation_id text This is the same as the booking confirmation.

8. Select Itineraries

Description

Save itineraries to My Trips

URL

POST /api/v1/itineraries/select

Request

Include the following Parameters in the request

  • select_itineraries array Array of itineraries to be selected

Example

{
  "select_itineraries": [
    {
      itinerary_id:"1"
    },
    {
      itinerary_id:"4"
    }
  ]
}

Results

Success

200

Failure

Error Message

9. Email Trips

Description

Send trip emails to the traveler.

URL

POST /api/v1/trips/email
POST /api/v1/itineraries/email (Denver RTD Only)

Request

Include the following Parameters in the request

  • email_address string email address AND EITHER:
  • trip_id int ID of current trip OR:
  • booking_confirmations array Array containing a Booking Confirmation Number

Example with Trip ID

{
  "email_address": "email@camsys.com",
  "trip_id": 1
}

Example with Multiple Recipients and Booking Confirmation

{
  "email_address": "email@camsys.com, user@camsys.com",
  "booking_confirmations": ["1695914"]
}

For Denver RTD Only

  • email_itineraries array Array of trips to email each contains email address and trip id.
  • email_address string email address
  • trip_id int

Example

{
  "trip_link": "http://url-to-list-trip.camsys-apps.com/#/trip/",
  "email_itineraries": [
    {
      "from_address": "sender@camsys.com",
      "subject": "email_subject",
      "email_address": "user@camsys.com",
      "itineraries": [
        {
          "trip_id":"1"
        }
      ]
    }
  ]
}

Example with Itineraries Specified (Denver Trip Planner)

{
  "trip_link": "http://rtd-qa.camsys-apps.com/#/plan/",
  "email_itineraries": [
    {
      "from_address": "user@camsys.com",
      "subject": "test2",
      "email_address": "lcaraballo@camsys.com",
      "trip_id": 38,
      "itinerary_ids": [96]
    }
  ]
}

Results

Success

200

Failure

Error Message

10. Trip Status From Token

Description

Return the status of a Trip.

URL

GET api/v1/trips/status_from_token

Request

Include the following Parameters in the request

  • trip_token string

Example

GET api/v1/trips/status_from_token?trip_token=1234

Results

  • trip_token string

  • trip_id int

  • code string Status of the trip

    Codes

    • BOOKED Trip is booked
    • PLANNED Trip has been saved but not booked (only used for non-bookable trips)
    • STARTED Trip started but neither booked or planned/saved
  • description string Expanded version of the status

Example

{
  "trip_status_report": {
    "trip_token": "abc123",
    "trip_id": 2,
    "code": STARTED,
    "description": "Trip is started but not planned."
  }
}

11. Trip Status From ID

Description

Return the status of a Trip.

URL

GET api/v1/trips/<id>/status

Request

Include the following Parameters in the request

  • id int Internal Trip Id

Example

GET api/v1/trips/3/status

Results

  • trip_token string

  • trip_id int

  • code string Status of the trip

    Codes

    • BOOKED Trip is booked
    • PLANNED Trip has been saved but not booked (only used for non-bookable trips)
    • STARTED Trip started but neither booked or planned/saved
  • description string Expanded version of the status

Example

{
  "trip_status_report": {
    "trip_token": "abc123",
    "trip_id": 2,
    "code": STARTED,
    "description": "Trip is started but not planned."
  }
}

12. Trip Details From Token

Description

Return the status of a Trip.

URL

GET api/v1/trips/status_from_token

Request

Include the following Parameters in the request

  • trip_token string

Example

GET api/v1/trips/details_from_token?trip_token=1234

Results

  • trip_token string

  • trip_id int

  • code string Status of the trip

    Codes

    • BOOKED Trip is booked
    • PLANNED Trip has been saved but not booked (only used for non-bookable trips)
    • STARTED Trip started but neither booked or planned/saved
  • description string Expanded version of the status

  • trip trip object a full trip object including

13. Trip Details From ID

Description

Return the status of a Trip.

URL

GET api/v1/trips/<id>/details

Request

Include the following Parameters in the request

  • id int Internal Trip Id

Example

GET api/v1/trips/3/details

Results

  • trip_token string

  • trip_id int

  • code string Status of the trip

    Codes

    • BOOKED Trip is booked
    • PLANNED Trip has been saved but not booked (only used for non-bookable trips)
    • STARTED Trip started but neither booked or planned/saved
  • description string Expanded version of the status

  • trip trip object a full trip object including

14. Get Characteristics

Description

Get a list of the global characteristics questions.

URL

GET api/v1/characteristics/list

Request

Example

GET http://oneclick-pa.herokuapp.com/api/v1/characteristics/list

Results

  • characteristics_questions array an array of characteristics questions and potential answers
  • text string Question Text
  • code string Unique code for this question
  • type string What type of question is this? Bool, Date, or Integer

Example

{
  "characteristics_questions":
    [
      {
        "text":"Do you have a permanent or temporary disability?",
        "code":"disabled",
        "type":"bool"
      },
      {
        "text":"Are you eligible for ADA paratransit?",
        "code":"ada_eligible",
        "type":"bool"
      }
    ]
 }

15. Get Accommodations

Description

Get a list of the global accommodations questions.

URL

GET api/v1/accommodations/list

Request

Example

GET http://oneclick-pa.herokuapp.com/api/v1/accommodations/list

Results

  • accommodations_questions array an array of characteristics questions and potential answers
  • text string Question Text
  • code string Unique code for this question
  • type string What type of question is this? Bool, Date, or Integer

Example

{
  "accommodations_questions":
    [
      {
        "text":"Do you need a vehicle that has space for a folding wheelchair?",
        "code":"folding_wheelchair",
        "type":"bool"
      },
      {
        "text":"Do you need assistance entering the vehicle?",
        "code":"requires_assistance",
        "type":"bool"
      }
    ]
 }

16. Point Within Coverage Area

Description

Does a given point (lat,lng) reside within the global coverage area.

URL

POST /api/v1/places/within_area

Request

Include the following Parameters in the request

  • geometry Google Place

Results

True

The point lies within the global boundary.

False

The point lies outside the global boundary.

17. Get the Global Boundary

Description

Retrieve the global boundary for the system.

URL

GET /api/v1/places/boundary

Request

Example

GET http://oneclick-rtd-qa.herokuapp.com/api/v1/places/boundary

Results

  • GeoJSON representation of the global bounary

Example

{
  "type":"MultiPolygon",
  "coordinates":
    [[[[-105.02646235099996,39.52183578300003],[-105.02673495599998,39.52182518700005], etc. . .
}

18. Get a List of Paratransit Service Ids

Description

Returns a list of all paratransit services. ["paratransit", "volunteer", "nemt", "tap", "dial_a_ride"]. Used mostly for getting a list county names in Pennsylvania.

URL

GET api/v1/services/ids

Request

Example

GET http://oneclick-pa-qa.herokuapp.com/api/v1/services/ids

Results

  • service_ids array An array of service ids

Example

{"service_ids":["lebanon","dauphin","cambria","york","northumberland","franklin"]}

19. Get a List of Humanized Paratransit Service Ids

Description

The same as #18, but the names are humanized e.g., los_angeles would become Los Angeles. Used mostly for getting a list county names in Pennsylvania.

URL

GET api/v1/services/ids_humanized

Request

Example

GET http://oneclick-pa-qa.herokuapp.com/api/v1/services/ids_humanized

Results

  • service_ids array An array of service ids

Example

{"service_ids":["Lebanon","Dauphin","Cambria","York","Northumberland","Franklin"]}

20. Get Traveler Profile

Description

Get Traveler profile of the currently logged in user. It's currently customized for FindMyRidePA. Should be generalized.

URL

GET api/v1/users/profile

Request

Example

GET http://oneclick-pa-qa.herokuapp.com/api/v1/users/profile

Results

  • first_name string
  • last_name string
  • email string
  • walking_speed string [slow = 2mph, average = 3mph, fast = 4mph]
  • walking_distance float Maximum distance the traveler is willing to walk on a trip (miles).
  • ecolane_id string Ecolane Id of this traveler
  • lang string preferred language of the traveler
  • characteristics array Hash array of answered characteristics questions
  • accommodations array Hash array of answered accommodations questions
  • preferred_modes array Array of modes that the traveler prefers to use. This can be used to hide certain modes by default.

Example

{
  "first_name":"George", 
  "last_name":"Burdell", 
  "email":"GeorgePBurdell@example.com", 
  "walking_speed":"average", 
  "walking_distance":2.0, 
  "ecolane_id":12345,
  "lang": "en",
  "characteristics": [
    {
      "name": "Disabled",
      "code": "disabled",
      "note": "Do you have a permanent or temporary disability?"
    },
    {
      "name": "Veteran",
      "code": "veteran",
      "note": "Are you a military veteran?"
    }
  ],
  "accommodations": [
    {
      "name": "Folding wheelchair accessible.",
      "code": "folding_wheelchair_accessible",
      "note": "Do you need a vehicle that has space for a folding wheelchair?"
    },
    {
      "name": "Motorized wheelchair accessible.",
      "code": "motorized_wheelchair_accessible",
      "note": "Do you need a vehicle than has space for a motorized wheelchair?"
    },
    {
      "name": "Curb-to-curb",
      "code": "curb_to_curb",
      "note": "Do you need delivery to the curb in front of your home?"
    }
  ],
  "preferred_modes": [
    "mode_paratransit",
    "mode_transit"
  ]
}

21. Update Traveler Profile

Description

Update Traveler profile of the currently logged in user. It's currently customized for FindMyRidePA. Should be generalized.

URL

POST api/v1/users/update

Request

Include the following Parameters in the request

  • attributes json Contain attributes to be updated.
  • characteristics json Contains updated characteristics questions.
  • accommodations json Contains updated accommodations question.
  • password string Updated Password
  • password_confirmation string Confirm your password
  • lang string Preferred language
  • preferred_modes array Array of preferred modes

Supported Attributes

  • first_name string
  • last_name string
  • email string
  • lang string (e.g., 'en', 'es')
  • walking_speed string [slow = 2mph, average = 3mph, fast = 4mph]
  • walking_distance float Maximum miles a person is willing to walk.

Example

{
  "attributes": 
  {
    email: "dedwards@camsys.com", 
    walking_speed: "average", 
    walking_distance: "2.5"
  },
  "characteristics":
  {
    veteran: true,
    ada_eligible: false
  },
  "accommodations":
  {
    stretcher: false,
    folding_wheelchair: true
  },
  "booking":
  [ 
    { "service_id": 3, "user_name": "bob@bob.bob", "password": "B0B" }
  ],
  "lang":"es",
  "preferred_modes", ["mode_paratransit", "mode_transit"]
}

Results

  • will return status code 200 if user info was updated successfully, 400 if not
  • message string
  • booking["result"] boolean If booking profile info was passed, did it all authenticate successfully?
  • booking["message"] string Message describing the outcome of booking info authentication.

22. Get Future Trips

Description

Get all the upcoming trips for a traveler.

URL

GET api/v1/trips/future_trips

Request

Include the following Parameters in the request

No parameters should be included, the user is assumed to be the logged in user.

Results

A trip array will be returned.

Each trip will contain a hash of either 1 or two itineraries. They keys for these itineraries will be

  • 0 For the first itinerary in the trip. (i.e., the Outbound Itinerary)
  • 1 For the second itinerary in the trip. (.e., the Return Itinerary). Note: The return itinerary is optional.

Each itinerary will contain the following

  • mode _string _
  • booking_confirmation string (optional)
  • system string The system the trip was booked with (optional)
  • customer_id string (optional)
  • status string (optional)
  • departure iso8601 time
  • arrival iso8601 time
  • fare float (optional)
  • assistant boolean is their an assistant booked with this trip? (optional)
  • children int how many children are traveling (optional)
  • companions int how many additional companions are traveling (optional)
  • origin Google Place
  • destination Google Place
  • duration float duration of trips in seconds
  • walk_time float total walk time of trip in seconds
  • transit_time float total time spent traveling in a vehicle in seconds
  • wait_time float total time spent waiting in seconds
  • walk_distance float total distance walked in meters
  • transfers int total number of transfers
  • json_legs hash hash of all leg details (walking directions, transit directions, shapes, etc.) from OpenTripPlanner.

23. Get Past Trips

Description

Get past trips for a traveler. This only checks trips that occurred in the past year. Passing a date will only retrieve orders between 1 year ago and that date. Passing a max_results=N will limit the results to the N most recent trips planned within the date range.

URL

GET api/v1/trips/past_trips

Request

Include the following Parameters in the request

  • max_results int (optional) the maximum number of trips to return. The default is 10

Results

A trip array will be returned.

Each trip will contain a hash of either 1 or two itineraries. They keys for these itineraries will be

  • 0 For the first itinerary in the trip. (i.e., the Outbound Itinerary)
  • 1 For the second itinerary in the trip. (.e., the Return Itinerary). Note: The return itinerary is optional.

Each itinerary will contain the following

  • mode _string _
  • booking_confirmation string (optional)
  • system string The system the trip was booked with (optional)
  • customer_id string (optional)
  • status string (optional)
  • departure iso8601 time
  • arrival iso8601 time
  • fare float (optional)
  • assistant boolean is their an assistant booked with this trip? (optional)
  • children int how many children are traveling (optional)
  • companions int how many additional companions are traveling (optional)
  • origin Google Place
  • destination Google Place
  • duration float duration of trips in seconds
  • walk_time float total walk time of trip in seconds
  • transit_time float total time spent traveling in a vehicle in seconds
  • wait_time float total time spent waiting in seconds
  • walk_distance float total distance walked in meters
  • transfers int total number of transfers
  • json_legs hash hash of all leg details (walking directions, transit directions, shapes, etc.) from OpenTripPlanner.

24. Create Map For Trip Itineraries

Description

Generate images of each itinerary map for the specified trip. It's currently customized for Denver Trip Planner.

URL

POST /api/v1/itineraries/request_create_maps

Request

Include the following Parameters in the request

  • trip_id int OR
  • itinerary_ids array of integers

Trip Id Example

{ "trip_id": 100}

Itinerary Ids Example

{ "itinerary_ids": [100]}

Results

Success

200

Failure

Error Message

25. Itinerary Map Image Status

Description

Checks to see if a rendered map image is available for the specified itineraries. It's currently customized for Denver Trip Planner.

URL

POST /api/v1/itineraries/map_status

Request

Include the following Parameters in the request

  • id int Comma separated list of itineraries

Example

{ "id": 100}

Results

Success

{
  "itineraries": [{
	  "id": 100,
	  "has_map": true,
	  "url": "/uploads/itinerary/map_image/100/itinerary_map20160614-4212-1xc3gc1.png"
  }]
}

Failure

Error Message

26. Trip Email

Description

Email trip details from either a trip_id or a list of booking_confirmations.

URL

POST /api/v1/trips/email

Request

Include the following Parameters in the request

  • email_address string Comma separated string of emails
  • booking_confirmations array (Optional: If this is not specified, trip_id must be specified) array of strings of booking booking confirmation numbers
  • trip_id int (Optional: If this is not specified, booking_confirmations must be specified) Integer of the trip id

Note: You need either booking_confirmations OR trip_id. Both are not needed.

Example

Example using booking confirmations

{"email_address": "dedwards8@gmail.com", "booking_confirmations": ["16233178", "16233179"]}

Example using trip_id.

{"email_address": "dedwards8@gmail.com", "trip_id": "3838"}

Results

Success

Returns 200

Failure

Error Message

27. Find Translations

Description

Pass a locale and an array of translation key and get back a dictionary of those translations.

URL

POST /api/v1/translations/find

Request

Include the following Parameters in the request

  • locale string String of locale e.g., "en" or "es"
  • translations array An array of translations

Example

Example body

{"locale": "en", "translations": ["splash", "welcome", "mode_walk"]}

Results

{
  "splash": "<html>Hello World!</html>",
  "welcome": "Welcome",
  "mode_walk": null
}

28. All Translations

Description

Get all translations for a specific locale or for all locales.

URL

GET /api/v1/translations/all

Request

Include the following Parameters in the request

  • lang string (Optional) String of locale e.g., "en" or "es"

Examples

Get all translations for all locales.

http://oneclick-pa-qa.camsys-apps.com/api/v1/translations/all

Get all translations for Spanish only.

http://oneclick-pa-qa.camsys-apps.com/api/v1/translations/all?lang=es

Results

For all locales, the results will look like this

{"es":{"hello":"hola","goodbye":"adios"},"en":{"hello":"Hi","goodbye":"Good bye"}}

For specific locales, the locale is omitted and only the dictionary is returned.

{"hello":"hola","goodbye":"adios"}

29. Recent Places

Description

Get the 4 most recently used places for a logged in user.

URL

GET /api/v1/places/recent

Request

Include the following Parameters in the request header

  • X-User-Token
  • X-User-Email

Results

An array of the 20 most recent places.

30. Sign Up

Description

Create a new user.

URL

POST /api/v1/sign_up 

Request

Include the following Parameters

  • first_name
  • last_name
  • email
  • password
  • password_confirmation

Example

{
  "email": "gpburdell@camsys.com",
  "password": "welcome1",
  "password_confirmation": "welcome1",
  "first_name": "George",
  "last_name": "Burdell"
}

Results

Success

  • email address string
  • authentication_token string

Email address and an authentication token. The Authentication token must be passed in all future API requests.

{"email":"dedwards@camsys.com","authentication_token":"vEUuxxx5zH9Z1wgZQ7PU"}

Failure

An error message explaining why the user creation failed.

31. User Lookup

Description

For booking service users that have forgotten their ID, looks up ID by user attributes. Currently only works for Ecolane, and requires last name, last 4 digits of social, and home county.

URL

GET /api/v1/users/lookup 

Request

Include the following Parameters in the url

  • booking_agency string
  • county string
  • last_name string
  • date_of_birth string (format: YYYY-MM-DD) [OPTIONAL]
  • ssn_last_4 int or string [OPTIONAL]

Example

GET ../api/v1/users/lookup?booking_agency=ecolane&last_name=user&date_of_birth=1950-05-30&county=countyname

Results

Success

  • customer_number string

Returns the identifying ID number for the user's external booking service account. You may query using date_of_birth, ssn_last_4, or both.

{ "customer_number": "79109" }

Failure

Will return ERROR: 404 and a message if there were NO results, or MORE THAN ONE result, or if an invalid booking_agency parameter was passed.

32. Update Password

Description

Update Traveler Password

URL

POST api/v1/users/password

Request

Include the following Parameters in the request

  • password string
  • password_confirmation string

Example

{
  "password": "welcome1",
  "password_confirmation": "welcome1"
}

Results

  • will return status code 200 if the password updated successfully, 406 if not

32. Update Password

Description

Update Traveler Password

URL

POST api/v1/users/password

Request

Include the following Parameters in the request

  • password string
  • password_confirmation string

Example

{
  "password": "welcome1",
  "password_confirmation": "welcome1"
}

Results

  • will return status code 200 if the password updated successfully, 406 if not

33. Send Reset Password Email

Description

Send an email to the user with password reset instructions

URL

localhost:3000/api/v1/users/request_reset

Request

Include the following Parameters in the request

  • email string

Example

{
    "email":"jsmith@example.com"
}

Results

  • will return status code 200 and send an email to the user.

34. Reset a Password from Reset Token

Description

Reset a user's password from a password reset token.

URL

POST /api/v1/users/reset

Request

Include the following Parameters in the request

  • password string
  • password_confirmation string
  • reset_password_token string This token is provided in URL, in the email sent by 33. Send Reset Password Email

Example

{
  "password": "welcome2", 
  "password_confirmation":"welcome2", 
  "reset_password_token":"djejesjaklsdvlk2929"
}

Results

The call will return with a status code and a message

  • will return status code 200 if the password is reset
  • will return status code 400 if the password or password_confirmation is missing
  • will return status code 403 if reset_password_token is invalid
  • will return status code 406 if the password is unacceptable

Clone this wiki locally