Giter Site home page Giter Site logo

shopifyapi's Introduction

The Shopify API Wrapper for .NET 4.0

Shopify is great for running a store - but up until now there haven't been many API tools for .NET. This simple library is useful for querying your Shopify store as well as adding, editing, and deleting items.

How To Install It?

Reference the Shopify.dll in your project.

How Do You Use It?

This might come as a big surprise to people... but it's all dynamic. You structure queries based on what you need from the API.

For instance - if you want to query for products, you make a JSON request to the Shopify API (the docs are here: http://api.shopify.com/product.html):

dynamic shopify = new Shopify.Api("myAPIKey","myAPIPassword","somestore.myshopify.com");
var query = shopify.Products();
foreach(var product in query.products){
	Console.Writeline(product.title);
}

In this example, the method "Products()" doesn't exist - it's "caught" by the API wrapper and a URL constructed for you (with the necessary credentials). What you get back is a dynamic bit of JSON that you can then loop over. You'll need to know the structure of the return call - but it's all documented up in the Shopify API.

You can also query by passing in parameters:

dynamic shopify = new Shopify.Api("myAPIKey","myAPIPassword","somestore.myshopify.com");
var query = shopify.Products(collection_id: 12121212);
foreach(var product in query.products){
	Console.Writeline(product.title);
}

Same thing - the call here is dynamicall inferred based on the name of the named argument.

Adding, Editing, Deleting

Again, all dynamic. For this you use an ExpandoObject and pass it into the API:

//use an Anon type here if you like... it just needs to match the casing and structure of the Shopify bits
var p = new {
	title = "My new Product";
	handle = "sex-appeal";
	//add variants and price here using arrays
}

dynamic shopify = new Shopify.Api("myAPIKey","myAPIPassword","somestore.myshopify.com");
shopify.Products.Save(p);

The last call there is, once again, dynamically inferred. "Products" doesn't exist as a property on "shopify" - so a bunch of goodness happens which results in you being able to execute an HTTP POST to the Shopify API.

If there's an "id" present on the product, a "PUT" will be executed, which will update the item (Product, Collection, Blog, Page... whatever).

To delete, you simply need to know the ID. You can do that easily:

dynamic shopify = new Shopify.Api("myAPIKey","myAPIPassword","somestore.myshopify.com");
var query = shopify.Products(handle: "sex-appeal");
var id = query.products[0].id
shopify.Products.Delete(id);

shopifyapi's People

Contributors

cmcdonaldca avatar subsonic avatar robconery avatar

Stargazers

 avatar

Watchers

James Cloos avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.