reqt

Crates.ioreqt
lib.rsreqt
version1.0.0
created_at2025-11-26 11:10:09.945727+00
updated_at2025-11-26 11:10:09.945727+00
descriptionAn HTTP request manager, providing high level features to connect to a web API and handle requests.
homepagehttps://github.com/ZialeHub/reqt
repositoryhttps://github.com/ZialeHub/reqt
max_upload_size
id1951250
size158,695
Ziale (ZialeHub)

documentation

README

Rust CI

๐Ÿ“ฆ Library: reqt

โ“ What is it?

reqt is an HTTP request manager, providing high level features to connect to a web API and handle requests.

๐Ÿ”ญ What is our vision for this project?

reqt goal is to make communication with web APIs easy.

๐Ÿšจ What problem does it solve?

reqt provides high level interfaces to make connect, auth, pagination, filtering, ranging, sorting, and working with rate limits a breeze.

๐ŸŽฏ Who is it for?

Web devs who need to interact with an API.

โœจ Features

  • connection
  • authorization
  • requests (REST)
  • rate-limit (manual + automatic)
  • pagination
  • filters
  • range
  • sorting

โš™๏ธ Next

โ” Open questions

๐Ÿš€ Usage

Connector

Api<P: Pagination = RequestPagination, F: Filter = FilterRule, S: Sort = SortRule, R: Range = RangeRule>

Api Connector can be defined using the default Pagination, Filter, Sort and Range rules, or by implementing your own types that implement the following traits:

Each rule can be overridden for a specific request if needed later.

Authorization

Authorization Type define how to use your token in each request:

  • None => No token
  • Basic
    username and password are Base64 encoded
    Authorization: Basic username:password
  • Bearer
    Authorization: Bearer <token>
  • ApiKey
    X-API-Key: 1234567890abcdef
  • OAuth2
    Authorization: Bearer <access_token>
    Authorization: Bearer <refresh_token>
  • OIDC
  • Keycloak

Request

Request<B: Serialize + Clone = (), P: Pagination = RequestPagination, F: Filter = FilterRule, S: Sort = SortRule, R: Range = RangeRule>

The request allow you to override pagination, filter, sort and range rules from the connector.

Pagination

Pagination defines the rule to manage multiple page requests depending on the API specifications.

By default RequestPagination will be used and fields are set as follow:

  • size = 100 => Page size
  • current_page = 1
  • pagination = PaginationRule::OneShot

And the headers page[number]=x and page[size]=y are added to the final query of the request.

To implement your own pagination, you need to implement the Pagination trait.

Pagination Rule
  • Fixed(X)
    Where X is the number of page you want collected by one request
  • OneShot

Filter

Filter defines the way to filter resources with your request, and the list of filters you want to apply.

To implement your own filter rule, you need to implement the Filter trait.

Range

Range defines the way to range resources with your request, and the list of ranges you want to apply.

To implement your own range rule, you need to implement the Range trait.

Sort

Sort defines the way to sort resources with your request, and the list of sorts you want to apply.

To implement your own sort rule, you need to implement the Sort trait.

SortOrder

Rate limit

The rate limit can be set through the ApiBuilder (Default = RateLimiter::new(1, TimePeriod::Second)), and will allow the connector to respect a specific rate to avoid 429 HTTP errors.

Derive Macros

To implement your own connector with ease, you have in your hands the following macros:

#[derive(Debug, Clone, Deserialize, Oauth2)]
#[pagination(PaginationTest)]
#[filter(FilterTest)]
#[sort(SortTest)]
#[range(RangeTest)]
struct TestApiConnector {
  client_id: String,
  client_secret: String,
  auth_endpoint: String,
  scopes: Vec<String>,
}

๐Ÿ‘€ Examples

๐Ÿค Contributing

Please always perform the following checks before committing:

  1. โš™๏ธ cargo build --workspace --all --all-features --tests
  2. ๐Ÿงผ cargo fmt --all
  3. ๐Ÿฉบ cargo clippy --workspace --all --all-features --tests -- -D warnings
  4. ๐Ÿงช cargo test --all-targets --all-features --workspace

๐Ÿ“„ License

This project is licensed under the MIT License. See LICENSE for details.

Contributors

Huge thanks to gpoblon for his CI, ideas and reviews!

Commit count: 0

cargo fmt