Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
46 changes: 25 additions & 21 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ The official Java SDK for the Textkernel Tx v10 API for resume/CV and job parsin
### Gradle Users
Add this dependency to your project's build file:
```
implementation "com.textkernel:tx-java:2.3.4"
implementation "com.textkernel:tx-java:3.0.0"
```

### Maven Users
Expand All @@ -22,13 +22,13 @@ Add this dependency to your project's POM:
<dependency>
<groupId>com.textkernel</groupId>
<artifactId>tx-java</artifactId>
<version>2.3.4</version>
<version>3.0.0</version>
</dependency>
```

### Others
You'll need to manually install the following JARs:
- The Textkernel Tx JAR from https://repo1.maven.org/maven2/com/textkernel/tx-java/2.3.4/tx-java-2.3.4.jar
- The Textkernel Tx JAR from https://repo1.maven.org/maven2/com/textkernel/tx-java/3.0.0/tx-java-3.0.0.jar
- [Google Gson][gson_url] from https://repo1.maven.org/maven2/com/google/code/gson/gson/2.9.0/gson-2.9.0.jar
- [Square OkHttp][okhttp_url] from https://repo1.maven.org/maven2/com/squareup/okhttp3/okhttp/4.12.0/okhttp-4.12.0.jar

Expand All @@ -46,32 +46,36 @@ For full code examples, see [here][examples].
### Creating a `TxClient`
This is the object that you will use to perform API calls. You create it with your account credentials and the `TxClient` makes the raw API calls for you. These credentials can be found in the [Tx Console][portal]. Be sure to select the correct `DataCenter` for your account.
```java
TxClient client = new TxClient("12345678", "abcdefghijklmnopqrstuvwxyz", DataCenter.US);
TxClientSettings settings = new TxClientSettings();
settings.AccountId = "12345678";
settings.ServiceKey = "abcdefghijklmnopqrstuvwxyz";
settings.DataCenter = DataCenter.US;
TxClient client = new TxClient(settings);
```

For self-hosted customers, you can create a `DataCenter` object with your custom URL using the constructor provided on that class.

### Handling errors and the `TxException`
Every call to any of the methods in the `TxClient` should be wrapped in a `try/catch` block. Any 4xx/5xx level errors will cause a `TxException` to be thrown. Sometimes these are a normal and expected part of the Tx API. For example, if you have a website where users upload resumes, sometimes a user will upload a scanned image as their resume. Textkernel does not process these, and will return a `422 Unprocessable Entity` response which will throw a `TxException`. You should handle any `TxException` in a way that makes sense in your application.
### Using the various `TxClient` services
The `TxClient` has the following services available:
- `parser()`
- `geocoder()`
- `formatter()`
- `skillsIntelligence()`
- `searchMatchV1()`
- `searchMatchV2()`

Additionally, there are `TxUsableResumeException` and `TxUsableJobException` which are thrown when some error/issue occurs in the API, but the response still contains a usable resume/job. For example, if you are geocoding while parsing and there is a geocoding error (which happens after parsing is done), the `ParsedResume` might still be usable in your application.
Each service exposes certain API functionality via its methods. For example, to parse a resume you would do something like:
```java
TxClient client;//created or injected however
ParseResumeResponse parseResponse = client.parser().parseResume(...);
```

### How to create a Matching UI session
You may be wondering, "where are the Matching UI endpoints/methods?". We have made the difference between a normal API call (such as `Search`) and its equivalent Matching UI call extremely trivial. See the following example:
For the complete list of methods on each service and their method signatures, check out our [online Javadoc][javadoc_url].

```java
TxClient client = new TxClient("12345678", "abcdefghijklmnopqrstuvwxyz", DataCenter.US);
List<String> indexesToSearch = ...;
FilterCriteria searchQuery = ...;
### Handling errors and the `TxException`
Every call to any of the methods in the `TxClient` should be wrapped in a `try/catch` block. Any 4xx/5xx level errors will cause a `TxException` to be thrown. Sometimes these are a normal and expected part of the Tx API. For example, if you have a website where users upload resumes, sometimes a user will upload a scanned image as their resume. Textkernel does not process these, and will return a `422 Unprocessable Entity` response which will throw a `TxException`. You should handle any `TxException` in a way that makes sense in your application.

SearchResponse searchResponse = client.search(indexesToSearch, searchQuery, null, null);
```
To generate a Matching UI session with the above Search query, you simply need to call the `ui(...)` method on the `TxClient` object, pass in any UI settings, and then make the same call as above:
```java
MatchUISettings uiSettings = ...;
GenerateUIResponse uiResponse = client.ui(uiSettings).search(indexesToSearch, searchQuery, null, null);
```
For every relevant method in the `TxClient`, you can create a Matching UI session for that query by doing the same as above.
Additionally, there are `TxUsableResumeException` and `TxUsableJobException` which are thrown when some error/issue occurs in the API, but the response still contains a usable resume/job. For example, if you are geocoding while parsing and there is a geocoding error (which happens after parsing is done), the `ParsedResume` might still be usable in your application.

[javadoc_url]: https://textkernel.github.io/tx-java/
[gson_url]: https://github.com/google/gson
Expand Down
Loading