zyte-api-rs

Crates.iozyte-api-rs
lib.rszyte-api-rs
version0.2.0
sourcesrc
created_at2023-05-16 23:51:52.126025
updated_at2023-05-25 23:50:18.722824
descriptionUse the Zyte API Proxy -- Unofficial & Unstable
homepagehttps://github.com/isaacimholt/zyte-api-rs
repositoryhttps://github.com/isaacimholt/zyte-api-rs
max_upload_size
id866426
size18,004
Isaac Imholt (isaacimholt)

documentation

https://github.com/isaacimholt/zyte-api-rs

README

zyte-api-rs

Allows access to the Zyte API proxy service.

This is an unofficial, unstable, unfinished crate. However normal usage with HTTP GET should work fine.

Prerequisites

Installation

cargo add zyte-api-rs

Example

use zyte_api_rs::ZyteApi;

#[tokio::main]
async fn get_google() {
    let zyte_api = ZyteApi::new("<MY_ZYTE_API_KEY>");

    // simple GET
    let response = zyte_api.get("https://www.google.com/").await.unwrap();

    // status_code is from http::Method
    if response.status_code.is_success() {
        println!("{}", response.http_response_body);
    }

    let response = zyte_api
        .post("https://httpbin.org/post")
        .unwrap()
        .text(r#"{"custname": "foobar"}"#)
        .send()
        .await
        .unwrap();

    if response.status_code.is_success() {
        println!("{}", response.http_response_body);
    }

}

Features

Requests

  • HTTP
    • GET
    • POST
      • httpResponseBody
      • httpResponseText
  • Browser
  • Headers

Responses

  • Normal Responses
  • Error Responses

Design Goals

Notes

  • The status code is actually an instance of http::StatusCode which allows more useful semantics such as status_code.is_success().
Commit count: 36

cargo fmt