{"id":25006612,"url":"https://github.com/croct-tech/export-client-java","last_synced_at":"2025-10-30T00:23:57.483Z","repository":{"id":43330842,"uuid":"351919632","full_name":"croct-tech/export-client-java","owner":"croct-tech","description":"Java client for the Croct Export API.","archived":false,"fork":false,"pushed_at":"2024-11-21T12:23:01.000Z","size":252,"stargazers_count":12,"open_issues_count":2,"forks_count":1,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-04-11T20:48:30.795Z","etag":null,"topics":["api","client","croct","java"],"latest_commit_sha":null,"homepage":"","language":"Java","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/croct-tech.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":".github/CODEOWNERS","security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2021-03-26T21:46:22.000Z","updated_at":"2022-12-14T16:04:16.000Z","dependencies_parsed_at":"2025-02-05T02:01:27.285Z","dependency_job_id":null,"html_url":"https://github.com/croct-tech/export-client-java","commit_stats":null,"previous_names":[],"tags_count":2,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/croct-tech%2Fexport-client-java","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/croct-tech%2Fexport-client-java/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/croct-tech%2Fexport-client-java/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/croct-tech%2Fexport-client-java/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/croct-tech","download_url":"https://codeload.github.com/croct-tech/export-client-java/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248591989,"owners_count":21130161,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["api","client","croct","java"],"created_at":"2025-02-05T01:50:22.924Z","updated_at":"2025-10-30T00:23:57.476Z","avatar_url":"https://github.com/croct-tech.png","language":"Java","funding_links":[],"categories":[],"sub_categories":[],"readme":"\u003cp align=\"center\"\u003e\n    \u003ca href=\"https://croct.com\"\u003e\n        \u003cimg src=\"https://cdn.croct.io/brand/logo/repo-icon-green.svg\" alt=\"Croct\" height=\"80\"/\u003e\n    \u003c/a\u003e\n    \u003cbr /\u003e\n    \u003cstrong\u003eExport API Java Client\u003c/strong\u003e\n    \u003cbr /\u003e\n    Java client for the Croct Export API.\n\u003c/p\u003e\n\n\u003cp align=\"center\"\u003e\n    \u003ca href=\"https://search.maven.org/artifact/com.croct.client/croct-export-client\"\u003e\u003cimg alt=\"Version\" src=\"https://img.shields.io/maven-central/v/com.croct.client/croct-export-client\"/\u003e\u003c/a\u003e\n    \u003ca href=\"https://github.com/croct-tech/export-client-java/actions/workflows/branch-validations.yaml\"\u003e\u003cimg alt=\"Validations\" src=\"https://github.com/croct-tech/export-client-java/actions/workflows/branch-validations.yaml/badge.svg\"/\u003e\u003c/a\u003e\n    \u003cbr /\u003e\n    \u003cbr /\u003e\n    \u003ca href=\"https://github.com/croct-tech/exporter-client-java/releases\"\u003e📦 Releases\u003c/a\u003e\n    ·\n    \u003ca href=\"https://github.com/croct-tech/exporter-client-java/issues\"\u003e🐞 Report Bug\u003c/a\u003e\n    ·\n    \u003ca href=\"https://github.com/croct-tech/exporter-client-java/issues\"\u003e✨ Request Feature\u003c/a\u003e\n\u003c/p\u003e\n\n## Introduction\n\nThe Export API Client for Java is a high-level HTTP client for exporting events, sessions, and users from a Croct workspace.\n\n## Getting Started\n\nThe following steps will walk you through installing the client and integrating it into your application.\n\n### Installation\n\nTo install the API client library to your local Maven repository, simply execute:\n\n```shell\nmvn clean install\n```\n\n#### Maven users\n\nAdd this dependency to your project's POM:\n\n```xml\n\u003cdependency\u003e\n  \u003cgroupId\u003ecom.croct.client\u003c/groupId\u003e\n  \u003cartifactId\u003ecroct-export-client\u003c/artifactId\u003e\n  \u003cversion\u003e0.3.1\u003c/version\u003e\n  \u003cscope\u003ecompile\u003c/scope\u003e\n\u003c/dependency\u003e\n```\n\n#### Gradle users\n\nAdd this dependency to your project's build file:\n\n```groovy\nrepositories {\n    mavenCentral()\n}\n\ndependencies {\n    compile \"com.croct.client:croct-export-client:0.3.1\"\n}\n```\n\n### Usage\n\nNow the library is installed, you need to initialize the client using the API key of the application you want to \nexport data:\n\n```java\nfinal ApiClient client = new ApiClient();\nclient.setApiKey(\"00000000-0000-0000-0000-000000000000\");\n\nfinal ExportApi api = new ExportApi(client);\n```\n\nFrom this point, you are all set to export data using one of the [export methods](#api-reference). However, developers \nare usually interested in implementing a routine to export data periodically. If that is the case, there are two \napproaches you can take to fetch data incrementally, as you will find out in the following sections.\n\n#### Incremental export\n\nThe following sections present different approaches for exporting data incrementally so you can choose the one that \nbest suits your needs.\n\n###### Stateful approach \n\nEvery request to the Export API returns a cursor that you can use in subsequent requests to fetch the next \nbatch of data. You can keep making calls until no data is left to export – at that point, you can store the cursor and \nresume the export later.\n\nThe following example illustrates how you can fetch data incrementally using cursors:\n\n```java\npackage com.croct;\n\nimport com.croct.client.export.ApiClient;\nimport com.croct.client.export.ApiException;\nimport com.croct.client.export.api.ExportApi;\nimport com.croct.client.export.model.Event;\nimport com.croct.client.export.model.EventResponse;\nimport java.util.List;\n\npublic class Example {\n    public static void main(String[] args) throws ApiException {\n        final ApiClient client = new ApiClient();\n        client.setApiKey(\"00000000-0000-0000-0000-000000000000\");\n\n        final ExportApi api = new ExportApi(client);\n\n        String cursor = loadCursor();\n\n        // The maximum number of events per request\n        final int pageSize = 100;\n\n        // The maximum number of events to export\n        int limit = 1000;\n\n        while (limit \u003e= pageSize) {\n            final EventResponse response = api.exportEvents(null, null, pageSize, cursor, null);\n            final List\u003cEvent\u003e events = response.getItems();\n\n            System.out.println(events);\n\n            cursor = response.getNextCursor();\n            limit = events.isEmpty() ? 0 : limit - events.size();\n        }\n\n        saveCursor(cursor);\n    }\n\n    private static String loadCursor() {\n        // Read the previous cursor from a database, file, or somewhere else\n    }\n\n    private static void saveCursor(final String cursor) {\n        // Write the current cursor to a database, file, or somewhere else\n    }\n}\n```\n\nBy reusing the previous cursor on subsequent requests, you guarantee that no data is missed between exports. However, \nit requires some extra work to store the cursor between exports so that the next export can start from where the \nprevious one left off.\n\n###### Stateless approach\n\nIf storing cursors is not an option, you can alternatively fetch data based on a time interval. For example, you can \nset up a job to daily export data from the previous day:\n\n```java\npackage com.croct;\n\nimport com.croct.client.export.ApiClient;\nimport com.croct.client.export.ApiException;\nimport com.croct.client.export.api.ExportApi;\nimport com.croct.client.export.model.Event;\nimport com.croct.client.export.model.EventResponse;\nimport java.time.LocalDate;\nimport java.time.ZoneOffset;\nimport java.util.List;\n\npublic class Example {\n    public static void main(String[] args) throws ApiException {\n        final ApiClient client = new ApiClient();\n        client.setApiKey(\"00000000-0000-0000-0000-000000000000\");\n\n        final ExportApi api = new ExportApi(client);\n\n        final LocalDate today = LocalDate.now(ZoneOffset.UTC);\n        final LocalDate yesterday = today.minusDays(1);\n        final long start = today.atStartOfDay().toEpochSecond(ZoneOffset.UTC);\n        final long end = yesterday.atStartOfDay().toEpochSecond(ZoneOffset.UTC);\n\n        String cursor = null;\n        boolean running = true;\n\n        while (running) {\n            final EventResponse response = api.exportEvents(start, end, 100, cursor, null);\n            final List\u003cEvent\u003e events = response.getItems();\n\n            System.out.println(events);\n\n            cursor = response.getNextCursor();\n            running = !events.isEmpty();\n        }\n    }\n}\n```\n\nThe disadvantage of this approach is that there are no guarantees that the data relative to the specified time window \nhave been processed by the time you make the subsequent request. Such cases can happen when events arrive late, \nrecent data was not processed fast enough, or during maintenance windows.\n\n#### Exporting Events\n\nThe `exportEvents` method exports events from the application associated with the API key, optionally filtered by type \nand a time window relative to the event timestamp.\n\nThe following example demonstrates how to export events of a particular type in batches of 100:\n\n```java\npackage com.croct;\n\nimport com.croct.client.export.ApiClient;\nimport com.croct.client.export.ApiException;\nimport com.croct.client.export.api.ExportApi;\nimport com.croct.client.export.model.Event;\nimport com.croct.client.export.model.EventResponse;\nimport java.util.List;\n\npublic class Example {\n    public static void main(String[] args) throws ApiException {\n        final ApiClient client = new ApiClient();\n        client.setApiKey(\"00000000-0000-0000-0000-000000000000\");\n\n        final ExportApi api = new ExportApi(client);\n\n        String cursor = null;\n        boolean running = true;\n\n        while (running) {\n            final EventResponse response = api.exportEvents(null, null, 100, cursor, null);\n            final List\u003cEvent\u003e events = response.getItems();\n\n            System.out.println(events);\n\n            cursor = response.getNextCursor();\n            running = !events.isEmpty();\n        }\n    }\n}\n```\n\n#### Exporting Sessions\n\nThe `exportSessions` method exports sessions from the application associated with the API key, optionally filtered by \na time window relative to the session's close time.\n\nThe following example demonstrates how to export sessions in batches of 100: \n\n```java\npackage com.croct;\n\nimport com.croct.client.export.ApiClient;\nimport com.croct.client.export.ApiException;\nimport com.croct.client.export.api.ExportApi;\nimport com.croct.client.export.model.Session;\nimport com.croct.client.export.model.SessionResponse;\nimport java.util.List;\n\npublic class Example {\n    public static void main(String[] args) throws ApiException {\n        final ApiClient client = new ApiClient();\n        client.setApiKey(\"00000000-0000-0000-0000-000000000000\");\n\n        final ExportApi api = new ExportApi(client);\n\n        String cursor = null;\n        boolean running = true;\n\n        while (running) {\n            final SessionResponse response = api.exportSessions(null, null, 100, cursor);\n            final List\u003cSession\u003e sessions = response.getItems();\n\n            System.out.println(sessions);\n\n            cursor = response.getNextCursor();\n            running = !sessions.isEmpty();\n        }\n    }\n}\n```\n\n#### Exporting Users\n\nThe `exportUsers` method exports users from the workspace associated with the API key, optionally filtered by \na time window relative to the user's last modified time.\n\nThe following example demonstrates how to export sessions in batches of 100:\n\n```java\npackage com.croct;\n\nimport com.croct.client.export.ApiClient;\nimport com.croct.client.export.ApiException;\nimport com.croct.client.export.api.ExportApi;\nimport com.croct.client.export.model.User;\nimport com.croct.client.export.model.UserResponse;\nimport java.util.List;\n\npublic class Example {\n    public static void main(String[] args) throws ApiException {\n        final ApiClient client = new ApiClient();\n        client.setApiKey(\"00000000-0000-0000-0000-000000000000\");\n\n        final ExportApi api = new ExportApi(client);\n\n        String cursor = null;\n        boolean running = true;\n\n        while (running) {\n            final UserResponse response = api.exportUsers(null, null, 100, cursor);\n            final List\u003cUser\u003e users = response.getItems();\n\n            System.out.println(users);\n            \n            cursor = response.getNextCursor();\n            running = !users.isEmpty();\n        }\n    }\n}\n```\n\n## API Reference\n\nThis reference documents all the methods available in the Export API.\n\n### constructor\n\nThe constructor initializes the Export API client with the API key to use for requests.\n\n#### Signature\n\nThe constructor has the following signature:\n\n```java\n// ExportApi(Configuration.getDefaultApiClient())\npublic ExportApi();\n\npublic ExportApi(ApiClient apiClient);\n```\n\n#### Code Sample\n\nHere's a minimal example showing how initialize the client:\n\n```java\nfinal ApiClient client = new ApiClient();\nclient.setApiKey(\"00000000-0000-0000-0000-000000000000\");\n\nfinal ExportApi api = new ExportApi(client);\n```\n\n### exportEvents\n\nThis method exports events from an application.\n\n#### Signature\n\nThe `exportEvents` method has the following signature:\n\n```java\npublic EventResponse exportEvents(Long start, Long end, Integer pageSize, String cursor, List\u003cEventType\u003e events) throws ApiException;\n```\n\nThese are the currently supported options:\n\n| Option     | Type        | Description\n|------------|-------------|-----------------------------------------------------------------------------------------------------------------------------------------------\n| `pageSize` | int32       | The maximum number of events to export per request, limited to 1000. By default, 100.\n| `cursor`   | string      | The cursor from the previous request to use as a starting point for export. By default, it points to the initial page.\n| `start`    | int64       | The start timestamp in seconds since epoch relative to the event timestamp, inclusive. By default, the start of the time window is unbounded.\n| `end`      | int64       | The end timestamp in seconds since epoch relative to the event timestamp, exclusive. By default, the end of the time window is unbounded.\n| `events`   | EventType[] | The types of events to export. By default, include all types listed bellow.\n\nThe list possible event types are:\n\n| Event                  | Since Version |\n|------------------------|---------------|\n| `userSignedUp`         | 1.0.0         |\n| `userSignedIn`         | 1.0.0         |\n| `userSignedOut`        | 1.0.0         |\n| `tabOpened`            | 1.0.0         |\n| `tabUrlChanged`        | 1.0.0         |\n| `tabVisibilityChanged` | 1.0.0         |\n| `locationDetected`     | 1.0.0         |\n| `clientDetected`       | 1.0.0         |\n| `pageOpened`           | 1.0.0         |\n| `pageLoaded`           | 1.0.0         |\n| `productAbandoned`     | 1.0.0         |\n| `productViewed`        | 1.0.0         |\n| `cartAbandoned`        | 1.0.0         |\n| `cartViewed`           | 1.0.0         |\n| `cartModified`         | 1.0.0         |\n| `checkoutStarted`      | 1.0.0         |\n| `orderPlaced`          | 1.0.0         |\n| `nothingChanged`       | 1.0.0         |\n| `goalCompleted`        | 1.0.0         |\n| `eventOccurred`        | 1.0.0         |\n| `slotPersonalized`     | 1.1.0         |\n\n#### Code Sample\n\nHere's a full example showing how to export events:\n\n```java\npackage com.croct;\n\nimport com.croct.client.export.ApiClient;\nimport com.croct.client.export.ApiException;\nimport com.croct.client.export.api.ExportApi;\nimport com.croct.client.export.model.Event;\nimport com.croct.client.export.model.EventResponse;\nimport com.croct.client.export.model.EventType;\nimport java.util.List;\n\npublic class Example {\n    public static void main(String[] args) throws ApiException {\n        final ApiClient client = new ApiClient();\n        client.setApiKey(\"00000000-0000-0000-0000-000000000000\");\n\n        final ExportApi api = new ExportApi(client);\n\n        String cursor = null;\n        boolean running = true;\n\n        while (running) {\n            final EventResponse response = api.exportEvents(\n                1440990000L,\n                1440990000L + 86_400,\n                100,\n                cursor,\n                List.of(\n                    EventType.PRODUCT_VIEWED,\n                    EventType.CHECKOUT_STARTED,\n                    EventType.ORDER_PLACED\n                )\n            );\n\n            final List\u003cEvent\u003e events = response.getItems();\n\n            System.out.println(events);\n\n            cursor = response.getNextCursor();\n            running = !events.isEmpty();\n        }\n    }\n}\n```\n\n### exportSessions\n\nThis method exports sessions from an application.\n\n#### Signature\n\nThe `exportSessions` method has the following signature:\n\n```java\npublic SessionResponse exportSessions(Long start, Long end, Integer pageSize, String cursor) throws ApiException;\n```\n\nThese are the currently supported options:\n\n| Option     | Type     | Description\n|------------|----------|---------------------------------------------------------------------------------------------------------------------------------------------------\n| `pageSize` | int32   | The maximum number of sessions to export per request, limited to 1000. By default, 100.\n| `cursor`   | string   | The cursor from the previous request to use as a starting point for export. By default, it points to the initial page.\n| `start`    | int64   | The start timestamp in seconds since epoch relative to the session's close time, inclusive. By default, the start of the time window is unbounded.\n| `end`      | int64   | The end timestamp in seconds since epoch relative to the session's close time, exclusive. By default, the end of the time window is unbounded.\n\n#### Code Sample\n\nHere's a full example showing how to export sessions:\n\n```java\npackage com.croct;\n\nimport com.croct.client.export.ApiClient;\nimport com.croct.client.export.ApiException;\nimport com.croct.client.export.api.ExportApi;\nimport com.croct.client.export.model.Session;\nimport com.croct.client.export.model.SessionResponse;\nimport java.util.List;\n\npublic class Example {\n    public static void main(String[] args) throws ApiException {\n        final ApiClient client = new ApiClient();\n        client.setApiKey(\"00000000-0000-0000-0000-000000000000\");\n\n        final ExportApi api = new ExportApi(client);\n\n        String cursor = null;\n        boolean running = true;\n\n        while (running) {\n            final SessionResponse response = api.exportSessions(\n                1440990000L,\n                1440990000L + 86_400,\n                100,\n                cursor\n            );\n\n            final List\u003cSession\u003e sessions = response.getItems();\n\n            System.out.println(sessions);\n\n            cursor = response.getNextCursor();\n            running = !sessions.isEmpty();\n        }\n    }\n}\n```\n\n### exportUsers\n\nThis method exports users from a workspace.\n\n#### Signature\n\nThe `exportUsers` method has the following signature:\n\n```java\npublic UserResponse exportUsers(Long start, Long end, Integer pageSize, String cursor) throws ApiException;\n```\n\nThese are the currently supported options:\n\n| Option     | Type    | Description\n|------------|---------|--------------------------------------------------------------------------------------------------------------------------------------------------------\n| `pageSize` | int32   | The maximum number of users to export per request, limited to 1000. By default, 100.\n| `cursor`   | string  | The cursor from the previous request to use as a starting point for export. By default, it points to the initial page.\n| `start`    | int64   | The start timestamp in seconds since epoch relative to the user's last modified time, inclusive. By default, the start of the time window is unbounded.\n| `end`      | int64   | The end timestamp in seconds since epoch relative to the user's last modified time, exclusive. By default, the end of the time window is unbounded.\n\n#### Code Sample\n\nHere's a full example showing how to export sessions:\n\n```java\npackage com.croct;\n\nimport com.croct.client.export.ApiClient;\nimport com.croct.client.export.ApiException;\nimport com.croct.client.export.api.ExportApi;\nimport com.croct.client.export.model.User;\nimport com.croct.client.export.model.UserResponse;\nimport java.util.List;\n\npublic class Example {\n    public static void main(String[] args) throws ApiException {\n        final ApiClient client = new ApiClient();\n        client.setApiKey(\"00000000-0000-0000-0000-000000000000\");\n\n        final ExportApi api = new ExportApi(client);\n\n        String cursor = null;\n        boolean running = true;\n\n        while (running) {\n            final UserResponse response = api.exportUsers(\n                1440990000L,\n                1440990000L + 86_400,\n                100,\n                cursor\n            );\n\n            final List\u003cUser\u003e users = response.getItems();\n\n            System.out.println(users);\n\n            cursor = response.getNextCursor();\n            running = !users.isEmpty();\n        }\n    }\n}\n```\n\n## Support\n\nIf this documentation has not answered all your questions, don't worry. \nHere are some alternative ways to get help from the Croct community.\n\n### Stack Overflow\n\nSomeone else from the community may have already asked a similar question or may be able to help with your problem.\n\nThe Croct team will also monitor posts with the \"croct\" tag. If there aren't any existing questions that help,\nplease [ask a new one](https://stackoverflow.com/questions/ask?tags=croct%20export).\n\n### GitHub\n\nIf you have what looks like a bug, or you would like to make a feature request, please\n[open a new issue on GitHub](https://github.com/croct-tech/export-client-java/issues/new/choose).\n\nBefore you file an issue, a good practice is to search for issues to see whether others have the same or similar problems.\nIf you are unable to find an open issue addressing the problem, then feel free to open a new one.\n\n### Slack Channel\n\nMany people from the Croct community hang out on the Croct Slack Group.\nFeel free to [join us and start a conversation](https://croct.link/community).\n\n## License\n\nThis project is released under the [MIT License](LICENSE).\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcroct-tech%2Fexport-client-java","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fcroct-tech%2Fexport-client-java","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcroct-tech%2Fexport-client-java/lists"}