BigCommerce API to Search products - bigcommerce

We are trying to build a mobile app for a Big Commerce based shop. We want to implement a simple product search feature - User will enter a search keyword, application should display all the products which matches that search keyword.
There don't seem to be any straight forward Big Commerce API to achieve this. Product has a field named "search_keywords" but surprisingly this is not listed in possible filters for querying a list of products. Can some body throw some light on how to implement a simple search feature using BC APIs.

Bigcommerce themes have a feature called QuickSearch that allows for fetching n XML list of matched products (and content pages) via AJAX but you will come across cross-origin domain issues if your server is not configured correctly. One example would be:
$.ajax({
type: 'GET',
dataType: 'xml',
url: config.ShopPath + '/search.php?action=AjaxSearch&search_query='+encodeURIComponent($('#search_query').val()),
success: function(response) { QuickSearch.search_done(response); }
});

Search keywords is used for web store search, it is not surfaced via API. If you want to build an entire search solution via API, it is going to be hard unless you GET the products and cache it. Check out an app called searchspring from BC app store, which implements an faceted search. Cheers!

Related

Accessing site options via a REST API

I'm building a REST API powered SPA application and I'm trying to decide on the best way to deliver "global options" via the API. By global options I mean an assortment of random fields that relate to the application as a whole rather than being associated with one specific model, for example brand logos and contact details that need to be accessible from multiple locations within the app.
Something like Wordpress would store these in an options table and access them via a php function using the option name, however since this is a REST API I'm not sure how I would go about accessing/updating multiple options without making lots of requests for each one.
I know a lot of projects just use a json file to store this data, but it specifcally needs to be editable via a CMS and served via the API. The following are two methods that have come to mind, but none of them feel like complete solutions:
1: An options table with one generic endpoint that takes a query string specifying which fields you want to access. This works for getting data, however updating data seems to get a bit messy and the only way I can think to do this is by sending an object of key/values pairs to bulk create or update the options:
GET: example.com/api/options?pick=logo,contact_phone,contact_email
POST: example.com/api/options
{
contact_email: "info#example.com",
contact_address: "123 Test St"
}
PUT: example.com/api/options
{
contact_email: "info#example.com",
contact_address: "123 Test St"
}
2: Breaking fields into groups and storing them as a json field in a "pages" table, this solves the creating and updating issues but breaks down when you have fields are used in multiple locations, and they aren't really pages so it's not very REST like.
GET: example.com/api/pages/contact
POST: example.com/api/pages
{
name: "contact",
values: {
email: "info#example.com",
address: "123 Test St",
}
}
PUT: example.com/api/pages/contact
{
values: {
email: "info#example.com",
address: "123 Test St",
}
}
I also need to take into account the issue of access permissions, for example the logo field would be accessible to the public, but the user support contact number would only be accessible to logged in users. With the first example you could have an extra permission column for each option, but this wouldn't work for the second option.
I've been googling but have failed to find any good information about this topic as REST schemas/documention generally only deal with concreate entities, so any insight into how this is achieved in real world applciations would be great!
Cheers,
Cam

How to Filter category data without change URL and querystring in bigcommerce

I am new in bigcommerce and I using the stencil and bigcommerce/stencil-utils.
When I filter data from provided option then add query string with existing URL as per below URL.
https://gemsnytest.mybigcommerce.com/loose-gemstones/?_bc_fsnf=1&carat[]=0.46&carat[]=3
After then data filter.
Any possible way to product data filter data without add query string in URL in bigcommerce
Please help.
This is not natively possible with Cornerstone and you would have to build this out yourself.
One option would be to create & inject custom scripts on custom catalog templates that can handle the filtering with JS, compared to how BigCommerce natively handles this, with query strings. The method BigCommerce is using with query strings could be useful from a merchandising/marketing perspective as you can link to your filtered results as its own page so that's something to consider when thinking of alternatives without present in the url.
Depending on the priority, size and flexibility needed for this requirement and where you are in your site building process, you could also consider building out a headless storefront. You could use the GraphQL API to query catalog results, or our S2S APIs. To handle the filtering, you could look at storing this in the state (if you were to build a storefront with a state management library) or something custom to your liking that can handle the filtering in a more discrete way.

TYPO3 - Insert api medipim

