> ## Documentation Index
> Fetch the complete documentation index at: https://docs.mileapp.dev/llms.txt
> Use this file to discover all available pages before exploring further.

# Read location history



## OpenAPI

````yaml /openapi/public/openapi-task.json get /location-histories
openapi: 3.0.0
info:
  title: MileApp API - Task
  version: 3.0.0
  description: MileApp API Documentation - RESTful API for field operations management.
servers:
  - url: https://apiweb.mile.app/api/v3
security:
  - bearerAuth: []
tags:
  - name: Task
    description: >-
      A task is an item of work intended for completion by an assignee. It can
      embody activities like pickups, deliveries, planning, inspections, sales
      visits, or other work-related actions within your organization. Tasks
      encompass essential attributes, including IDs, flow, time, status
      indicators, assignee information, order index, and other pertinent data.
      The content of a task is configurable based on your specified flow
      settings. For instance, tasks can serve as visits during the route
      optimization process, functioning as pivotal elements. The task can also
      represent a visit in route optimization, please follow [this
      link](#tag/Routing) to read more detail.


      **To see the details of task object, please follow [this
      link](#tag/task_model)**
  - name: Location History
    description: >-
      Location history is data that stores the user's location points that are
      sent periodically from the MileApp mobile application if the user
      activates the tracking feature. However, this endpoint can also be useful
      for integration into the user's IoT devices such as GPS or other mobile
      trackers. All location data sent can be visualized in MileApp in real time
      and makes it easier for users to monitor field activities more accurately.


      **Related Guide:** [Start Finish
      Feature](/configuration/start-trip-end-trip-feature)
  - name: Task Schedule
    description: >-
      Task Schedule is a mechanism to generate tasks according to the schedule
      that is set by you. The task schedule attributes consist of IDs,
      repetition period data (daily, weekly, etc.), flow structure, task
      content, and time of the schedule's start & end. This schedule could help
      you to set a task that will be repeated at a certain period.


      **To see the details of task schedule object, please follow [this
      link](#tag/task_schedule_model)**
  - name: Activity
    description: >-
      An Activity is a multi-step task group created from a Workflow template.
      When you create an Activity, MileApp automatically creates one parent task
      (with `taskType = activityMaster`) plus one child task (with `taskType =
      activityChild`) per Workflow step, and copies field values forward between
      steps according to the Workflow's field mappings. Activities are stored
      alongside regular tasks — the parent's `_id` is also the Activity ID, and
      its `subId` array lists every child task in Workflow-step order.


      After creation, retrieve, update, or delete an Activity through the
      standard Task endpoints using the Activity master task's ID.


      **To see the details of Activity object, please follow [this
      link](#tag/activity_model)**
paths:
  /location-histories:
    get:
      tags:
        - Location History
      summary: Read location history
      operationId: getLocationHistory
      parameters:
        - name: email
          in: query
          required: false
          description: Worker's email that assigned to the monitored task.
          schema:
            type: string
        - name: taskId
          in: query
          required: false
          description: >-
            The identifier for the task that generated by system. Use [GET
            /tasks API](#Task_Task) to get the list of Task IDs.

            **Example:** `621dd813eb3ebf16b94d6969`
          schema:
            type: string
        - $ref: '#/components/parameters/pageInQuery'
        - $ref: '#/components/parameters/limitInQuery'
        - name: sortOrder
          in: query
          required: false
          description: >-
            sortOrder is to decide ascending or descending order by
            `createdTime` 

            **Example:** `asc` or `desc`.

            **Default:** `desc`
          schema:
            type: string
        - name: timeBy
          in: query
          required: false
          description: >-
            Optional filter to range data between one of the following options :

            **enum**: `createdTime`,`startTime`

            If this parameter is **not provided**, the `timeFrom` and `timeTo`
            filters will be **ignored**.

            **Example:** `createdTime`
          schema:
            type: string
        - name: timeFrom
          in: query
          required: false
          description: |-
            date time selector to select timeBy from.
            **Example:** `2023-00-01 00:00:00`
          schema:
            type: string
        - name: timeTo
          in: query
          required: false
          description: |-
            date time selector to select timeBy to.
            **Example:** `2023-00-10 00:00:00`
          schema:
            type: string
        - name: startFinish
          in: query
          required: false
          description: >-
            when the value is `true` the start finish record will be show, if
            the value is `false` it only displays the location history record.
          schema:
            type: string
        - name: isLatest
          in: query
          required: false
          description: >-
            when the value is `true`, it will display the latest location
            history data from the user, and if the value is `false`, it will
            show the older location history data.
          schema:
            type: boolean
        - name: fields
          in: query
          required: false
          description: >-
            Fields is for selecting the specific fields that you can choose by
            multiples to show in the response using a string with a comma
            delimiter.
          schema:
            type: string
        - name: eventName
          in: query
          required: false
          description: >-
            A flagging of location history with value `otw`, `nearBy` and
            `done`. 

            **Example:** `done`.

            **Default:** `null`
          schema:
            type: string
        - name: createdFrom
          in: query
          required: false
          description: >-
            A flagging for describe location history created from, default value
            generated by system is `mileAppField`. <br>**Example:**
            `GPS`.<br>**Default:** `mileAppField`
          schema:
            type: string
      responses:
        '200':
          description: Success
          headers: {}
          content:
            application/json:
              schema:
                type: object
                title: NetworkCreateResponse
                properties:
                  status:
                    type: boolean
                    description: Status of response.
                  message:
                    description: Message of API response.
                    type: string
                  tasks:
                    description: Detail of object location history.
                    type: object
                    additionalProperties: true
                example:
                  status: true
                  message: Success
                  tasks:
                    current_page: 1
                    data:
                      - email: example@mile.app
                        taskId: 634e98098ce69d29474a7e11
                        speed: 40
                        distance: 50
                        duration: 50
                        lat: -6.1771046
                        lon: 106.9240199
                        _id: >-
                          634e98098ce07d29474a7e22_example@mile.app_1675224349343
                        time: 1675224349343
                        organizationId: 634e98098ce07d29474a7e22
                        createdTime: '2022-10-07 03:00:58'
                        updatedTime: '2022-10-07 04:00:58'
                      - _id: 64a696536d01ea0d503db772
                        email: example@mile.app
                        lat: -6.23239438813826
                        lon: 106.82152618097032
                        speed: 0
                        distance: 0
                        duration: 0
                        startTime: '2023-07-06 10:23:00'
                        notes: null
                        createdTime: '2023-07-06 10:24:19'
                        taskId: ''
                        time: 1688639059872
                        organizationId: 6488344e8db84c3a511f62b2
                        finish:
                          lat: -6.296958793290206
                          lon: 106.7858189729966
                          finishTime: '2023-07-06 11:23:00'
                          notes: null
                          totalDuration: 60
                          totalDistance: 24
                        updatedTime: '2023-07-06 10:53:36'
                        trackedTime: 60
                    first_page_url: >-
                      http://apiweb.mile.app/api/location-histories?limit=20&fields=email%2CtaskId%2Clon%2Clat&email=example%40mile.app&sortBy=createdTime&sortOrder=desc&page=1
                    from: 1
                    last_page: 1
                    last_page_url: >-
                      http://apiweb.mile.app/api/location-histories?limit=20&fields=email%2CtaskId%2Clon%2Clat&email=example%40mile.app&&sortBy=createdTime&sortOrder=desc&page=1
                    links:
                      - url: null
                        label: '&laquo; Previous'
                        active: false
                      - url: >-
                          http://apiweb.mile.app/api/location-histories?limit=20&fields=email%2CtaskId%2Clon%2Clat&email=example%40mile.app&&sortBy=createdTime&sortOrder=desc&page=1
                        label: '1'
                        active: true
                      - url: null
                        label: Next &raquo;
                        active: false
                    next_page_url: null
                    path: http://apiweb.mile.app/api/location-histories
                    per_page: 20
                    prev_page_url: null
                    to: 2
                    total: 2
        '400':
          description: Bad Request
          content:
            application/json:
              schema:
                type: object
                properties:
                  status:
                    type: boolean
                    description: Shows if the request was successful.
                  message:
                    type: string
                    description: A short message explaining what went wrong.
                example:
                  status: false
                  message: Bad request - invalid parameters provided.
        '500':
          description: Server error
          content:
            application/json:
              schema:
                type: object
                properties:
                  status:
                    type: boolean
                    description: Shows if the request was successful.
                  message:
                    type: string
                    description: A short message explaining what went wrong.
                example:
                  status: false
                  message: Internal server error, please contact support@mile.app.
      deprecated: false
      security:
        - bearerAuth: []
components:
  parameters:
    pageInQuery:
      name: page
      in: query
      schema:
        default: 1
        type: integer
      description: The page number of results to retrieve. **Example:** `2`
    limitInQuery:
      name: limit
      in: query
      schema:
        default: 20
        minimum: 1
        maximum: 1000
        type: integer
      description: >-
        Specifies the maximum number of items to retrieve in a single request.
        **Example:** `10`
  securitySchemes:
    bearerAuth:
      type: http
      scheme: bearer
      bearerFormat: JWT
      description: Use a valid Bearer token to authenticate.

````