0xtlt / shopify_api

A shopify api client for rust

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

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.5"
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", String::from("2024-04"), 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)

About

A shopify api client for rust

License:MIT License


Languages

Language:Rust 100.0%