Spotify API field filtering - spotify

I'm trying to use field filtering to pick out specific nested fields, and it seems to me like I'm hitting a limit for nesting.
Here's the filter I'm using: items(date_added, track(name, album(artists(name))))
and here's the curl command I'm trying (built with the new developer console):
curl -X "GET" "https://api.spotify.com/v1/users/<user_id>/playlists/<playlist_id>/tracks?fields=items(date_added%2C%20track(name%2C%20album(artists(name))))" -H "Accept: application/json" -H "Content-Type: application/json"
This call works and everything looks good until it gets to the artists field. It doesn't seem to be filtering down artist fields. I just want the artist name in this case. Here's a snippet of what I'm getting back:
"items": [
{
"track": {
"album": {
"artists": [
{
"external_urls": {
"spotify": "https://open.spotify.com/artist/3t69c5VItBx3GCrnkcYHEL"
},
"href": "https://api.spotify.com/v1/artists/3t69c5VItBx3GCrnkcYHEL",
"id": "3t69c5VItBx3GCrnkcYHEL",
"name": "Imagined Herbal Flows",
"type": "artist",
"uri": "spotify:artist:3t69c5VItBx3GCrnkcYHEL"
}
]
},
"name": "Floating"
}
}...
];
As you can see, I'm getting the full artist object. Can someone help me understand why I can't filter the fields for that?

Related

Not able to filter the record from Azure Search based on specific key within indexed json data

I have populated Azure search data using my application and this is what is present in Search Explorer in portal.azure.com.
{
"#odata.context": "https://demosearch.search.windows.net/indexes('<indexname>')/$metadata#docs(*)",
"value": [
{
"#search.score": 1,
"id": "31",
"code": "C001105",
"title": "Demo Course Title 1",
"creator": "FILE_UPLOAD",
"events": [
{
"eventId": 97,
"eventStatus": "PLANNING",
"evtSession": [
{
"postCode": "AB10 1AB",
"townOrCity": "Aberdeen City,",
"dates": {
"from": "2022-08-11T08:00:00Z",
"to": "2022-08-11T11:00:00Z"
}
}
]
}
]
},
{
"#search.score": 1,
"id": "45",
"code": "C001125",
"title": "Demo Course Title 2",
"creator": "FILE_UPLOAD",
"events": [
{
"eventId": 98,
"eventStatus": "IN_PROGRESS",
"evtSession": [
{
"postCode": "BA10 0AN",
"townOrCity": "Bruton",
"dates": {
"from": "2022-08-11T08:00:00Z",
"to": "2022-08-11T09:30:00Z"
}
}
]
}
]
}
],
"#odata.nextLink": "https://demosearch.search.windows.net/indexes('<indexname>')/docs?api-version=2019-05-06&search=%2A&$skip=50"
}
I'm trying below curl to get data where ["townOrCity": "Aberdeen City,"] from Azure search.
curl --location --request POST 'https://demosearch.search.windows.net/indexes/<indexname>/docs/search?api-version=2019-05-06' \
--header 'api-key: XXXX' \
--header 'Accept: application/json' \
--header 'Content-Type: application/json' \
--data-raw '{"count":false,"top":0,"skip":30,"search":"*","orderby":"search.score() desc","filter":"( events/any(evt: evt/evtSession/any(session: search.in(session/townOrCity, '\''Aberdeen City,'\'', '\'','\'') ) ) )","facets":["events/evtSession/townOrCity,count:10000"],"queryType":"full","searchMode":"any"}'
but I'm not getting expected response and value is coming as empty array :
RESPONSE
{
"#odata.context": "https://demosearch.search.windows.net/indexes('<indexname>')/$metadata#docs(*)",
"#search.facets": {
"events/evtSession/townOrCity": []
},
"value": []
}
Please help with the correct payload I should be using to filter out the record with "townOrCity" : "Aberdeen City," OR am I doing something wrong with indexing config or anything ?
"townOrCity" : "Aberdeen City,"
Edit 1:
NOTE: comma mentioned after Aberdeen City causes the issue. If I try same thing witout the comma everything works like a charm. But requirement is to support the comma.
$filter=( events/any(evt: evt/evtSession/any(session: search.in(session/townOrCity, 'Aberdeen City,', ',') ) ) )
there is data present in index but still its not applying filter properly, instead giving no record in response.
This works :
$filter=( events/any(evt: evt/evtSession/any(session: search.in(session/townOrCity, 'Aberdeen City,', '|') ) ) )
There are two overloads of the search.in function:
search.in(variable, valueList)
search.in(variable, valueList, delimiters)
Due to delimeters, comma inside my valueList was removed and hence actual value got changed. Apparently its an exact-match so empty response returned.
https://learn.microsoft.com/en-us/azure/search/search-query-odata-search-in-function

