# Retrieving Work Logs via the API (https://jetheads.io/help-center/fundamentals/jettime/integrations/retrieving-work-logs-via-the-api/)

Due to our privacy-first approach, detailed in [this article](/help-center/fundamentals/jettime/integrations/privacy-first-approach-to-data-integration/), you must use the Jira REST API to retrieve work logs with JetTime metadata.

## Scenario for Retrieving Work Logs [#scenario-for-retrieving-work-logs]

### 1. Retrieve Work Items Using JQL [#1-retrieve-work-items-using-jql]

First, retrieve the work items you want to get work logs for using the [Search for issues using JQL enhanced search](https://developer.atlassian.com/cloud/jira/platform/rest/v3/api-group-issue-search/#api-rest-api-3-search-jql-post) endpoint. For example, search for specific space work items or work items with a particular custom field set.

**Notes and hints**:

- Use the `worklogDate` JQL field to limit work items to those with work logs in the selected date range.
- Due to Jira's inconsistencies in handling time zones, we recommend extending the date range by one day at the start and end of the range. Then keep each work log whose day falls in the range — its day in its own time zone: the `timeZone` in its `jettime` property, else the author's `timeZone`. That is the day JetTime shows.

### 2. Retrieve Work Logs for Each Work Item [#2-retrieve-work-logs-for-each-work-item]

For each work item retrieved, use the [Get issue worklogs](https://developer.atlassian.com/cloud/jira/platform/rest/v3/api-group-issue-worklogs/#api-rest-api-3-issue-issueidorkey-worklog-get) Jira API endpoint. Make sure to include the `expand=properties` parameter to retrieve JetTime metadata for each work log.

### 3. Read the JetTime Property [#3-read-the-jettime-property]

The metadata sits in the property with the key `jettime`. Alongside the custom time categories and work log fields, it records how the work is organized: `account`, `team`, and `functionRole`, each stored as `{"name": ..., "key": ...}` or `null`. See [JetTime Work Log Metadata](/help-center/fundamentals/jettime/integrations/jettime-work-log-metadata/) for the full shape.

**Notes and hints**:

- Group and match on the `key`. It is the stable identifier; the `name` is a snapshot taken when the entry was written, so an object renamed since then still reads under its old name.
- Any of `account`, `team` and `functionRole` can be absent or `null` — the work log simply wasn't logged under one.
- `null` under `timeSpentSeconds` or `fields` is a field left empty; a missing key is a field the work log's form doesn't show. Jira's own `timeSpentSeconds` of `0` is an entered zero only with `"REGULAR": 0` in the property — see [JetTime Work Log Metadata](/help-center/fundamentals/jettime/integrations/jettime-work-log-metadata/).
- `timeZone` is the IANA name of the time zone the work log was logged in, for example `Europe/Berlin`. Read `started` in it to get the day and clock time JetTime shows. Work logs created outside JetTime may not have it yet.

## Alternative Method [#alternative-method]

As an alternative, you can export all work logs through JetTime's reports in the app UI. For details, refer to [Exporting Work Logs to CSV Using the App Interface](/help-center/fundamentals/jettime/reporting/exporting-report-work-logs-to-csv/).
