Google Places API filter by "user_ratings_total" number or between range - flutter

I'm trying to figure out a way to filter Places API results by number of user ratings despite the rating score, I've done something like this but it doesn't makes a difference : https://maps.googleapis.com/maps/api/place/nearbysearch/json?location=24.7588310%2C46.7330426&radius=10500&type=restaurant&user_ratings_total=15000&key=GOOGLE_API_KEY.
My actual goal is to have a result similar to (Example: Show list of restaurants with number or total ratings more than 1000 users and rating score with 4.5)
Your assistance is much appreciated.

I don't think the user_ratings_total is used liked that. It is only a value set for place details request and not a parameter itself. The parameter that usually uses it is the fields parameter for place detail request.
The docs says:
"Place Search requests and Place Details requests do not return the same fields. Place Search requests return a subset of the fields that are returned by Place Details requests."
This means that the reviews and ratings that are being returned on your sample request are just a common result from nearby search. In this case "a subset of the fields".
"To return one or more of these data fields for a place, make a Place Details request, pass a place ID, and specify which fields to return."
ref: Place Data Fields docs
A Place Details request looks like this: https://maps.googleapis.com/maps/api/place/details/output?parameters
And fields parameter can be added in this format: fields=user_ratings_total
In summary, user_ratings_total is not used to filter Nearby Search result, but it is used to get more total ratings of a user in a certain Place/POI using Place Details request.
I tried looking through the docs and I can't seem to find this feature on the Places API. So what you can do for now if your really want this feature, is to file a Feature Request on Google Issue Tracker and let it be reviewed by Google engineers if it is possible to be implemented on the API.

Related

Filtering certain coins based upon name with CoinMarketCap

I'm currently attempting to use the CoinMarketCap API but finding it frustrating.
I'm wanting to use this URL to query their API:
https://pro-api.coinmarketcap.com/v1/cryptocurrency/listings/latest
However, rather than finding all, or just simply filtering based upon the number, I want to find a certain few coins.
So for example, I want to only find Bitcoin, Ethereum and Cardano.
Looking at their docs, it suggests you can sort by name, but it appears this is only listing them alphabetically, which I don't want to do.
So can anyone suggest how to query their API successfully and find just Bitcoin, Ethereum and Cardano using that GET URL above?
Here's the URL to the specific URL for the API request: https://coinmarketcap.com/api/documentation/v1/#operation/getV1CryptocurrencyListingsLatest
For this purpose, you can use the endpoint Quotes Latest:
https://pro-api.coinmarketcap.com/v1/cryptocurrency/quotes/latest
It allows you to pass a list of identifiers in a string as a parameter, like this:
1,1027,328
or a list of slugs:
bitcoin,ethereum,monero
or a list of symbols
BTC,ETH,XMR
If you trying to scrape information about new listings at crypto exchanges, you can be interested in this API:
https://rapidapi.com/Diver44/api/new-cryptocurrencies-listings/
It includes an endpoint with New Listings, New Pairs from the biggest exchanges and a very useful endpoint with information about exchanges where you can buy specific coins and prices for this coin at that exchange. It's a bit paid, but it's worth it!

What is the difference between fields and params in the Facebook Marketing API?

Documentation and Code Sample
In the documentation above there are only two parameters.
However, in the code example they are using fields as parameters.
I tried searching the docs but I'm still unclear on how fields and params are different.
Are they completely interchangeable or are there specific times to use each?
I tried searching the docs but I'm still unclear on how fields and params are different. Are they completely interchangeable or are there specific times to use each?
Fields are the specific data elements you can request about an object.
A user’s e-mail address, a post’s message, a page’s cover photo – those are fields.
Parameters allow you to limit the selection of data, based on specific criteria.
You request a page’s feed, but you only want posts from a specific time frame - then you use parameters like since and until, for example.
If you are familiar with basic SQL, you could use this as an analogy: Fields would be the column names you specify after SELECT; Parameters would be the WHERE clause.
I reached out to Facebook Support and this was their answer:
Parameters are inputs to an API that specify constraints on the range
of data that will be returned (time ranges, specific ids etc.). Fields
are what are returned by the API, if you want specific fields to be
returned, these can be specified by adding something like
"fields=id,name..." to an API.
Parameters and fields are not interchangeable.

HTTP request to search for multiple ObjectIds in a Mongo-based API?

I'm looking to add search functionality to an API, on a resource called Organizations. Organizations can have different Location and Audience ids tagged onto them (which I would like to use in searching). Since these ids are MongoDB ObjectIds, they are quite long and I'm worried about reaching the max query string limit of the browser with a GET request. For example:
GET http://my-site.com/api/organizations?locations=5afa54e5516c5b57c0d43227,5afa54e5516c5b57c0d43226,5afa54e5516c5b57c0d43225,5afa54e5516c5b57c0d43224&audiences=5afa54e5516c5b57c0d43223,5afa54e5516c5b57c0d43222
Which would probably be about an average search, however I don't want it to break if users select many Locations or Audiences.
Any advice on how I could handle this situation?
I've ran into your situation before. You can change your method to POST
For a input of locations and audiences, your resource is not already sitting there. You have to compute it.
By the definition of POST:
Perform resource-specific processing on the request payload.
Providing a block of data, such as the fields entered into an HTML
form, to a data-handling process;
You have to compute and create new resource for response. So it's REST-compliance to do so.

REST API best practices: ignoring filter when empty

In the scenario of a users API (/api/users) with a property of team_id, I want to set up an endpoint that allows me to get users with specific team IDs, i.e. /api/users?team_ids=1&team_ids=2&team_ids=3.
My question is, what if I want to ignore this filter?
For instance, if there's a multiselect dropdown in the UI and the user de-selects all team_ids, the expected result would be nothing as they have selected zero teams, and all users are in a team. From an API perspective however, I think it would be reasonable to expect that /api/users would return all users.
You can simply make that parameter required then, so if it doesn't exist the response is an empty array. Or you can limit the amount of users returned

Aggregate data in RESTful API

Have an interesting HTTP API question that I'd like some opinions on. My API allows people to rate things on a 1-10 scale. I have a GET /ratings endpoint that lists a user's ratings. We also want a way to show the user's average rating per day. So my question - should the summary be the same url, like /ratings?data=summary, or should it be its own url like /ratingsummaries or /ratings/summary?
As is often the case, I don't think there is a right answer. Is the summary just another view of ratings, in which case it would be the ratings resource and should be part of /ratings? Or, is a summary of ratings its own resource, in which case it deserves its own url like /ratingsummaries? /ratings/summary looks nice too but it isn't really a sub-resource of ratings.
Looking forward to your feedback. Thanks all!
My opinion is to have it like /ratings/ when ever your are getting back a list of ratings. The search parameters are usually given as #QueryParam. Eg ratings?offset=20&records=50&startDate=xx&endDate=yy
/ratings/{id}/ for one particular rating identified by the id.
/ratings/{id}/votes for getting for votes on the rating.
Rating summary is different entity from rating so it is a candidate for separte url
/ratingsummary?startDate=x&endDate=y
or your path can start with /ratingsummary; it can be like/ratingsummary/ratings?offset=20&records=50&startDate=xx&endDate=yy
In this case you have the rating summary, then you can drill down to the list of ratings that contributed to the summary, then to one particilar rating, etc..
It is ideal to follow a pattern like /entities/{idOfOneEntiity}/{attributeOfEntitiy} etc.