{"id":3980,"date":"2016-12-19T05:50:49","date_gmt":"2016-12-19T05:50:49","guid":{"rendered":"https:\/\/www.botreetechnologies.com\/blog\/?p=3980"},"modified":"2020-12-08T17:09:54","modified_gmt":"2020-12-08T11:39:54","slug":"integrating-bigcommerce-api-with-rails-application","status":"publish","type":"post","link":"https:\/\/www.botreetechnologies.com\/blog\/integrating-bigcommerce-api-with-rails-application\/","title":{"rendered":"BigCommerce API: Accessing for Ruby on Rails application"},"content":{"rendered":"\n<p>In&nbsp;<a href=\"https:\/\/www.botreetechnologies.com\/blog\/ruby-on-rails-application-on-bigcommerce-platform\" target=\"_blank\" rel=\"noopener noreferrer\">previous article<\/a>, we saw how to create BigCommerce store, application and how to integrate it with our Rails application. Now let&#8217;s create a simple <a href=\"https:\/\/www.botreetechnologies.com\/hire-ruby-on-rails-developers\" target=\"_blank\" rel=\"noopener noreferrer\">Rails application<\/a> which will interact with BigCommerce using its Rest API.<\/p>\n\n\n\n<p>We have already added&nbsp;<a href=\"https:\/\/github.com\/bigcommerce\/bigcommerce-api-ruby\" target=\"_blank\" rel=\"noopener noreferrer\">bigcommmerce-api-ruby<\/a>&nbsp;gem for it. It&#8217;s an official Ruby client of Bigcommerce API. Our simple approach for this implementation is, when the&nbsp;load&nbsp;method is called from omniauth controller, we have store details in in params hash. We will use store params to find the store from the database and consider it as a current store throughout the user session.<\/p>\n\n\n\n<p>We will create a method current_store in application controller to access the current store. Mark this method as a helper method so that we can access it in views as well. Each API call expects Oauth token and BigCommerce Client ID. <\/p>\n\n\n\n<p>To fulfill this precondition, we will create a connection object first using the current store data and then we can use that connection object throughout the application to access the BigCommerce database.<\/p>\n\n\n\n<p><script src=\"https:\/\/gist.github.com\/NishantUpadhyay-BTC\/5cb3203cd107da428e73e41a2064306f.js\"><\/script><\/p>\n\n\n\n<p>Now, let&#8217;s create a products&#8217; controller and fetch all products from current store. Here is a sample code to fetch all products from a store.<\/p>\n\n\n\n<p><script src=\"https:\/\/gist.github.com\/NishantUpadhyay-BTC\/f6bacf3e20661ce04eaea4ad91f91f50.js\"><\/script><\/p>\n\n\n\n<blockquote class=\"wp-block-quote is-layout-flow wp-block-quote-is-layout-flow\"><p>Make sure whenever you send a request to BigCommerce, connection object must be passed otherwise your request will be invalidated.<\/p><\/blockquote>\n\n\n\n<p>Here is the sample code to create a product on BigCommerce store.<\/p>\n\n\n\n<p><script src=\"https:\/\/gist.github.com\/NishantUpadhyay-BTC\/4f1f8f169679a2a522ce2e9abe58b86c.js\"><\/script><\/p>\n\n\n\n<p>To get the details of a single product, just pass product id with connection object.<\/p>\n\n\n\n<p><script src=\"https:\/\/gist.github.com\/NishantUpadhyay-BTC\/1e3ce615c6e1461df8a03ecea566d9f0.js\"><\/script><\/p>\n\n\n\n<p>To update a product, just pass product id with all product details you want to update and connection object.<\/p>\n\n\n\n<p><script src=\"https:\/\/gist.github.com\/NishantUpadhyay-BTC\/67411d9db39bc60e04f1bdb97fa91803.js\"><\/script><\/p>\n\n\n\n<p>Deleting product is again straightforward:<\/p>\n\n\n\n<p><script src=\"https:\/\/gist.github.com\/NishantUpadhyay-BTC\/2f108252921667f147ed8b0a18184742.js\"><\/script><\/p>\n\n\n\n<p>This way we can perform different operations with the help of available APIs. Please refer Github repository for complete code base.<\/p>\n\n\n\n<p>We worked on a basic application for CRUD operations in this article. In next article, we will see what is webhook and how to handle it in BigCommerce. So keep reading!!<\/p>\n\n\n\n<p><a href=\"https:\/\/www.botreetechnologies.com\/ruby-on-rails-development\" target=\"_blank\" rel=\"noopener noreferrer\"><strong>Click here for more blogs&#8230;<\/strong><\/a><\/p>\n\n\n\n<hr class=\"wp-block-separator\"\/>\n\n\n\n<p>At <a href=\"https:\/\/www.botreetechnologies.com\/\" target=\"_blank\" rel=\"noopener noreferrer\">BoTree Technologies<\/a>, we build enterprise apps with our RoR team of 25+ engineers.<\/p>\n\n\n\n<p>We also specialize in RPA, AI, Python, Django, Shopify, Spree commerce, NodeJS and ReactJS.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\"><a href=\"https:\/\/www.botreetechnologies.com\/contact\" target=\"_blank\" rel=\"noopener noreferrer\">Consulting is free<\/a> &#8211; let us help you grow!<\/h3>\n","protected":false},"excerpt":{"rendered":"<p>In&nbsp;previous article, we saw how to create BigCommerce store, application&#8230;<\/p>\n","protected":false},"author":4,"featured_media":13947,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[62,73,10],"tags":[],"class_list":["post-3980","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-ecommerce","category-ruby-on-rails","category-technology"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v27.2 - https:\/\/yoast.com\/product\/yoast-seo-wordpress\/ -->\n<title>BigCommerce API: Accessing for Ruby on Rails application<\/title>\n<meta name=\"description\" content=\"BigCommerce API can be accessed for interaction with Ruby on Rails applications using REST. Here&#039;s how you can access BigCommerce API for RoR application.\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/www.botreetechnologies.com\/blog\/integrating-bigcommerce-api-with-rails-application\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"BigCommerce API: Accessing for Ruby on Rails application\" \/>\n<meta property=\"og:description\" content=\"BigCommerce API can be accessed for interaction with Ruby on Rails applications using REST. Here&#039;s how you can access BigCommerce API for RoR application.\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.botreetechnologies.com\/blog\/integrating-bigcommerce-api-with-rails-application\/\" \/>\n<meta property=\"og:site_name\" content=\"BoTree Technologies\" \/>\n<meta property=\"article:publisher\" content=\"https:\/\/www.facebook.com\/BoTreeTechnologies\/\" \/>\n<meta property=\"article:published_time\" content=\"2016-12-19T05:50:49+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2020-12-08T11:39:54+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/www.botreetechnologies.com\/blog\/wp-content\/uploads\/2016\/12\/bigcommerce-api-integration.jpg\" \/>\n\t<meta property=\"og:image:width\" content=\"1024\" \/>\n\t<meta property=\"og:image:height\" content=\"682\" \/>\n\t<meta property=\"og:image:type\" content=\"image\/jpeg\" \/>\n<meta name=\"author\" content=\"Nishant Upadhyay\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:creator\" content=\"@BoTreeTech\" \/>\n<meta name=\"twitter:site\" content=\"@BoTreeTech\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"Nishant Upadhyay\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"2 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\/\/www.botreetechnologies.com\/blog\/integrating-bigcommerce-api-with-rails-application\/#article\",\"isPartOf\":{\"@id\":\"https:\/\/www.botreetechnologies.com\/blog\/integrating-bigcommerce-api-with-rails-application\/\"},\"author\":{\"name\":\"Nishant Upadhyay\",\"@id\":\"https:\/\/www.botreetechnologies.com\/blog\/#\/schema\/person\/5af799914f08fa3d67f69755fdd41467\"},\"headline\":\"BigCommerce API: Accessing for Ruby on Rails application\",\"datePublished\":\"2016-12-19T05:50:49+00:00\",\"dateModified\":\"2020-12-08T11:39:54+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\/\/www.botreetechnologies.com\/blog\/integrating-bigcommerce-api-with-rails-application\/\"},\"wordCount\":378,\"commentCount\":0,\"image\":{\"@id\":\"https:\/\/www.botreetechnologies.com\/blog\/integrating-bigcommerce-api-with-rails-application\/#primaryimage\"},\"thumbnailUrl\":\"https:\/\/www.botreetechnologies.com\/blog\/wp-content\/uploads\/2016\/12\/bigcommerce-api-integration.jpg\",\"articleSection\":[\"ECommerce\",\"Ruby on Rails\",\"Technology\"],\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\/\/www.botreetechnologies.com\/blog\/integrating-bigcommerce-api-with-rails-application\/#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\/\/www.botreetechnologies.com\/blog\/integrating-bigcommerce-api-with-rails-application\/\",\"url\":\"https:\/\/www.botreetechnologies.com\/blog\/integrating-bigcommerce-api-with-rails-application\/\",\"name\":\"BigCommerce API: Accessing for Ruby on Rails application\",\"isPartOf\":{\"@id\":\"https:\/\/www.botreetechnologies.com\/blog\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\/\/www.botreetechnologies.com\/blog\/integrating-bigcommerce-api-with-rails-application\/#primaryimage\"},\"image\":{\"@id\":\"https:\/\/www.botreetechnologies.com\/blog\/integrating-bigcommerce-api-with-rails-application\/#primaryimage\"},\"thumbnailUrl\":\"https:\/\/www.botreetechnologies.com\/blog\/wp-content\/uploads\/2016\/12\/bigcommerce-api-integration.jpg\",\"datePublished\":\"2016-12-19T05:50:49+00:00\",\"dateModified\":\"2020-12-08T11:39:54+00:00\",\"author\":{\"@id\":\"https:\/\/www.botreetechnologies.com\/blog\/#\/schema\/person\/5af799914f08fa3d67f69755fdd41467\"},\"description\":\"BigCommerce API can be accessed for interaction with Ruby on Rails applications using REST. Here's how you can access BigCommerce API for RoR application.\",\"breadcrumb\":{\"@id\":\"https:\/\/www.botreetechnologies.com\/blog\/integrating-bigcommerce-api-with-rails-application\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/www.botreetechnologies.com\/blog\/integrating-bigcommerce-api-with-rails-application\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/www.botreetechnologies.com\/blog\/integrating-bigcommerce-api-with-rails-application\/#primaryimage\",\"url\":\"https:\/\/www.botreetechnologies.com\/blog\/wp-content\/uploads\/2016\/12\/bigcommerce-api-integration.jpg\",\"contentUrl\":\"https:\/\/www.botreetechnologies.com\/blog\/wp-content\/uploads\/2016\/12\/bigcommerce-api-integration.jpg\",\"width\":1024,\"height\":682,\"caption\":\"BigCommerce API Access in Rails app\"},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/www.botreetechnologies.com\/blog\/integrating-bigcommerce-api-with-rails-application\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\/\/www.botreetechnologies.com\/blog\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"BigCommerce API: Accessing for Ruby on Rails application\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/www.botreetechnologies.com\/blog\/#website\",\"url\":\"https:\/\/www.botreetechnologies.com\/blog\/\",\"name\":\"BoTree Technologies\",\"description\":\"Committed to inspire generation.\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/www.botreetechnologies.com\/blog\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":\"Person\",\"@id\":\"https:\/\/www.botreetechnologies.com\/blog\/#\/schema\/person\/5af799914f08fa3d67f69755fdd41467\",\"name\":\"Nishant Upadhyay\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/www.botreetechnologies.com\/blog\/wp-content\/uploads\/2020\/10\/nishant-upadhyay-150x150.png\",\"url\":\"https:\/\/www.botreetechnologies.com\/blog\/wp-content\/uploads\/2020\/10\/nishant-upadhyay-150x150.png\",\"contentUrl\":\"https:\/\/www.botreetechnologies.com\/blog\/wp-content\/uploads\/2020\/10\/nishant-upadhyay-150x150.png\",\"caption\":\"Nishant Upadhyay\"},\"description\":\"Nishant is Practice Lead of Ruby on Rails. He is a Blogger, Mentor, and Rubyst. He has expertise in Javascript as well. He is highly skilled in designing, developing and testing web applications. He enjoys being challenged and engaging with projects that require him to work outside his comfort and knowledge set.\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"BigCommerce API: Accessing for Ruby on Rails application","description":"BigCommerce API can be accessed for interaction with Ruby on Rails applications using REST. Here's how you can access BigCommerce API for RoR application.","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/www.botreetechnologies.com\/blog\/integrating-bigcommerce-api-with-rails-application\/","og_locale":"en_US","og_type":"article","og_title":"BigCommerce API: Accessing for Ruby on Rails application","og_description":"BigCommerce API can be accessed for interaction with Ruby on Rails applications using REST. Here's how you can access BigCommerce API for RoR application.","og_url":"https:\/\/www.botreetechnologies.com\/blog\/integrating-bigcommerce-api-with-rails-application\/","og_site_name":"BoTree Technologies","article_publisher":"https:\/\/www.facebook.com\/BoTreeTechnologies\/","article_published_time":"2016-12-19T05:50:49+00:00","article_modified_time":"2020-12-08T11:39:54+00:00","og_image":[{"width":1024,"height":682,"url":"https:\/\/www.botreetechnologies.com\/blog\/wp-content\/uploads\/2016\/12\/bigcommerce-api-integration.jpg","type":"image\/jpeg"}],"author":"Nishant Upadhyay","twitter_card":"summary_large_image","twitter_creator":"@BoTreeTech","twitter_site":"@BoTreeTech","twitter_misc":{"Written by":"Nishant Upadhyay","Est. reading time":"2 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/www.botreetechnologies.com\/blog\/integrating-bigcommerce-api-with-rails-application\/#article","isPartOf":{"@id":"https:\/\/www.botreetechnologies.com\/blog\/integrating-bigcommerce-api-with-rails-application\/"},"author":{"name":"Nishant Upadhyay","@id":"https:\/\/www.botreetechnologies.com\/blog\/#\/schema\/person\/5af799914f08fa3d67f69755fdd41467"},"headline":"BigCommerce API: Accessing for Ruby on Rails application","datePublished":"2016-12-19T05:50:49+00:00","dateModified":"2020-12-08T11:39:54+00:00","mainEntityOfPage":{"@id":"https:\/\/www.botreetechnologies.com\/blog\/integrating-bigcommerce-api-with-rails-application\/"},"wordCount":378,"commentCount":0,"image":{"@id":"https:\/\/www.botreetechnologies.com\/blog\/integrating-bigcommerce-api-with-rails-application\/#primaryimage"},"thumbnailUrl":"https:\/\/www.botreetechnologies.com\/blog\/wp-content\/uploads\/2016\/12\/bigcommerce-api-integration.jpg","articleSection":["ECommerce","Ruby on Rails","Technology"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/www.botreetechnologies.com\/blog\/integrating-bigcommerce-api-with-rails-application\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/www.botreetechnologies.com\/blog\/integrating-bigcommerce-api-with-rails-application\/","url":"https:\/\/www.botreetechnologies.com\/blog\/integrating-bigcommerce-api-with-rails-application\/","name":"BigCommerce API: Accessing for Ruby on Rails application","isPartOf":{"@id":"https:\/\/www.botreetechnologies.com\/blog\/#website"},"primaryImageOfPage":{"@id":"https:\/\/www.botreetechnologies.com\/blog\/integrating-bigcommerce-api-with-rails-application\/#primaryimage"},"image":{"@id":"https:\/\/www.botreetechnologies.com\/blog\/integrating-bigcommerce-api-with-rails-application\/#primaryimage"},"thumbnailUrl":"https:\/\/www.botreetechnologies.com\/blog\/wp-content\/uploads\/2016\/12\/bigcommerce-api-integration.jpg","datePublished":"2016-12-19T05:50:49+00:00","dateModified":"2020-12-08T11:39:54+00:00","author":{"@id":"https:\/\/www.botreetechnologies.com\/blog\/#\/schema\/person\/5af799914f08fa3d67f69755fdd41467"},"description":"BigCommerce API can be accessed for interaction with Ruby on Rails applications using REST. Here's how you can access BigCommerce API for RoR application.","breadcrumb":{"@id":"https:\/\/www.botreetechnologies.com\/blog\/integrating-bigcommerce-api-with-rails-application\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.botreetechnologies.com\/blog\/integrating-bigcommerce-api-with-rails-application\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.botreetechnologies.com\/blog\/integrating-bigcommerce-api-with-rails-application\/#primaryimage","url":"https:\/\/www.botreetechnologies.com\/blog\/wp-content\/uploads\/2016\/12\/bigcommerce-api-integration.jpg","contentUrl":"https:\/\/www.botreetechnologies.com\/blog\/wp-content\/uploads\/2016\/12\/bigcommerce-api-integration.jpg","width":1024,"height":682,"caption":"BigCommerce API Access in Rails app"},{"@type":"BreadcrumbList","@id":"https:\/\/www.botreetechnologies.com\/blog\/integrating-bigcommerce-api-with-rails-application\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/www.botreetechnologies.com\/blog\/"},{"@type":"ListItem","position":2,"name":"BigCommerce API: Accessing for Ruby on Rails application"}]},{"@type":"WebSite","@id":"https:\/\/www.botreetechnologies.com\/blog\/#website","url":"https:\/\/www.botreetechnologies.com\/blog\/","name":"BoTree Technologies","description":"Committed to inspire generation.","potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/www.botreetechnologies.com\/blog\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Person","@id":"https:\/\/www.botreetechnologies.com\/blog\/#\/schema\/person\/5af799914f08fa3d67f69755fdd41467","name":"Nishant Upadhyay","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.botreetechnologies.com\/blog\/wp-content\/uploads\/2020\/10\/nishant-upadhyay-150x150.png","url":"https:\/\/www.botreetechnologies.com\/blog\/wp-content\/uploads\/2020\/10\/nishant-upadhyay-150x150.png","contentUrl":"https:\/\/www.botreetechnologies.com\/blog\/wp-content\/uploads\/2020\/10\/nishant-upadhyay-150x150.png","caption":"Nishant Upadhyay"},"description":"Nishant is Practice Lead of Ruby on Rails. He is a Blogger, Mentor, and Rubyst. He has expertise in Javascript as well. He is highly skilled in designing, developing and testing web applications. He enjoys being challenged and engaging with projects that require him to work outside his comfort and knowledge set."}]}},"amp_enabled":true,"_links":{"self":[{"href":"https:\/\/www.botreetechnologies.com\/blog\/wp-json\/wp\/v2\/posts\/3980","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.botreetechnologies.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.botreetechnologies.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.botreetechnologies.com\/blog\/wp-json\/wp\/v2\/users\/4"}],"replies":[{"embeddable":true,"href":"https:\/\/www.botreetechnologies.com\/blog\/wp-json\/wp\/v2\/comments?post=3980"}],"version-history":[{"count":1,"href":"https:\/\/www.botreetechnologies.com\/blog\/wp-json\/wp\/v2\/posts\/3980\/revisions"}],"predecessor-version":[{"id":13948,"href":"https:\/\/www.botreetechnologies.com\/blog\/wp-json\/wp\/v2\/posts\/3980\/revisions\/13948"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.botreetechnologies.com\/blog\/wp-json\/wp\/v2\/media\/13947"}],"wp:attachment":[{"href":"https:\/\/www.botreetechnologies.com\/blog\/wp-json\/wp\/v2\/media?parent=3980"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.botreetechnologies.com\/blog\/wp-json\/wp\/v2\/categories?post=3980"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.botreetechnologies.com\/blog\/wp-json\/wp\/v2\/tags?post=3980"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}