Git Product home page Git Product logo

escalade-salsify-api's People

Contributors

kennedyrose avatar tbaustin avatar

Watchers

 avatar  avatar

escalade-salsify-api's Issues

Rework API into JSON export

Hey Taylor,

To answer your original question: the API is not returning parent products because it's restricted to the products in the lists that you're passing, and the parent (or base) products are not on those lists. You could add them, but that might create problems within other aspects of your Salsify implementation.

If you did add them, you can differentiate between them using the filter "?filter==list:default:product_type:root" (which would return parents) and "?filter==list:default:product_type:leaf"(which would return variants). You can change the list there, but that's just an example.

I'm curious about why you are querying the api/lists/ endpoint every time -- do your lists change often? If they don't, I would suggest creating a constant with the list IDs in it that you can use locally: I think that would be faster for you and less intensive for our servers, because you don't need to paginate through all of your lists every time. If your list IDs do change often, then we can definitely revisit this.

I think we can actually make everything work within an ephemeral export call, which could return a JSON file that you could use to feed your site.

For example, I know that the "2018 Archery Catalog" has the list id "83002". Instead of looping through the /api/products endpoint, which is expensive both on your side and on ours, we can create a constant of all of the properties that you want to return:

viewProps = "'Brand','Item Number','Product Name','Brand Images','Main Image','Web Images','Brand Video','Product Video','Feature Bullets','Summary Bullets','Long Description','Short Description','Item Name','Digital Catalog Category','Digital Catalog Subcategory','Category','Product Type','Single Item Unit Height','Single Item Unit Length','Single Item Unit Weight','EscaladeSports.com Product Name','Single Item Unit Width','Product Title','Basketball Goals - Backboard Thickness (in)','Basketball Goals - Pole Size (in)','Basketball Goals - Overhang (ft)','Goalrilla.com - YouTube Video Link','Goalrilla.com - Category','Goalrilla.com - Included Accessories','Goalrilla.com - Related Products','EscaladeSports.com Category'"

and then use an ephemeral export to output a JSON file with the values of those properties for your selected list:

POST to https://app.salsify.com/api/orgs/${process.env.SALSIFY_ORG_ID}/export_runs/ with the configuration:

{
"configuration":{
"entity_type":"product",
"filter":"=list:${ list.id }",
"properties":"${ viewProps }",
"include_all_columns":"false",
"format": "json"
}
}

where viewProps is the constant of properties you would like to return and list.id is the id of the list you are looking up, returned from some earlier lookup against a local list of Salsify product lists. The response body of this POST includes an id, which is the run id.

When you make a GET against https://app.salsify.com/api/orgs/${process.env.SALSIFY_ORG_ID}/export_runs/${run_id}, it will return the URL for a JSON file of all of the product information for the products matching the filter.

This way, you can slim down your program, and make fewer calls against our API (and hopefully faster calls!) to avoid hitting our rate limit. All of the variables are also exposed here, rather than in different Salsify configurations, so you can easily change them.

Let me know if this, or something like it, would work for you. As Joel mentioned, we're working on a GraphQL implementation for Salsify, but we would still paginate the output of our APIs to keep everything speedy, so once we get into data that exceeds 250 entities (and often lower) we start asking if we could accomplish the same tasks with an ephemeral export or a bulk endpoint.

Let me know if you have any questions, or if you want to jump on a call to talk about this.

Best,
Evan

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.