Magento rest api resources - api

I have an android application connected to magento server by rest api. The application must preform some actions, but I have no examples of requests needed for the application.
For example I have this list of requests, but it is superficial enough for my application. For example, I do request:
"http://myUrl.com/api/rest/products?limit=15" and receive the list of 15 products. But after I need to receive next 15 product, and next, and next... What request can do it?
Also I need to do another requests which have no in site examples.
Where can I get more information and examples about rest api requests? Thank You in advance.

You can use various get filters available for REST request in magento GET FILTERS. To access second page you can use page filter available i.e. "http://myUrl.com/api/rest/products?limit=15&page=2". You can also combine many filters and use them as you want. Eg. For getting a result of products which have their name like 'product123', you can use: magentohost/api/rest/products?filter[1][attribute]=name&filter[1][like]=%product123%.

Related

Flask REST api resource URLs suggestions

I'm working on REST Api suing Python Flask, as I have more and more routes, its hard to manage all the resource urls.
Right now, I'm confused which one is better practices of URL parameters. Examples below:
Get a list of courses with limits:
/courses/<int:lim> OR /courses/list?lim=10
Get a specific course:
/courses/<code>/<section> OR /courses/show?code=cs100&section=1
Get a list of students in specific course:
/courses/<code>/<section>/students OR /students/show?code=cs100&section=1
Should I pass query parameters using / or by doing ?
The only reason I'm using / is that there's no conflict in query.
If I have these two URL for two different queries, how can I fix it so I can query base on the parameters:
/students/show?code=cs100&section=1 (Get all students in that course)
/students/show?id=123456789 (Get the specific student)
The URL should identify a resource or collection of resources. Any options you want to give the client, such as pagination, limits, filtering, sorting, etc. I think is best to include in the query string or in HTTP headers.
So regarding your specific questions:
Get a list of courses with limits: /courses/<int:lim> OR /courses/list?lim=10
Neither one. Use /courses?lim=10. No need to have a /list component, that is an action, not a resource.
Get a specific course: /courses/<code>/<section> OR /courses/show?code=cs100&section=1
The first. Once again, /courses/show indicates an action, you want URLs to be links to resources, in this case your course.
Get a list of students in specific course: /courses/<code>/<section>/students OR /students/show?code=cs100&section=1
The first, same reason as the previous one.
I have given REST API talks at the last two PyCon conferences, feel free to check them out if you want to learn more API design best practices:
PyCon 2014: Writing RESTful Web Services with Flask
PyCon 2015: Is Your REST API RESTful?

How can I deep link into QuickBooks Online with results from API calls that don't include the txnId

QuickBooks Online (QBO) uses a URL format like qbo.intuit.com/app/timeactivity?txnId=123 to point to, in this example, a TimeActivity.
However, in the API, resources are referenced by entityId (returned as just Id when querying via the TimeActivity API), which is different from txnId.
In my time tracking web app, I have a feature that exports time to QBO as TimeActivities. I'd like to provide users with direct links from the time entered in my app to the corresponding TimeActivity in QBO—is there any way to do so?
The answer to this is that it's not currently possible because there's multiple base URLs (I think they call them "realms") in use for QuickBooks Online (qbo.intuit.com is only one of them). Because you do not receive this information as part of linking to QBO via OAuth, there's unfortunately no way to construct proper links.
Yes, when creating a successful TimeActivity you will receive back an Id, which I assume you are persisting.
That Id can be used to query QBO in a simple GET request.
<baseURL>/company/{companyID}/timeactivity/{timeactivityId}

how to display Google Plus average rating on my website?

I want to put Google+ badge of a business on my page. I can get code for it using Google Developer website: https://developers.google.com/+/web/badge/#badge
But i do not understand how to get average score and number of reviews so I can feature them on my website as well - something similar to what you get when you search for a place:
for example, here is a restaurant's Google+ page: https://plus.google.com/106659611775440325701/about?hl=en - it clearly displays all those reviews and scores. How to get this information from Google? Is there a way to modify badge's code to include them?
Reviews data is part of the Places API. There are a couple of options for getting them on your site.
The Maps Embed API would be the easiest but requires loading a map on your page.
Using the Maps JS API v3 you can load and render place details client side.
Using the HTTP API you can load details on your server to cache in a DB and render on page load.
UPDATE May 2019: it is possible now to get total number of reviews using Place Details Place APIs call: https://developers.google.com/places/web-service/details#fields
as of Jan 2019, it returns user_ratings_total field: https://developers.google.com/maps/documentation/javascript/releases#335
so looking at this again 3 years later, we still can't get all reviews for a place. We can get some - top 5 - using Place Details API call: https://developers.google.com/places/web-service/details
then there is a change request for Google team to extend this: https://issuetracker.google.com/issues/35825957
And finally, you can apply for Google Business Account and request access to extended API which allows you to get all reviews for a verified location: accounts.locations.reviews.list

What is the maximum results returned for YouTube Data API v3 call

Context
I am in the process of providing some consultancy on doing a HTTP GET using YouTube Data API V3; in order to develop a Windows based application to GET a list of results from Youtube, for say a specific CATEGORY, or a specific TAG.
We are open to using any programming language(I'm from a C++ background and am hoping You tube will support direct HTTP connections without using Google client SDK and so on) to connect to YouTube and (HTTP) GET data.(Once a month or so, so YouTube API quotas should not be problem).
The Issue
We are being told by some of my client's web developers that YouTube API v3 will only return a maximum of 500 records/results, for say a query that returns JUST the Total viewers, the Video's link, and basic meta data such as that.
S, say I wish to find 5,000 results for category "House music" or "basketball" - and I have the Developer Key etc are all set up, would that be possible?
If so, what GET fields would I need to populate(such as "max_results_per_page")?
Thank you.
The API won't provide more than ~500 search results for any arbitrary query. It's by design. Technically, it means that the nextPageToken field won't be returned once you hit ~500 results. No additional parameter can change that.
If you want more than ~500 results for a query, you have to split it into more specific sub-queries. I'd suggest using the publishedAfter and publishedBefore parameters to achieve that, but feel free to experiment with the other ones here.
This only holds for the search-Query. Other queries like "PlaylisItem:list" deliver more results. I have tested with 100.000 items to get the videos of a playlist.

BigCommerce JavaScript API

In BigCommerce, can I access the current customer's record using JavaScript?
I want to change something on the product page based on the customer group that the current customer is in.
there is no JS SDK yet for Bigcommerce. However, because the APIs are restful, you should be able to execute a simple GET request to get a customer's record. The only challenge is that you need to get the customer ID/info when they login to the store and then get their record.
There is an example on Bigcommerce forums on using Javascript to hide pricing for customers who are not logged in.
http://forum.bigcommerce.com/f4/global-variable-for-current-user-s-group-1815/index2.html
This combined with GET request on the customer endpoint (http://developer.bigcommerce.com/api/customers) should get you moving in that direction.
Does this help? Are you looking for a code sample?
Use Javascript or jQuery to do the IF statement.
Then use Ajax to request the data that you want to display to the user.
So to answer your question, directly with Javascript you can't, but combine it with some PHP and then you use the API to do what you would like.
Hope this helps :)