loc-api
loc-api is a Rust library that provides an interface for interacting with the Library of Congress (LOC) APIs. It simplifies the process of constructing API requests, managing parameters, and handling responses, enabling developers to seamlessly integrate LOC data into their Rust applications.
Work in progress, not everything is implemented yet, however, the library is functional and can be used to interact with the LOC API. Check out the examples below to see how to use the library. The included examples directory within the repository contains a few more examples as well.
Please report any issues or bugs, I'm sure there are many. I'm also open to suggestions and contributions.
Installation
Add loc-api to your project's Cargo.toml:
[]
= "1.0.8"
OR
You can use cargo add to add the dependency to your Cargo.toml:
This library depends on [reqwest], [serde] and [serde_json] for making HTTP requests and serializing/deserializing JSON data, respectively:
[]
= { = "0.11", = ["blocking", "json"] }
= { = "1.0", = ["derive"] }
= "1.0"
Examples
Creating an API Client
First, initialize the [ApiClient]. You can optionally set the [LOC_API_BASE_URL] environment variable to override the default LOC API base URL.
Other methods of setting the base URL include using the ApiClient::with_base_url constructor or directly modifying the loc_client::DEFAULT_BASE_URL constant.
use ApiClient;
Using the modules directly to construct a URL for querying specific types of [MediaType]
use ;
Using the loc_client module to make a search request
use ApiClient;
use ;
use AttributesSelect;
use SortField;
Related Projects
- **[cdg_api]: A Rust library for interacting with the Congress.gov API.
License
This project is licensed under the MIT License. See the LICENSE file for more details.
Repository
Acknowledgements
The data is sourced from the U.S. Library of Congress.
Contact
For questions or feedback, please contact me on github.
If you find this project helpful, consider donating PayPal.