Is there a function to list all SPL Tokens in a Wallet using Rust

Is there a function which can get a list of all tokens a wallet owns using Rust?
There is an JsonRPC EndPoint on Solana : getTokenAccountsByOwner
Returns all SPL Token accounts by token owner.
https://docs.solana.com/developing/clients/jsonrpc-api#gettokenaccountsbyowner
curl http://localhost:8899 -X POST -H "Content-Type: application/json" -d '
{
"jsonrpc": "2.0",
"id": 1,
"method": "getTokenAccountsByOwner",
"params": [
"4Qkev8aNZcqFNSRhQzwyLMFSsi94jHqE8WNVTJzTP99F",
{
"mint": "3wyAj7Rt1TWVPZVteFJPLa26JmLvdb1CAKEFZm3NY75E"
},
{
"encoding": "jsonParsed"
}
]
}
'
I also think there is a way to make calls to endpoints from smart contracts, you should look around for this

Creating invoices in bulk using NetSuite REST API

Is there a way to create multiple invoices with a single POST request to the NetSuite REST API?
The API Reference doesn't mention anything - but I'm hoping there's a way to avoid sending thousands of individual requests.
I am creating a single invoice like this (some headers have been removed):
curl --location --request POST 'https://{{COMPANY_URL}}.suitetalk.api.netsuite.com/services/rest/record/v1/invoice' \
--header 'Content-Type: application/json' \
--data-raw '{
"entity": {
"id": 46
},
"item": {
"items": [
{
"item": {
"id": 134
},
"amount": 20
}
]
}
}'

YouTube Search.list: big 'totalResults' property and no items in response

