Get Rides


GET /v1/api/corporate/rides?status=<status>&limit=<limit>&offset=<offset>

GET /v2/api/corporate/rides?status=<status>&limit=<limit>&offset=<offset>

Use this Api to get list of rides taken by corporate for a given period.


Request Parameters

Name Data Type Description Type Remark
from_date Date Get all rides from given date query Mandatory
to_date Date Get all rides till a date query Mandatory
limit integer Number of rides to be fetched query Optional
page_num integer Offset for getting next page results query Optional
order string Order by ride start time query Optional
user_email_id string Email Id of user query Optional
employee_code string Employee code of user added by corporate admin query Optional
anchor string End row anchor id response Optional
  • Example Request

    GET

    https://devapi.olacabs.com/v1/api/corporate/rides?from_date=2016-09-01 00:00:00&to_date=2016-10-05 00:00:00&limit=5&page_num=1&order=ride_start_time_asc&user_email_id=corpwebtesting@corporate_partners.com

    https://devapi.olacabs.com/v2/api/corporate/rides?from_date=2016-09-01 00:00:00&to_date=2016-10-05 00:00:00&limit=5&page_num=1&order=ride_start_time_asc&user_email_id=corpwebtesting@corporate_partners.com

    
        Headers: {
          X-CORPORATE-TOKEN: fd5d4d3726121212f12ff12f12f1f12f1f12fa
        }
    
    

    Example Response (Success)

      200
        {
          "timestamp": "2017-08-04 17:37:58",
          "total_results": 367,
          "anchor": "107702",
          "results": [
            {
              "id": 107702,
              "crn": "OSN_12345678",
              "trip_start_time": "2017-06-01 16:36:34",
              "trip_end_time": "2017-06-01 16:35:15",
              "pickup_area": "463 6th Main Road, Mathikere, Bengaluru, Karnataka, India",
              "drop_location": "540 100 Feet Road, Domlur, Bengaluru, Karnataka, India",
              "cab_category": "Sedan",
              "comment": "",
              "reason": "Field sourcing/Supply management",
              "payment_type": "employee",
              "payment_mode": "CASH",
              "user_name": "Divesh",
              "user_email": "name.ex@corporate_partners.com",
              "employee_code": null,
              "user_group": "MobileGroup",
              "bill": 231,
              "expense_code": "",
              "booking_created_by": null,
              "approval_status": "Admin require details",
              "fare_breakup": {
                "base_cost": 217.96,
                "service_tax": 12.18,
                "sb_tax": 0.43,
                "krishi_kalyan_tax": 0.43,
                "toll_and_parking": 0
              }
            }
          ]
        }
    

    Please Note:

    • total_results : Total results e.g. in this sample response we have 5 rows and total_rsults=15. This indicates that there are 10 more results to fetch.
    • anchor : To avoid overlapping of results. This is passed from server. It is recommended to send this value in the next page query.

    Example Responses (Failures)

    • Invalid Partner Token used

        401 -
          {
            "Code":"invalid_partner_key",
            "message":"Partner key is not authorized"
          }
      
    • No user found with given employee_code

        400 -
          {
            "message": "No user found with given employeeCode",
            "status": 400
          }
      
    • If page_num passed is < 1

        403 -
          {
            "message": "Pagination start from 1 onwards.",
            "status": 403
          }
      
    • If limit passed is < 1

        403 -
          {
            "message": "Please specify a positive limit.",
            "status": 403
          }
      
    • from_date format not correct

        403 -
          {
            "message": "Please enter a proper from date.",
            "status": 403
          }
      
    • to_date format not correct

        403 -
          {
            "message": "Please enter a proper to date.",
            "status": 403
          }
      
    • start_time and end_time not provided

        403 -
          {
            "message": "Please specify a proper time.",
            "status": 403
          }
      
    • If start_time > end_time

        403 -
          {
            "message": "From date can not be greater than to_date.",
            "status": 403
          }
      
    • Incase of multiple errors in parameters

        403 -
          {
            "message": "Please specify a proper time. Pagination start from 1 onwards.",
            "status": 403
          }
      
    • Unknown error

        500 - Unknown error
      
  • Example Request (PHP)

    
          <?php
          $curl = curl_init();
          $headers = array("X-CORPORATE-TOKEN: <CLIENT-SPECIFIC-TOKEN>");
          $options = array(
          CURLOPT_URL => '<HOST>/v1/api/corporate/rides?from_date=2016-10-01%2000%3A00%3A00&to_date=2016-10-10%2000%3A00%3
          A00&limit=5&page_num=1',
          CURLOPT_CUSTOMREQUEST => "GET",
          CURLOPT_ENCODING => "", CURLOPT_MAXREDIRS => 10,
          CURLOPT_TIMEOUT => 30, CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
          CURLOPT_HTTPHEADER => $headers, CURLOPT_RETURNTRANSFER => true
          );
          curl_setopt_array($curl, $options);
          $response = curl_exec($curl);
          $err = curl_error($curl);
          curl_close($curl);
          if ($err) {
          echo "cURL Error #:" . $err;
          } else {
          echo $response; }
          ?>
                

    Example Request (JAVA)

    
          import org.apache.http.HttpResponse;
          import org.apache.http.client.HttpClient;
          import org.apache.http.client.methods.HttpDelete;
          import org.apache.http.client.methods.HttpGet;
          import org.apache.http.client.methods.HttpPost;
          import org.apache.http.client.methods.HttpPut;
          import org.apache.http.entity.StringEntity;
          import org.apache.http.impl.client.HttpClientBuilder;
          import java.io.BufferedReader;
          import java.io.IOException;
          import java.io.InputStreamReader;
          ....
          private HttpResponse runGet() throws IOException {
          HttpClient httpClient = HttpClientBuilder.create().build();
          HttpGet request = new HttpGet("<HOST>/v1/api/corporate/rides?from_date=2016-10-01%2000%3A00%3A00&to_date=201
          6-10-10%2000%3A00%3A00&limit=5&page_num=1");
          request.addHeader("X-CORPORATE-TOKEN","<CLIENT-SPECIFIC-TOKEN>");
          request.addHeader("Content-Type", "application/json");
          HttpResponse response = httpClient.execute(request);
          BufferedReader reader = new BufferedReader(new InputStreamReader(
          response.getEntity().getContent()));
          String inputLine;
          StringBuffer responseEntity = new StringBuffer();
          while ((inputLine = reader.readLine()) != null) {
          responseEntity.append(inputLine); }
          System.out.println(responseEntity.toString());
          reader.close();
          return response;
          }