API URL Query to filter the response - arrays

So I'm trying to filter the response of my API GET query and can't seem to find a way to access deep enough in Json.
My response is like:
{
"orders": [
{
"id": "7e35583d-2309-4775-a993-d2277539da2f",
"updated_at": "2022-05-13T22:12:35.426Z",
"created_at": "2022-05-13T22:11:40.194Z",
"properties_attributes": {
"sublocacao": "Sim_Subloc"
},
"price_in_cents": 13500,
"grand_total_in_cents": 0,
"grand_total_with_tax_in_cents": 0,
"tax_in_cents": 0,
.
.
.
And I want to show only responses that have the properties_attributes": {"sublocacao": "Sim_Subloc"}. The others orders id's that doesn't have this property I don't want to show on the result.
I've tried:
https://apixxxxx.com/api/1/orders?sort=number_desc&statuses[]=reserved&properties_attributes=%7B%22sublocacao%22%3A%22Sim_Subloc%22%7D
Without avail.
There isn’t (at least on the documentation) an endpoint for this filter, so I'm trying to filter by myself.
Any hopes of getting it right?
thanks

Related

Solr how to write a facet.query text field value

I am thoroughly confused and lost due to being unable to know what to enter in this facet.query field when using Solr
I want to do a sum of all the documents that are returned, summing up this TotalPaxCount and AdultPaxCount values?
How can I do this using the GUI in the Solr web interface. The very limited examples seem to use curl requests and I have tried what they put in the facet.query and its constantly errors.
I managed to see what the original code was creating and then gave up trying to use the web UI interface! using curl I could make a call like this, in windows I had to put it all on one line like this:
curl http://localhost:8983/solr/mycore/query -d "{\"filter\": \"\",\"query\":\"ResortId:(229) AND ArrivalDate:[2022-10-24T00:00:00Z TO 2022-10-30T23:59:59Z] AND IsActive:True AND *:*\", \"limit\": 0,\"offset\": 0,\"fields\": \"\",\"facet\": {\"ResortId\": { \"type\": \"terms\",\"field\": \"ResortId\", \"limit\": -1, \"minCount\": 0, \"facet\": { \"Total\": \"sum(TotalCount)\", \"AdultCount\": \"sum(AdultCount)\", \"ChildCount\": \"sum(ChildCount)\", \"InfantCount\": \"sum(InfantCount)\" }}}}'
On a linux machine I believe you could do this curl command, which is more readable. I think this helps show the structure that is expect from solr, as was very confusing trying to understand the documentation.
curl http://localhost:8983/solr/mycore/query -d '
{
"filter": "",
"query": "ResortId:(229) AND ArrivalDate:[2022-10-24T00:00:00Z TO 2022-10-30T23:59:59Z] AND IsActive:True AND *:*",
"limit": 0,
"offset": 0,
"fields": "",
"facet": {
"ResortId": {
"type": "terms",
"field": "ResortId",
"limit": -1,
"minCount": 0,
"facet": {
"Total": "sum(TotalCount)",
"AdultCount": "sum(AdultCount)",
"ChildCount": "sum(ChildCount)",
"InfantCount": "sum(InfantCount)"
}
}
}
}'

Get member emails when using delta on group

I'm trying to use the graph API to get a list of users which have been added to a specific group using the delta feature so I reduce the amount of data that passes through.
However, when I $expand on the members property, I'm only getting the id, and not the specific properties I need (mail and some other details) - despite the fact I'm $selecting it.
The url I'm using for the query is
https://graph.microsoft.com/v1.0/groups/delta?$expand=members($select=id,mail)&$select=members&$filter=id eq '<myGroupId>'
And the data I'm getting returned is:
[...]
"value": [
{
"id": "xxxxx-xxxx-xxx-xxx-xxxxx",
"members#delta": [
{
"#odata.type": "#microsoft.graph.user",
"id": "xxxxxxxxxxxxxxxxxxxx"
},
{
"#odata.type": "#microsoft.graph.user",
"id": "xxxxxxxxxxxxxxxxxxxxx"
},
I want my members#delta to include the details of the member so I don't have to query for them seperately.
According this members#delta property contains only the ids of member objects in the group.

Fetch partial documents from couchdb

I'm using couchdb to store large documents, which is causing some trouble when fetching them to memory. I do realize the database is not meant to be used this way. As a fallback solution, is it possible to fetch partial documents from the database, without creating a view?
In example, if a document has the fields id, content and extra_content, I would like to retrieve only the first two.
Thank you in advance.
If you are using CouchDB 2.x, you can use /db/_find endpoint as a mechanism to retrieve part of the doc.
POST /db/_find
{
"selector": {
"_id": "a-doc-id"
},
"fields": [
"_id",
"content"
]
}
You'll get only the set of fields you have specified in the query
This is not possible prior to CouchDB 2.x. For CouchDB 2.x or greater, see JuanjoRodriguez's answer.
But one possible work around for any version of CouchDB would be to take advantage of file attachments, which by default are excluded from a fetch. If some of your data isn't always needed, and doesn't need to be included in indexes, you could potentially store it as (JSON) attachments, rather than as part of the document directly:
{
"id": "foo",
"content": "stuff",
"extra_content": "other stuff"
}
becomes:
{
"id": "foo",
"content": "stuff",
"_attachments": {
"extra_content": {
"content_type": "application/json",
"data": "ZXh0cmEgc3R1ZmYK"
}
}
}

Gmail API how to get labels ThreadsUnread

how can i to get labels ThreadsUnread when excuting LabelsResource.ListRequest?
trying to get the ThreadsUnread property when i'm excuting the Google.Apis.Gmail.v1.UsersResource.LabelsResource.ListRequest
but it comes with null value.
This is my code:
Google.Apis.Gmail.v1.UsersResource.LabelsResource.ListRequest labelReq = service.Users.Labels.List("me");
IList<Google.Apis.Gmail.v1.Data.Label> labels = labelReq.Execute().Labels;
what do i need to ask in the request the ThreadsUnread or MessagesUnread value?
There is a property in the request that called "fields".
it can be set with a string. but where can i find what is the options of that string?
At the time of writing (March, 2019), you cannot get counts when doing a list. You have to subsequently request the details of each label to get the detail. Very slow, costly and frankly unnecessary. The equivalent Microsoft Graph API doesn't have this limitation.
Use the Users.labels.get. In the try-it section do this:
GET https://www.googleapis.com/gmail/v1/users/userId/labels/id
userId:
me
id:
INBOX
and execute, the response would looke something like:
{
"id": "INBOX",
"name": "INBOX",
"messageListVisibility": "hide",
"labelListVisibility": "labelShow",
"type": "system",
"messagesTotal": 1808,
"messagesUnread": 1610,
"threadsTotal": 454,
"threadsUnread": 323
}
and there's the "threadsUnread": 323 you're looking for.

Google Translate get synonyms and examples

Can I access word's synonyms and examples along with the translation itself, when using Google Translate API?
I checked out docs but I don't see anything like that.
No, you cannot get the synonyms and examples along with the translated text.As currently they have only 3 methods in the Translate API.The 3 methods are detections.list, languages.list and translations.list. So i think it would be great if you make a feature request for this API at PIT of AppEngine.
Pearson released their free API which includes examples, part of speech, and synonyms. Check it out: http://developer.pearson.com/apis/dictionaries
http://api.pearson.com/v2/dictionaries/lase%20/entries?headword=hola
{
"status": 200,
"offset": 0,
"limit": 10,
"count": 1,
"total": 1,
"url": "/v2/dictionaries/lase /entries?headword=hola",
"results": [
{
"datasets": [
"lase",
"dictionary"
],
"headword": "hola",
"id": "ct59rx0q97",
"part_of_speech": "interjection",
"senses": [

Resources