I'm a novice user of YouTube Data API. Am interested in the method Search.list and tried it as follows:
curl \
'https://www.googleapis.com/youtube/v3/search?part=snippet&maxResults=50&publishedAfter=2020-01-01T00%3A00%3A00Z&publishedBefore=2020-01-01T00%3A01%3A00Z&q=Nemo&type=video&key=[YOUR_API_KEY]' \
--header 'Authorization: Bearer [YOUR_ACCESS_TOKEN]' \
--header 'Accept: application/json' \
--compressed
The JSON response provided was:
{
"kind": "youtube#searchListResponse",
"etag": "r_b6korptu_RtbUGCZrdsQokN6M",
"nextPageToken": "CDIQAA",
"regionCode": "RU",
"pageInfo": {
"totalResults": 263644,
"resultsPerPage": 50
},
"items": []
}
I'm wondering about how could the value of totalResults be 263644 when there are no items in the result set?
Is it possible that between the dates of 2020-01-01T00:00:00Z and 2020-01-01T00:01:00Z a number of 263644 videos related to the search key Nemo were published?
A similar question was asked on this forum, yet, upon years having passed, no answer emerged.
First thing to acknowledge is that the property totalResults is not reliable by its very specification (the emphasis below is mine):
pageInfo.totalResults (integer)
The total number of results in the result set. Please note that the value is an approximation and may not represent an exact value. In addition, the maximum value is 1,000,000.
You should not use this value to create pagination links. Instead, use the nextPageToken and prevPageToken property values to determine whether to show pagination links.
This peculiarity of totalResults was already mentioned within the question you quoted above and is also confirmed officially by Google's staff.
To confirm myself the statement emphasized above, I did call Search.list on your very same URL and obtained the following JSON response:
{
"kind": "youtube#searchListResponse",
"etag": "nR1UCL5Kru9VxHzZ2DnocjjIfjk",
"nextPageToken": "CDIQAA",
"regionCode": "...",
"pageInfo": {
"totalResults": 268418,
"resultsPerPage": 50
},
"items": []
}
Moreover, repeating the same API call several times in a row (only seconds apart one from another), I never got the same value of totalResults, yet always got an empty items array.
There's only one thing to learn from here: between the two date-time values (2020-01-01T00:00:00Z and 2020-01-01T00:01:00Z), there's no video that matches the query term Nemo.
If only changing publishedBefore to 2020-01-01T01:00:00Z -- thus using the following URL:
https://www.googleapis.com/youtube/v3/search?part=snippet&maxResults=50&publishedAfter=2020-01-01T00%3A00%3A00Z&publishedBefore=2020-01-01T01%3A00%3A00Z&q=Nemo&type=video&key=...
for invoking the same endpoint --, the JSON response obtained contains an items array of only one element:
{
"kind": "youtube#searchListResponse",
"etag": "w5YKbVnLAwAFSmESM0ZoCCtvHo0",
"nextPageToken": "CDIQAA",
"regionCode": "...",
"pageInfo": {
"totalResults": 255015,
"resultsPerPage": 50
},
"items": [
{
"kind": "youtube#searchResult",
"etag": "qoMGew0LKTvIT7PdH6o7vJ8Ob9s",
"id": {
"kind": "youtube#video",
"videoId": "YU2sbTlAxLk"
},
"snippet": {
"publishedAt": "2020-01-01T00:33:51Z",
"channelId": "UCgMTHBAZjC6mkq257UseEzQ",
"title": "YANDA ZAKA NEMO NAMBOBIN WAYAR KA DA SU KA BACE",
"description": "Ta yanda zaka nemo Lambobinka da suka Bace ================================== Ga link din da zaku shiga ...",
"thumbnails": {
...
},
"channelTitle": "kk Techtube",
"liveBroadcastContent": "none",
"publishTime": "2020-01-01T00:33:51Z"
}
}
]
}
If publishedBefore is set to 2020-01-01T00:34:00Z, then the result set is identical with the one above.
These tests seem to indicate that Search.list works OK w.r.t. the issue you have risen.

api call to upload an image to object storage container on bluemix node js app

