{"id":19037467,"url":"https://github.com/marsavar/aletheia","last_synced_at":"2025-04-23T19:16:13.732Z","repository":{"id":42010544,"uuid":"442290096","full_name":"marsavar/aletheia","owner":"marsavar","description":"A client library for the Guardian's content API written in Rust 🦀","archived":false,"fork":false,"pushed_at":"2022-12-28T00:41:20.000Z","size":95,"stargazers_count":3,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-04-23T19:16:02.477Z","etag":null,"topics":["api-client","api-client-rust","guardian","guardian-api","rust","rust-crate","rust-lang","rust-library","theguardian"],"latest_commit_sha":null,"homepage":"https://crates.io/crates/aletheia","language":"Rust","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/marsavar.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2021-12-27T22:43:14.000Z","updated_at":"2024-03-20T02:20:39.000Z","dependencies_parsed_at":"2023-01-31T05:30:34.231Z","dependency_job_id":null,"html_url":"https://github.com/marsavar/aletheia","commit_stats":null,"previous_names":[],"tags_count":3,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/marsavar%2Faletheia","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/marsavar%2Faletheia/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/marsavar%2Faletheia/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/marsavar%2Faletheia/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/marsavar","download_url":"https://codeload.github.com/marsavar/aletheia/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":250496993,"owners_count":21440231,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["api-client","api-client-rust","guardian","guardian-api","rust","rust-crate","rust-lang","rust-library","theguardian"],"created_at":"2024-11-08T21:59:58.941Z","updated_at":"2025-04-23T19:16:13.709Z","avatar_url":"https://github.com/marsavar.png","language":"Rust","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Aletheia\n\n\u003e Aletheia is truth or disclosure (...) The literal meaning of the word ἀλήθεια is \"the state of not being hidden; the state of being evident.\"\n\nAletheia is an HTTP client library for [the Guardian](https://www.theguardian.com)'s [content API](https://open-platform.theguardian.com) written in Rust.\n\n## How to use it\nAletheia requires Tokio as a dependency to execute asynchronous code.\\\nSimply add `aletheia` and `tokio` to the list of dependencies in your `Cargo.toml` file.\n\n```toml\n[dependencies]\naletheia = \"0.1.6\"\ntokio = { version = \"1\", features = [\"full\"] }\n```\n\nYou also need an API key to be able to make requests. \nKeys can be requested [here](https://open-platform.theguardian.com/access/). \n\n## Example\n\nLet's say you were interested in finding five film, play or album reviews with a rating of 5 stars \ncontaining the word \"politics\" published from January to December 2022.\nThe code would look something like the example below, and would consist of three steps:\n\n1) Constructing the HTTP client\n2) Building the query\n3) Parsing the response [*](#debug)\n```rust\nuse aletheia::enums::*;\nuse aletheia::{GuardianContentClient, Result};\n\n#[tokio::main]\nasync fn main() -\u003e Result\u003c()\u003e {\n    // The client is constructed by passing your API key\n    // as the only parameter\n    let mut client = GuardianContentClient::new(\"your-api-key\");\n\n    // Query parameters are built incrementally\n    let response = client\n        .search(\"politics\")\n        .date_from(2022, 1, 1)\n        .date_to(2022, 12, 31)\n        .star_rating(5)\n        .page_size(5)\n        .show_fields(vec![Field::Byline])\n        .order_by(OrderBy::Newest)\n        .send()\n        .await?;\n\n    // Parsing the response.\n    // The response objects are deserialized, for the most part,\n    // into Option values that need to be handled safely with\n    // `let else` or `if let`.\n    if let Some(results) = response.results {\n        for result in results {\n            let Some(pub_date) = result.web_publication_date else { continue };\n            let Some(fields) = result.fields else { continue };\n            let Some(byline) = fields.byline else { continue };\n\n            println!(\n                \"[{}] {} ({})\\n{}\\n\",\n                pub_date.format(\"%Y-%m-%d\"),\n                result.web_title.trim(),\n                byline,\n                result.web_url,\n            )\n        }\n    }\n\n    Ok(())\n}\n```\n\nThe above will return the following results.\n```\n[2022-12-15] Children of the Taliban review – this beautiful documentary is an absolute must-watch (Rebecca Nicholson)\nhttps://www.theguardian.com/tv-and-radio/2022/dec/15/children-of-the-taliban-review-this-beautiful-documentary-is-an-absolute-must-watch\n\n[2022-10-25] The White Lotus season two review – this immaculate show’s writing is utterly unrivalled (Lucy Mangan)\nhttps://www.theguardian.com/tv-and-radio/2022/oct/25/the-white-lotus-season-two-review-this-immaculate-seriess-writing-is-utterly-unrivalled\n\n[2022-10-09] The Doctor review – a repeat prescription for acute intellectual stimulation (Arifa Akbar)\nhttps://www.theguardian.com/stage/2022/oct/10/the-doctor-review-duke-of-yorks-theatre-robert-icke-juliet-stevenson\n\n[2022-09-27] Make Me Prime Minister review – absolute, exquisite agony (Lucy Mangan)\nhttps://www.theguardian.com/tv-and-radio/2022/sep/27/make-me-prime-minister-review-absolute-exquisite-agony\n\n[2022-09-02] Bones and All review – cannibal romance is a heartbreaking banquet of brilliance (Peter Bradshaw)\nhttps://www.theguardian.com/film/2022/sep/02/bones-and-all-review-luca-guadagnino-timothee-chalamet-venice-film-festival\n```\n\n#### Debug\n[*] You can pretty-print the whole output response with the format specifier `#?`:\n```rust\nprintln!(\"{response:#?}\");\n```\nor by using the `dbg!` macro:\n```rust\ndbg!(response);\n```","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmarsavar%2Faletheia","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmarsavar%2Faletheia","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmarsavar%2Faletheia/lists"}