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
Jump to file
Failed to load files.
Loading
Diff view
Diff view
182 changes: 174 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,24 @@
[![Java CI](https://github.com/ListenNotes/podcast-api-java/actions/workflows/gradle.yml/badge.svg)](https://github.com/ListenNotes/podcast-api-java/actions/workflows/gradle.yml)
[![Maven Central](https://img.shields.io/maven-central/v/com.listennotes/podcast-api)](https://central.sonatype.com/artifact/com.listennotes/podcast-api)

The official Java client for the [Listen Notes Podcast API](https://www.listennotes.com/podcast-api/),
for JVM applications written in Java, Kotlin, Scala, Groovy, and other languages.
Search podcasts and episodes, fetch metadata, and manage playlists.
Questions? Contact [hello@listennotes.com](mailto:hello@listennotes.com).
Search podcasts and episodes, generate speaker-labeled transcripts on demand, and get podcast audience insights with the official Java SDK for the [Listen Notes Podcast API](https://www.listennotes.com/api/).

You can also discover podcasts in ChatGPT, Claude, or another compatible AI assistant without writing code. [Connect the official Podcast MCP](https://www.listennotes.com/api/mcp/).

## On-demand podcast transcription

Transcription methods are available in version 3.2.0. Use the [mock API](https://www.listennotes.help/article/48-how-to-test-the-podcast-api-without-an-api-key) to try the examples with fixed responses and no API key.

| Method | What it does |
| --- | --- |
| [`estimateEpisodeTranscription`](#estimateepisodetranscription) | Estimate cost and check your remaining transcription quota. |
| [`transcribeEpisode`](#transcribeepisode) | Queue a transcription for a podcast episode. |
| [`getEpisodeTranscript`](#getepisodetranscript) | Poll for job status and get fresh signed download URLs. |
| [`listTranscripts`](#listtranscripts) | List completed transcripts and paginate with `next_cursor`. |

**Can I get speaker-labeled podcast transcripts?** Yes. When multiple voices are detected, TXT, SRT, and VTT include speaker labels. Word-level JSON includes speaker IDs when available and timestamps in milliseconds. Signed links expire after 15 minutes. Poll again for fresh links.

**Can I request a live transcription?** Enable transcription and set up billing in your API dashboard, then use a server-side API key. Check the estimate first because live requests can incur transcription fees. [Transcription settings](https://www.listennotes.com/api/dashboard/#transcription) · [Pricing](https://www.listennotes.com/api/pricing/#on-demand-transcription)

## Installation

Expand All @@ -16,7 +30,7 @@ Version 3 requires **Java 17 or later**. It uses the JDK HTTP client and
Gradle, with Maven Central enabled:

```groovy
implementation 'com.listennotes:podcast-api:3.1.0'
implementation 'com.listennotes:podcast-api:3.2.0'
```

Maven:
Expand All @@ -25,11 +39,11 @@ Maven:
<dependency>
<groupId>com.listennotes</groupId>
<artifactId>podcast-api</artifactId>
<version>3.1.0</version>
<version>3.2.0</version>
</dependency>
```

These coordinates become installable when 3.1.0 is published to Maven Central.
These coordinates become installable when 3.2.0 is published to Maven Central.

## Usage

Expand Down Expand Up @@ -182,6 +196,10 @@ separate from creating the draft. Do not store credentials or signing keys in Gi
- [`addPlaylistItem`](#addplaylistitem) — `POST /playlists/{id}/items`
- [`deletePlaylistItem`](#deleteplaylistitem) — `DELETE /playlists/{id}/items/{item_id}`
- [`updatePlaylistItemNotes`](#updateplaylistitemnotes) — `PUT /playlists/{id}/items/{item_id}`
- [`estimateEpisodeTranscription`](#estimateepisodetranscription) — `GET /episodes/{id}/transcript/estimate`
- [`transcribeEpisode`](#transcribeepisode) — `POST /episodes/{id}/transcript`
- [`getEpisodeTranscript`](#getepisodetranscript) — `GET /episodes/{id}/transcript`
- [`listTranscripts`](#listtranscripts) — `GET /transcripts`

<!-- END GENERATED METHOD INDEX -->

Expand Down Expand Up @@ -472,7 +490,11 @@ Fetch detailed meta data for an episode by id

`GET /episodes/{id}`

Fetch detailed meta data for a specific episode.
Fetch detailed metadata for a specific episode.

Existing episode transcripts are already available on Listen Notes and include transcripts supplied by podcast producers. About 12% of new episodes and over 3% of all episodes have an existing transcript. Retrieve one with `show_transcript=1` on PRO and ENTERPRISE.

If an episode has no transcript, use `POST /episodes/{id}/transcript` to request on-demand transcription on any plan.

```java
import java.util.HashMap;
Expand Down Expand Up @@ -1091,6 +1113,150 @@ public class Example {

[Full API documentation](https://www.listennotes.com/api/docs/#put-api-v2-playlists-id-items-item_id)

### estimateEpisodeTranscription

Estimate episode transcription cost

`GET /episodes/{id}/transcript/estimate`

Get an informational estimate using episode duration metadata, your remaining quota, and your account's per-minute overage rate. This does not start transcription or reserve quota.

`transcription_quota_this_cycle` shows the included and remaining minutes. `billing_this_transcription.amount_cents` is the estimated fee for minutes beyond the remaining quota. It is 0 when the estimate fits within the quota.

The final fee uses the audio duration measured by the model, the quota available when transcription completes, and the per-minute rate saved when the request is accepted.

If duration metadata is unavailable, `estimate`, `billing_this_transcription.billable_minutes`, and `billing_this_transcription.amount_cents` are null. You can request an estimate before enabling Transcription or adding a payment method. Normal API request accounting applies.

```java
import java.util.HashMap;
import java.util.Map;
import com.listennotes.podcast_api.Client;
import com.listennotes.podcast_api.exception.ListenApiException;

public class Example {
public static void main(String[] args) throws ListenApiException {
Client client = new Client(System.getenv("LISTEN_API_KEY"));
Map<String, String> parameters = new HashMap<>();
parameters.put("id", "dc09fd798802477b8dba0ca1e10134fa");
System.out.println(client.estimateEpisodeTranscription(parameters).toJSON().toString(2));
}
}
```

[Full API documentation](https://www.listennotes.com/api/docs/#get-api-v2-episodes-id-transcript-estimate)

### transcribeEpisode

Request episode transcription

`POST /episodes/{id}/transcript`

Generate speaker-labeled transcripts for a podcast episode on demand. The request runs asynchronously. Ensure Transcription is enabled and a payment method is added in the [API dashboard](https://www.listennotes.com/api/dashboard/#transcription). Eligible paid accounts may use their existing invoicing arrangement.

**On-demand transcription can incur fees. This example uses the mock API. Configure a server-side API key only when you intend to request live transcription.**

See the [API pricing page](https://www.listennotes.com/api/pricing/#on-demand-transcription) for included minutes and rates. Use the estimate endpoint to check your account's quota and estimated charge.

Returns HTTP 202 for a queued or processing request, or HTTP 200 if a completed transcript already exists for this API account. Repeating a pending or completed request reuses it without another transcription charge. If transcription fails, you may request it again. Up to three pending requests are allowed per API account by default.

Both responses include `transcription_quota_this_cycle` and `billing_this_transcription`. HTTP 202 includes `estimate`, which is null when duration metadata is unavailable. HTTP 200 includes the measured duration and completion time. Use the polling endpoint for signed download URLs.

Poll GET /episodes/{id}/transcript, or [configure a webhook in the dashboard](https://www.listennotes.com/api/dashboard/#webhooks) to receive `episode_transcription.completed` or `episode_transcription.failed`. Webhooks are optional; there is no webhook URL parameter on this operation.

The processing deadline is 15 minutes when estimated audio length is under 60 minutes or unknown, otherwise 25% of estimated audio length. Failed and timed-out transcriptions are not charged a transcription fee.

The per-minute rate is saved when the request is accepted. When a transcription succeeds, we round the measured audio duration up to a whole minute. Only minutes beyond the included quota incur a transcription fee. Disabling Transcription blocks new requests. Accepted requests continue processing.

No request body is required. Normal API request accounting applies even when the transcription fee is zero.

```java
import java.util.HashMap;
import java.util.Map;
import com.listennotes.podcast_api.Client;
import com.listennotes.podcast_api.exception.ListenApiException;

public class Example {
public static void main(String[] args) throws ListenApiException {
Client client = new Client(null);
Map<String, String> parameters = new HashMap<>();
parameters.put("id", "1871d978bdc648588441bc5649857ddb");
System.out.println(client.transcribeEpisode(parameters).toJSON().toString(2));
}
}
```

[Full API documentation](https://www.listennotes.com/api/docs/#post-api-v2-episodes-id-transcript)

### getEpisodeTranscript

Get episode transcription status and downloads

`GET /episodes/{id}/transcript`

Poll the transcription requested by your API account for this episode. Returns HTTP 200 for queued, processing, completed, and failed states. Only your API account's requests are accessible.

Queued and processing responses include the same quota, billing, and estimate fields as HTTP 202 from POST, plus a `Retry-After` header of 30 seconds. Completed responses include actual duration, `billing_this_transcription`, `transcription_quota_this_cycle`, and all available TXT, SRT, VTT, and word-level JSON download URLs. Failed responses include `error.code`, such as `transcription_timeout`, and null billing minutes and amount.

Signed URLs in `download_urls` are valid for 15 minutes and share the UTC expiration time in `download_url_expired_date`. Anyone holding a valid URL can download the file without an API key. Poll again for fresh URLs.

Transcription uses speaker diarization to distinguish voices. When multiple speakers are detected, TXT, SRT, and VTT use speaker labels. A TXT download places the label before the spoken text.

```
Speaker A: Thanks for joining us.

Speaker B: Happy to be here.
```

Word-level JSON includes start and end timestamps in milliseconds and a `speaker` ID for each word, or `null` when a label is unavailable.

If multiple attempts exist, an existing completed transcript remains available until a replacement succeeds. Otherwise the latest request is returned. This operation does not initiate transcription.

```java
import java.util.HashMap;
import java.util.Map;
import com.listennotes.podcast_api.Client;
import com.listennotes.podcast_api.exception.ListenApiException;

public class Example {
public static void main(String[] args) throws ListenApiException {
Client client = new Client(System.getenv("LISTEN_API_KEY"));
Map<String, String> parameters = new HashMap<>();
parameters.put("id", "1871d978bdc648588441bc5649857ddb");
System.out.println(client.getEpisodeTranscript(parameters).toJSON().toString(2));
}
}
```

[Full API documentation](https://www.listennotes.com/api/docs/#get-api-v2-episodes-id-transcript)

### listTranscripts

List completed episode transcripts

`GET /transcripts`

List your API account's completed transcripts, newest completion first. Queued, processing, failed, and superseded attempts are excluded.

Follow `next_cursor` until it is null. Cursors are opaque and belong to this API account. Each item contains a `billing_this_transcription` summary. Fetch its `transcript_url` from the API server for quota details and fresh signed download URLs.

```java
import java.util.HashMap;
import java.util.Map;
import com.listennotes.podcast_api.Client;
import com.listennotes.podcast_api.exception.ListenApiException;

public class Example {
public static void main(String[] args) throws ListenApiException {
Client client = new Client(System.getenv("LISTEN_API_KEY"));
Map<String, String> parameters = new HashMap<>();
parameters.put("limit", "20");
System.out.println(client.listTranscripts(parameters).toJSON().toString(2));
}
}
```

[Full API documentation](https://www.listennotes.com/api/docs/#get-api-v2-transcripts)

<!-- END GENERATED API REFERENCE -->

## License
Expand Down
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
GROUP_ID=com.listennotes
VERSION_NAME=3.1.0
VERSION_NAME=3.2.0

POM_URL=https://github.com/ListenNotes/podcast-api-java
POM_SCM_URL=https://github.com/ListenNotes/podcast-api-java
Expand Down
40 changes: 40 additions & 0 deletions src/main/java/com/listennotes/podcast_api/ApiMethods.java
Original file line number Diff line number Diff line change
Expand Up @@ -334,4 +334,44 @@ public ApiResponse updatePlaylistItemNotes(Map<String, String> parameters) throw
new String[] {"id", "item_id"}, new String[] {}, parameters);
}

/** Estimate episode transcription cost
* @param parameters path, query, and form values
* @return API response, including response headers
* @throws ListenApiException on invalid input, connection failure, or a non-2xx response
*/
public ApiResponse estimateEpisodeTranscription(Map<String, String> parameters) throws ListenApiException {
return requestApi("GET", "/episodes/{id}/transcript/estimate",
new String[] {"id"}, new String[] {}, parameters);
}

/** Request episode transcription
* @param parameters path, query, and form values
* @return API response, including response headers
* @throws ListenApiException on invalid input, connection failure, or a non-2xx response
*/
public ApiResponse transcribeEpisode(Map<String, String> parameters) throws ListenApiException {
return requestApi("POST", "/episodes/{id}/transcript",
new String[] {"id"}, new String[] {}, parameters);
}

/** Get episode transcription status and downloads
* @param parameters path, query, and form values
* @return API response, including response headers
* @throws ListenApiException on invalid input, connection failure, or a non-2xx response
*/
public ApiResponse getEpisodeTranscript(Map<String, String> parameters) throws ListenApiException {
return requestApi("GET", "/episodes/{id}/transcript",
new String[] {"id"}, new String[] {}, parameters);
}

/** List completed episode transcripts
* @param parameters path, query, and form values
* @return API response, including response headers
* @throws ListenApiException on invalid input, connection failure, or a non-2xx response
*/
public ApiResponse listTranscripts(Map<String, String> parameters) throws ListenApiException {
return requestApi("GET", "/transcripts",
new String[] {}, new String[] {"limit", "cursor"}, parameters);
}

}
4 changes: 2 additions & 2 deletions src/test/java/com/listennotes/podcast_api/ClientTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
class ClientTest {
@TestFactory Stream<DynamicTest> everyGeneratedMethodMatchesContract() throws Exception {
var operations = TestSupport.operations();
assertEquals(31, operations.size());
assertEquals(35, operations.size());
return operations.stream().map(operation -> DynamicTest.dynamicTest(operation.getString("func"), () -> {
try (var server = new TestSupport()) {
Map<String, String> parameters = new HashMap<>();
Expand Down Expand Up @@ -289,7 +289,7 @@ void legacyConnectionAndResponseConstructorsRemainUsable() throws Exception {
Files.writeString(file, matcher.group(1).replace("public class Example", "public class " + name));
arguments.add(file.toString());
}
assertEquals(32, count);
assertEquals(36, count);
assertEquals(0, ToolProvider.getSystemJavaCompiler().run(null, null, null, arguments.toArray(String[]::new)));
}
}
16 changes: 13 additions & 3 deletions src/test/java/com/listennotes/podcast_api/MockIntegrationTest.java
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
package com.listennotes.podcast_api;

import java.util.List;
import java.util.Map;
import java.util.stream.Stream;
import org.junit.jupiter.api.*;
Expand All @@ -13,9 +12,20 @@ class MockIntegrationTest {
@TestFactory Stream<DynamicTest> allMethodsAgainstPublicMock() throws Exception {
return TestSupport.operations().stream().map(operation -> DynamicTest.dynamicTest(operation.getString("func"), () -> {
ApiResponse response = TestSupport.call(client, operation, TestSupport.examples(operation));
assertTrue(List.of(200, 201).contains(response.getStatusCode()));
String name = operation.getString("operationId");
int status = switch (name) {
case "createPlaylist", "addPlaylistItem" -> 201;
case "transcribeEpisode" -> 202;
default -> 200;
};
assertEquals(status, response.getStatusCode());
assertFalse(response.toJSON().isEmpty());
if (operation.getString("operationId").equals("deletePlaylist")) {
if (name.equals("transcribeEpisode")) {
assertEquals("queued", response.toJSON().getString("status"));
} else if (name.equals("getEpisodeTranscript")) {
assertEquals("completed", response.toJSON().getString("status"));
assertFalse(response.toJSON().getJSONObject("download_urls").isEmpty());
} else if (name.equals("deletePlaylist")) {
assertEquals(200, response.getStatusCode());
assertTrue(response.toJSON().getBoolean("deleted"));
assertEquals(operation.getJSONObject("example_params").getString("id"), response.toJSON().getString("id"));
Expand Down
Loading