Iam trying to upload an image to object storage container and get the url of that image deployed on bluemix using a node js app.To achieve this i need to use a post or put api call.I could able to authenticate with the object storage but not able to achieve the functionality through the api calls.So,I need some help on the api calls.So can some one help me out in this if you had worked on such kind of api calls with images on object storage.(using object-storage npm).Even share any kind of sample working api calls.Any help appreciated.
Object storage api's are derived from the OpenStack Swift API spec. In order to add an object of any sort to a Bluemix Object Storage container, you'll need to do 2 things:
Authenticate to the Object Storage instance to obtain an authorization token.
Perform actions on the container using the token obtained.
I assume that you already have access to the JSON credentials provided by the object storage service ... similar to:
{
"auth_url": "https://identity.open.softlayer.com",
"domainId": "nice_long_hex_value",
"domainName": "some_number",
"password": "not_gonna_tell_you",
"project": "object_storage_hex_value",
"projectId": "project_hex_value",
"region": "dallas",
"userId": "another_fine_hex_value",
"username": "some_text_with_hex_values"
}
Step 1: Obtain X-Auth-token. 4 items (user_id, user_name, password and auth_url) should come from your provided credentials.
curl -i -X POST -H "Content-Type: application/json" -H "Cache-Control: no-cache" -d '{
"auth": {
"identity": {
"methods": [
"password"
],
"password": {
"user": {
"id": "another_fine_hex_value",
"password": "not_gonna_tell_you"
}
}
},
"scope": {
"project": {
"id": "project_hex_value"
}
}
}
}' "{auth_url}/v3/auth/tokens" | tee response.txt | grep X-Subject-Token | sed 's/.*X-Subject-Token: \([^ ]*\).*/\1/g' | tee >(awk '{printf("\nX-Auth-Token: %s\n\nJSON Response Body:\n", $0)}' > /dev/tty) | sed -n '/{/,$p' <response.txt | python -m json.tool && rm response.txt
This should result in a 500+ Line JSON Response BODY (take note of the public interface for the region of dallas within the swift endpoints array) similar to …
{
"token": {
"methods": [
"password"
],
"roles": [
{
"id": "redacted",
"name": "ObjectStorageOperator"
}
],
"expires_at": "2016-03-09T20:26:39.192753Z",
"project": {
"domain": {
"id": "some_hex_value",
"name": "some_int"
},
"id": "another_hex_value",
"name": "one_more_hex_value"
},
"catalog": [
...
{
"endpoints": [
{
"region_id": "london",
...
},
{
...
},
{
"region_id": "dallas",
"url": "https://dal.objectstorage.open.softlayer.com/v1/AUTH_",
"region": "dallas",
"interface": "public",
"id": "some_unique_id"
},
{
...
},
{
...
},
{
...
}
],
"type": "object-store",
"id": "hex_values_rock",
"name": "swift"
},
...
],
"extras": {},
"user": {
"domain": {
"id": "hex_value",
"name": "another_fine_int"
},
"id": "tired_of_hex_values_yet?",
"name": "cheers_one_more_hex_value_for_the_road"
},
...
}
}
Specifically, we want to identify the Swift Object Storage API url in the form:
https://dal.objectstorage.open.softlayer.com/v1/AUTH_some-hex-value
https://dal.objectstorage.open.softlayer.com/v1/AUTH_some-hex-value is
linked to your desired object storage region (dallas, london, …) and associated with a public interface. This will be found within the endpoints section which includes the name “swift”.
Even more importantly, within the generated HTTP Response Header of this /v3/auth/tokens call is an authentication token that we also need to record to facilitate subsequent authenticated HTTP API calls.
Here is a sample of the HTTP Response Headers
Connection: Keep-Alive
Content-Length: 12089
Content-Type: application/json
Date: Wed, 09 Mar 2016 19:26:39 GMT
Keep-Alive: timeout=5, max=21
Server: Apache/2.4.6 (CentOS) OpenSSL/1.0.1e-fips mod_wsgi/3.4 Python/2.7.5
Vary: X-Auth-Token
X-Subject-Token: gAAAAABW4Hjv5O8yQRwYbkV81s7KC0mTxlh_tXTFtzDEf3ejsP_CByfvvupOeVWWcWrB6pfVbUyG5THZ6qM1-BiQcBUo1WJOHWDzMMrEB5nru69XBd-J5f5GISOGFjIxPPnNmEDZT_pahnBwaBQiJ8vrg9p5obdtRJeuxk7ADVRQFcBcRhAL-PI
x-openstack-request-id: req-26a078fe-d0a7-4a75-b32d-89d3461c55f1
The X-Subject-Token is the important response header. Its value will be reused within all subsequent HTTP Request Headers using the header X-Auth-Token. Obvious, right?
Step 2: With this token, let's add an object to a container named "ibmjstart".
curl -s -X PUT -i -H "Content-Type: text/plain"\
-H "X-Auth-Token: X-Subject-Token from above"\
-H "Cache-Control: no-cache"\
-d "Awesome sauce is best served warm" "{API AUTH URL obtained above}/ibmjstart/test.txt"
If all goes well, this should result in a new container named ibmjstart which contains a text file named test.txt with a single line of content.

Resources