4 releases

0.3.4 Oct 18, 2022
0.3.2 Oct 18, 2022
0.2.1 Oct 17, 2022
0.2.0 Oct 17, 2022
0.1.0 Oct 16, 2022

#920 in Web programming

21 downloads per month

MIT license

24KB
394 lines

shopify_api

crates.io Documentation MIT/Apache-2 licensed CI Issues

An ergonomic, Shopify API Client for Rust.

  • GraphQL API support with automatic data deserialization
  • Changelog

Example

This asynchronous example uses Tokio and enables some optional features, so your Cargo.toml could look like this:

[dependencies]
shopify_api = "0.3"
tokio = { version = "1", features = ["full"] }

And then the code:

use shopify_api::*;
use shopify_api::utils::ReadJsonTreeSteps;
use serde::{Deserialize};

#[derive(Deserialize)]
struct Shop {
  name: String,
}

#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
  let shopify = Shopify::new("hello", "world", ShopifyAPIVersion::V2023_01, None);

  let graphql_query = r#"
    query {
      shop {
      name
     }
  }"#;

  let variables = serde_json::json!({});
  let json_finder = vec![ReadJsonTreeSteps::Key("data"), ReadJsonTreeSteps::Key("shop")];

  let shop: Shop = shopify.graphql_query(graphql_query, &variables, &json_finder).await.unwrap();
  Ok(())
}

License

Licensed under MIT license (LICENSE-MIT or http://opensource.org/licenses/MIT)

Dependencies

~5–13MB
~272K SLoC