I want to call products on a web page via the api of Medipim. I have never done this before and I have never worked with TYPO3.
Therefore two questions.
In which (config) file do I place the authentication (I have an ID and secret key) and what exactly does that code look like?
When I want to call up the products, how do I use this in the TYPO3 page environment? Do I have to choose a html page or can I just enter it in the TYPO3 editor on a page?
Documentation: watch
You probably need an extension which converts the data you get from medipim to HTML. I Expect you get information as JSON, XML, or CSV.
As you won't publish your access code you probably will not use a javascript call from the browser to access the API, then you need some PHP.
Using PHP in TYPO3 is done in extensions. You should learn about building extensions in TYPO3. As a healper you might use the TYPO3 extension "Extension Builder" (=EB). As you have no local records you only need the extension frame with just one plugin from the EB.
Depending on your usage (will an editor select products from Medipim (option A) or should the visitor be able to select products (option B)?) you need a plugin with an option to insert desired product identification for BackEnd editors or just an input mask.
you can configure your plugin with typoscript so an integrator can enter the authentification information just once.
For option A you need to enhance your plugin with a field for the product ids.
keyword: flexform
for Option B you need a form.
Then you need to display the product information you get from the API. provide the returned data in variables and use Fluid templates to get a nice display.
Without any knowledge of TYPO3 this will be hard work and a lot to learn. The other possibility: hire an experienced TYPO3 developer and let him build this extension for you.

ASP.NET Core Displaying data in View from Api

I am creating Cars store in Asp.Net for my school.
I built an Api Method:
[HttpGet("api/brands/{brandName}/models")]
public IActionResult Get(string brandName)
{
{
var model = _context.getBrandByName(brandName);
return Ok(model.Models.ToList());
}
}
An it works when I am checking it with Postman.
Now I would like User to choose brandName from selection list in the website and show him avaliable models.
In other words I dont know how to use this Api to get Data displayed.
Any help will be strongly appreciated
RESTful Web services are one way of providing interoperability between computer systems on the Internet. REST-compliant Web services allow requesting systems to access and manipulate textual representations of Web resources using a uniform and predefined set of stateless operations.
from Wikipedia.
This means, the REST API's only concern is to provide the data to work in a uniform and predefined set of operations, where those operations take the HTTP Verb that was used in consideration.
in your example, your GET route, should only be api/brands/{brandName}
the default in rest api, http verbs say:
GET - getting one element or a list
POST - creating
PUT - updating
DELETE - removing
in your application, the best approach would be something like:
GET /api/brands will get ALL existing brands
GET /api/brands/<brand_name> will get just one brand
POST /api/brands will create a new brand
PUT /api/brands will edit an existing brand
DELETE /api/brands will delete an existing brand
from your question:
Now I would like User to choose brandName from selection list on the website
the website would then request a GET to the route /api/brands to get the list of all of the brands.
This is the REST API part, it concerns ONLY in providing the right data to the system that request it.
if you want to create a website in order to CONSUME this data, you can easily create a new web project in your solution and request the data that the API provides, making the Website completely "blind" from where the data comes from, as it only asks for the data itself.
Making the whole system much easier for updated and maintainability.
In other words I dont know how to use this Api to get Data displayed.
The main purpose of REST API is to expose data not to display it by using any kind of UI framework.
If you think you need to manage the full stack of your application end-to-end. I mean from User interface to your database then you must think at implementing the V of the MVC pattern bu return a view and not just a data. ASP.Net Core can help you with that. Follow this tutorial, it explains a lot about this pattern in ASP.Net Core MVC.

Yammer statistics through APIs

We have a CMS-solution, where Yammer is integrated using the "Embedded Feed". Next to most of the pages in the solution, there is a Yammer part for comments and liking.
Now we would like to increase the functionality with the following:
A list of the most liked pages
A list of the most commented pages
How many people liked the current page
How many people commented current page
Anyone have experience with this? Ie, to collect already summarized data, or retrieve data and summarize yourself in the solution? And especially dealt with rate limits and worked with some form of caching?
The Yammer APIs are very limited in functionality, and will not support what you are trying to do.
Even without the throttling, getting the most liked and most-commented pages are going to be flat-out impossible. There's no way to query for most-liked or most-commented Open Graph objects. (Unless I am mistaken)
To get the total likes and comments on a given page, ignoring the throttling issues, here's what you could do:
Pages are represented as Open Graph objects in Yammer. Getting the likes and comments is a 2-step process. First, you need to grab the Open Graph ID of a given URL, then fetch the messages related to that OG object. But, again, you'll only get the first twenty.
To grab the OG object:
yam.platform.request({
url: "open_graph_objects?url=" + url.toLowerCase(),
method: "GET",
data: {},
success: function (OGObj) {
//your id is in the OGObj.id
}
});
then, to get the messages:
yam.platform.request({
url: "messages/open_graph_objects/" + OG_id + ".json",
method: "GET",
data: {},
success: function (msg) {
//parse out this object for the messages, which
// contain like and comments counts
}
});
**Now, there is a Yammer "Like" button that allows you to directly "Like" Yammer Oopen Graph objects, but incredibly there is no way to actually retreive those Likes. You can only get likes on messages related to those URLs.