tvmaze.com
A client to access the TVMaze API
Maven Project Info
-
Javadoc
Report Bug
-
Request Feature
Table of Contents
An easy-to-use java client to access the TVMaze API for programmatic access to TV show, episode and cast/crew information.
Include this package as a dependency in your project. Note: This package is published to both GitHub and Maven Central repositories.
<dependency>
<groupId>com.amilesend</groupId>
<artifactId>tvmaze-java-client</artifactId>
<version>2.2.2</version>
</dependency>Default:
TvMaze client = new TvMaze();
SearchApi searchApi = client.getSearchApi();
List<ShowResult> results = searchApi.searchShows("friends");With a RetryStrategy:
TvMaze client = new TvMaze(new DefaultConnectionBuilder()
.httpClient(new OkHttpClient())
.baseUrl(TvMaze.API_URL)
.userAgent(TvMaze.USER_AGENT)
.authManager(new NoOpAuthManager())
.gsonFactory(new GsonFactory())
.isGzipContentEncodingEnabled(true)
// Options are ExponentialDelayRetryStrategy, FixedDelayRetryStrategy
// or NoRetryStrategy (default).
.retryStrategy(ExponentialDelayRetryStrategy.builder()
.baseDelayMs(500L)
.maxJitterMs(100L)
.maxAttempts(3)
.maxTotalDelayMs(2000L)
.build())
.build());OkHttpClientBuilder example
If your use-case requires configuring the underlying OkHttpClient instance (e.g., configuring your own
SSL cert verification, proxy, and/or connection timeouts), you can configure the client with the provided
OkHttpClientBuilder,
or alternatively with OkHttp's builder.
OkHttpClient httpClient = OkHttpClientBuilder.builder()
.trustManager(myX509TrustManager) // Custom trust manager for self/internally signed SSL/TLS certs
.hostnameVerifier(myHostnameVerifier) // Custom hostname verification for SSL/TLS endpoints
.addInterceptor(myInterceptor) // Custom okhttp interceptor (e.g., logging)
.proxy(myProxy, myProxyUsername, myProxyPassword) // Proxy config
.connectTimeout(8000L) // connection timeout in milliseconds
.readTimeout(5000L) // read timeout in milliseconds
.writeTimeout(5000L) // write timeout in milliseconds
.build();
Connection connection = Connection.builder()
.httpClient(httpClient)
.gsonFactory(GsonFactory.getInstance())
.build();
TvMaze client = new TvMaze(connection);If you have a suggestion that would make this better, please fork the repo and create a pull request. You can also open an issue with the tag "enhancement". Don't forget to give the project a star! Thanks again!
- Fork the Project
- Create your Feature Branch (
git checkout -b feature/AmazingFeature) - Commit your Changes (
git commit -m 'Add some AmazingFeature') - Push to the Branch (
git push origin feature/AmazingFeature) - Open a Pull Request
Distributed under the GPLv3 license. See LICENSE for more information.
Andy Miles - andy.miles (at) amilesend.com
Project Link: https://github.com/andy-miles/tvmaze-java-client