Wiki

Clone wiki

ma3route-api-documentation / Directions

Home

#!https
GET /directions

To access directions send a GET request to https://www.ma3route.com/findit-api/v2/json/directions

Parameters

Note: If no other parameter other than the defaults parameters is supplied, the server returns a response jsonobject with no data value.

  • from_id and to_id are both integer values. Both MUST be provided. from_id is the id of the "placefrom" and to_id is the id of the "place to".

  • name A string value formed from the placefromid followed by "-" then the placetoid e.g https://www.ma3route.com/findit-api/v2/json/directions?name=37-111. Only used if from_id and to_id are not provided.

Note: To get a list of places, send a GET request to https://www.ma3route.com/findit-api/v2/json/places with town_id and lastread_id parameters. The server gives a max of 200 places, make multiple calls with different lastread_id to get all places for a town.

The data property of the response object is an object whose most important properties include: description, cost, alternative and altCost.

Sample response

#!json

{
   "meta":"",
   "data":{
      "placeFrom":{
         "id":37,
         "town":{
            "id":1,
            "name":"Nairobi",
            "isActive":true,
            "description":"Nairobi is the capital of Kenya.",
            "country":"Kenya",
            "latitude":"-1.29207",
            "longitude":"36.82195"
         },
         "name":"Westlands",
         "isActive":true,
         "isapproved":true,
         "description":"Near Westlands Square",
         "latitude":"-1.2700225376",
         "longitude":"36.81129634",
         "location":"Near Westlands Square",
         "isedited":false
      },
      "placeTo":{
         "id":111,
         "town":{
            "id":1,
            "name":"Nairobi",
            "isActive":true,
            "description":"Nairobi is the capital of Kenya.",
            "country":"Kenya",
            "latitude":"-1.29207",
            "longitude":"36.82195"
         },
         "name":"Otiende",
         "isActive":true,
         "isapproved":true,
         "description":"Next to the Southern By-pass",
         "latitude":"-1.3216753734",
         "longitude":"36.77909374",
         "location":"Next to the Southern By-pass",
         "isedited":false
      },
      "description":"Board the 135-Limuru at Gama Pinto Road and Alight at Kaka Terminal. Board the 15-Langata at Bus Station and Alight at Otiende.",
      "cost":"- - -",
      "alternative":"Unknown",
      "altCost":"- - -"
   }
}

#!https
POST /directions
To post a direction item send a POST request to https://www.ma3route.com/findit-api/v2/json/directions

The request body should be a json object with it's fields as in:

#!json
{
    "townid":"?", 
    "fromid":"?",
    "toid": "?"
    "description":"?",     
    "cost":"?",
    "alternative":"?", 
    "alternativecost":"?",     
}
* townid a integer value, the town id. Mandatory. * fromid a integer value, the place from id. Mandatory. * toid a integer value, the place to id. Mandatory. * description a string value. Mandatory. * cost description of cost. optional. * alternative description of alternative means. * altcost description of alternative means cost.

Once you post, you will receive a response from the server, which is a JSON object that will indicate if you successfully posted the ad or if an error occurred. For now, we are not pointing to the exact cause of the error, this will be done in future enhancements.

Server response

#!json
{
   "meta":{      
   },
   "data":{
      "success":true,
      "message":"You successfully posted an update"
   }
}
OR

#!json
{
   "meta":{      
   },
   "data":{
      "success":false,
      "message":"Error! Check that you have all mandatory properties in the object. Avoid empty strings!"
   }
}

Updated