| Crates.io | tmdb-sans-io |
| lib.rs | tmdb-sans-io |
| version | 0.1.2 |
| created_at | 2025-05-05 02:05:23.189548+00 |
| updated_at | 2025-05-26 21:59:16.125566+00 |
| description | The Movie Database (TMDb) API for Rust, sans io |
| homepage | https://github.com/danjl1100/tmdb-sans-io |
| repository | https://github.com/danjl1100/tmdb-sans-io |
| max_upload_size | |
| id | 1660064 |
| size | 52,598 |

This is a fork of tmdb (Cir0X/tmdb-rs), following the sans-io approach to let you build a custom wrapper around TMDb API.
Bring your own I/O stack!
Why yet another TMDb API library written in Rust?
For a throw-away hobby project, I needed to access TMDb API:
cargo audit, it seems one dependency of the chosen library (the latest reqwest version 0.9.24 per the semver range, from 2019-12-11) has security advisories.The situation is understandable: an older but still working API access library (last updated in 2021) that uses an older version of HTTP client library is bound to have a few security vulnerabilities reported deep in their dependency tree.
Security advisories (in this case, DDOS vulnerabilities) may not be critical for a hobby project but are still not ideal.
Instead of manually patching the API access library to use an updated HTTP client library, why not decouple the API models from the HTTP client?
Credit goes to the original authors for the data models, and API design. Building upon that, the finish method is crudely bolted on, returning an HttpGet struct containing the URL to be queried and a receive_response method to parse the JSON response.
See examples/basic for sample usage.
See the integration tests for more examples.
NOTE: All code examples are not rigorously checked, for reference only.
Currently there are 3 actions available:
You can search for movies by title and year.
let page_request = tmdb.search()
.title("Bicentennial Man")
.year(1999)
.finish();
let response = {
let request_url = page_request.request_url();
unimplemented!("INSERT YOUR HTTP CLIENT LIBRARY HERE");
};
let page = page_request.receive_response(response)?;
let movies = page.results;
You can fetch a movie, when you know its ID. Then you get all the movie details.
let movie_request = tmdb.fetch()
.id(157336)
.finish();
let response = {
let request_url = movie_request.request_url();
unimplemented!("INSERT YOUR HTTP CLIENT LIBRARY HERE");
};
let movie = movie_request.receive_response(response)?;
When you don't have any movie ID, you can search for a movie and then easily fetch the full details.
let page_request = tmdb.search()
.title("Bicentennial Man")
.year(1999)
.finish();
let response = {
let request_url = page_request.request_url();
unimplemented!("INSERT YOUR HTTP CLIENT LIBRARY HERE");
};
let page = page_request.receive_response(response)?;
let movies = page.results;
let movie_request = movies[0].fetch(&tmdb);
let response = {
let request_url = movie_request.request_url();
unimplemented!("INSERT YOUR HTTP CLIENT LIBRARY HERE");
};
let movie = movie_request.receive_response(response)?;
Furthermore you can request some more data with the append to response feature.
let movie_request = tmdb.fetch()
.id(2277)
.append_videos()
.append_credits()
.finish();
Finding a movie with an external ID is currently supported with IMDB IDs.
let find_result = tmdb.find()
.imdb_id("tt0816692")
.finish();
let response = {
let request_url = find_request.request_url();
unimplemented!("INSERT YOUR HTTP CLIENT LIBRARY HERE");
};
let find_result = find_request.receive_response(response);
let movies = find_result.movie_results;