Skip to content

Commit 253d24b

Browse files
committed
Update README.md
1 parent 644fc77 commit 253d24b

File tree

4 files changed

+106
-17
lines changed

4 files changed

+106
-17
lines changed

Cargo.toml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
[package]
22
name = "podcast-api"
3-
version = "0.1.0"
4-
authors = ["Cameron Fyfe <cameron.j.fyfe@gmail.com>"]
3+
version = "1.0.1"
4+
authors = ["Listen Notes, Inc. <hello@listennotes.com>"]
55
edition = "2018"
66
description = "Rust bindings for the Listen Notes Podcast API"
77
license = "MIT"
8-
keywords = ["listennotes", "podcast"]
9-
documentation = "https://docs.rs/podcast-api"
8+
keywords = ["listennotes", "podcast", "searchengine", "podcastsearch"]
9+
documentation = "https://www.listennotes.com/api/docs/"
1010
repository = "https://github.com/ListenNotes/podcast-api-rust"
1111
readme = "README.md"
1212

README.md

Lines changed: 100 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,111 @@
1-
# podcast-api-rust
2-
Rust library for the Listen Notes Podcast API
1+
# Podcast API Rust Library
32

4-
## Check
3+
The Podcast API Rust library provides convenient access to the [Listen Notes Podcast API](https://www.listennotes.com/api/) from
4+
applications written in the Rust language.
5+
6+
Simple and no-nonsense podcast search & directory API. Search the meta data of all podcasts and episodes by people, places, or topics. It's the same API that powers [the best podcast search engine Listen Notes](https://www.listennotes.com/).
7+
8+
If you have any questions, please contact [[email protected]]([email protected]?subject=Questions+about+the+Rust+SDK+of+Listen+API)
9+
10+
<a href="https://www.listennotes.com/api/"><img src="https://raw.githubusercontent.com/ListenNotes/ListenApiDemo/master/web/src/powered_by_listennotes.png" width="300" /></a>
11+
12+
## Installation
13+
14+
Add the following line to your `Cargo.toml` file's dependencies section:
15+
16+
```toml
17+
[dependencies]
18+
podcast-api = "1.0.1"
19+
```
20+
21+
## Usage
22+
23+
The library needs to be configured with your account's API key which is
24+
available in your [Listen API Dashboard](https://www.listennotes.com/api/dashboard/#apps). Set `api_key` to its
25+
value:
26+
27+
```rust
28+
use podcast_api::Error;
29+
use serde_json::json;
30+
31+
#[tokio::main]
32+
async fn main() {
33+
// Api Key (None => Test API, Some(key) => Production API)
34+
let api_key = None;
35+
// let api_key = Some("put your api key here");
36+
37+
// Create client
38+
let client = podcast_api::Client::new(api_key);
39+
40+
// Call API
41+
match client
42+
.typeahead(&json!({
43+
"q": "startup",
44+
"show_podcasts": 1
45+
}))
46+
.await
47+
{
48+
Ok(response) => {
49+
println!("Successfully called Listen Notes API.");
50+
if let Ok(body) = response.json().await {
51+
println!("Response Body:");
52+
println!("{}", body);
53+
} else {
54+
println!("Response body JSON data parsing error.")
55+
}
56+
}
57+
Err(err) => {
58+
match err {
59+
Error::NotFoundError => { println!("Not Found: {}", err); }
60+
Error::AuthenticationError => { println!("Authentication Issue: {}", err); }
61+
Error::RateLimitError => { println!("Rate Limit: {}", err); }
62+
Error::InvalidRequestError => { println!("Invalid Request: {}", err); }
63+
Error::ListenApiError => { println!("API Error: {}", err); }
64+
Error::ApiConnectionError => { println!("Connection Issue: {}", err); }
65+
Error::Reqwest(err) => { println!("Reqwest HTTP Client Error: {}", err); }
66+
Error::Json(err) => { println!("JSON Parsing Error: {}", err); }
67+
}
68+
}
69+
};
70+
}
71+
```
72+
73+
If `apiKey` is `None`, then we'll connect to a [mock server](https://www.listennotes.com/api/tutorials/#faq0) that returns fake data for testing purposes.
74+
75+
76+
### Handling errors
77+
78+
Unsuccessful requests return errors.
79+
80+
| Error | Description |
81+
| ------------- | ------------- |
82+
| AuthenticationError | wrong api key or your account is suspended |
83+
| InvalidRequestError | something wrong on your end (client side errors), e.g., missing required parameters |
84+
| RateLimitError | you are using FREE plan and you exceed the quota limit |
85+
| NotFoundError | endpoint not exist, or podcast / episode not exist |
86+
| ApiConnectionError | failed to connect to Listen API servers |
87+
| ListenApiError | something wrong on our end (unexpected server errors) |
88+
89+
All errors can be found in [this file](https://github.com/ListenNotes/podcast-api-rust/blob/main/src/error.rs).
90+
91+
92+
## Development
93+
94+
### Check
595
- formatting: `cargo fmt -- --check`
696
- valid code: `cargo check`
797
- linting: `cargo clippy`
898

9-
## Open Docs
99+
### Open Docs
10100
`cargo doc --open`
11101

12-
## Build
102+
### Build
13103
`cargo build`
14104

15-
## Test
105+
### Test
16106
`cargo test`
17107

18-
## Usage
19-
Add this to your `Cargo.toml`:
20-
```toml
21-
[dependencies]
22-
podcast-api = "0.1"
23-
```
108+
### Run example app
109+
```sh
110+
cd examples/sample && cargo run
111+
```

examples/sample/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ edition = "2018"
77
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
88

99
[dependencies]
10-
podcast-api = { version = "^0", path = "../../" }
10+
podcast-api = { version = "^1.0.1", path = "../../" }
1111
reqwest = { version = "0.11", features = ["json"] }
1212
serde = { version = "1", features = ["derive"] }
1313
serde_json = "1"

examples/sample/src/main.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ use serde_json::json;
55
async fn main() {
66
// Api Key (None => Test API, Some(key) => Production API)
77
let api_key = None;
8+
// let api_key = Some("put your api key here");
89

910
// Create client
1011
let client = podcast_api::Client::new(api_key);

0 commit comments

Comments
 (0)