Vimeo API - Get categories and credits - api

I'm doing a script that takes a video ID from Vimeo, calls the API and populate the database with all the data we need.
I'm able to get all the fields and everything is working well using that url:
https://api.vimeo.com/videos/{video_id}
I can also use the query ?fields=name, etc... To only get the fields i need.
But when i make that request to the API (even when i use the fields query), the categories array is empty and the credits are returned as this:
"credits": {
"uri": "/videos/{video_id}/credits",
"options": [
"GET",
"POST"
],
"total": 1
}
If i make another request, to those url:
https://api.vimeo.com/videos/{video_id}/credits
https://api.vimeo.com/videos/{video_id}/categories
I get all the info i need about the credits and categories.
The problem is: i do not want to make 3 request to the API to get everything i need. Why are the credits and categories not included in the original video request?
Is there a way i can do it with one call?

Regarding categories, the video may not be categorized, either by the video owner or a Vimeo Curator. When a video has not been categorized, the categories array will return empty.
For example, this test video returns no categories:
curl -X GET
'https://api.vimeo.com/videos/76979871?fields=uri,categories'
-H 'Accept: application/vnd.vimeo.*+json;version=3.4'
-H 'Authorization: bearer [token]'
While this Staff Picked video returns several categories and subcategories:
curl -X GET
'https://api.vimeo.com/videos/274849065?fields=uri,categories.uri,categories.uri,categories.name,categories.top_level'
-H 'Accept: application/vnd.vimeo.*+json;version=3.4'
-H 'Authorization: bearer [token]'
Regarding credits, a video will always have a minimum of one credit (the video owner). I suggest adding some logic so that if metadata.connections.credits.total is greater than 1, then make the additional request to get those other credited users.
For instance, this same Staff Picked video returns metadata.connections.credits.total=2, so to get the additional credited user, you'll need to make a request to the video's credits endpoint.
curl -X GET
'https://api.vimeo.com/videos/274849065?fields=uri,metadata.connections.credits'
-H 'Accept: application/vnd.vimeo.*+json;version=3.4'
-H 'Authorization: bearer [token]'
The reason for the separate endpoint for credits is that each user object can contain a lot of metadata -- if a video credits many users, the video response (which is already quite large) can be even bigger if the fields parameter isn't used.
I hope this information helps!

Related

twitter API: query tweets with conversation id

I was using the following code in the terminal to search for all the tweets in the given conversation:
curl --request GET \
--url 'https://api.twitter.com/2/tweets/search/recent?query=conversation_id:107679773517545473&tweet.fields=in_reply_to_user_id,author_id,created_at,conversation_id' \
--header 'Authorization: Bearer $bearertoken'
But I got the following result(I also tried conversation id from twitter's example 1279940000004973111 with the same result)
{"meta":{"result_count":0}
I don't know why.Is that because I don't have an academic license?
/recent only gives you tweets that are less than 1 week old. That means, even if you have multiple tweets with same conversation id, you only get tweets that are less than 1 week old. That is why you are getting {"meta":{"result_count":0}. Probably you will need to have academic access. Haven't found any other ways to get old tweets on Internet.

Using Postman Code in Unreal Engine VARest?

I'm trying to learn how to use VARest in Unreal Engine. But every tutorial uses a single URL and not a JSON input by using "Construct Json Object". My API has multiple functions, and I'm trying to use the one called "readPlayerWallet". When I view the cURL code generated by Postman, I get this:
curl --location --request
POST '---' \
--header 'Authorization: ---
--header 'Content-Type: application/json' \
--data-raw '{"query":"query readPlayerWallet ($playerGameId: String!, $network: String)
{\n readPlayerWallet (playerGameId: $playerGameId, network: $network) {\n
wallets {\n id\n type\n publicKey\n
privateKey\n createdAt\n balance\n }\n info {\n
status\n message\n }\n }\n}","variables":
{"playerGameId":"idtest","network":"---"}}'
And Postman returns a JSON file that ends with
"message":"success"}}}}
So my Unreal blueprint looks like this (Set Text's exec is connected to RestCallback, it just broke while I was taking the screenshot):
But the text disappears, and doesn't trigger isNull, so I guess it's just empty.
Why? How do I solve this?
Firstly, pull the response node and convert that to string using "to string". This will help you to check if you are getting the complete json file first.
I can't say for sure without looking at the full json file. Have you checked if the message field is directly the child of the response object or if its within an array field or another object field. If by hierarchy it has a parent array or object, you have to call it first...then from that object you have to use "get string field."
Next, check if the json is of the supported format. For example: Nested arrays are not supported by Varest.

Recieving an "errorCode: ERROR_RESOURCE_GONE" when trying to send play command

I have been trying to figure out the sonos api over the past few days, but unfortuanetly have hit a road block. I have already gotten my tokens and room names and and favorites Id, but when I send the curl request to play a song I get the error described above.
Curl Code :
curl -X POST -H "Content-Type: application/json" -H "Authorization: Bearer {TOKEN}" "https://api.ws.sonos.com/control/api/v1/groups/RINCON_48A6B88A5B14014XX:XXXXXXXXXX/favorites" --data #play.json
I keep the body in a .json file called play which contains the code:
{
"favoriteId":2,
"playOnCompletion":true
}
I have not been able to find any documentation on this issue online, so any and all help is very appreciated.
The "ERROR_RESOURCE_GONE" HTTP 410 response indicates that the
groupID you are using in your request (RINCON_48A6B88A5B14014XX:XXXXXXXXXX) no longer exists. Group IDs are not static and may change depending on a number of factors - grouping and ungrouping, power cycling, etc.
If you re-run the request to get groups, you should get an up-to-date list of group IDs. Try doing that and using a returned Group ID in your favorites request.
The "Subscribe" section of the documentation describes how to automatically listen for group ID changes: https://developer.sonos.com/build/direct-control/connect/
Have you made sure that the groupId or the favoriteId are still valid? Based on the ERROR_RESOURCE_GONE, it seems one of those has likely changed.

Cannot access form data in GET request

I've been trying to make a GET request to an endpoint defined in a ktor route, but the parameters seem to be missing no matter how I try to get them. According to the documentation, I should just be able to call call.receive<Parameters>() and that should yield a map containing the data, but it's always empty.
So Far, I've tried installing my own ContentNegotiator (the convertForReceive method is never called), accessing the queryParams (always empty as well), and using the call.receiveParameters() method, which is always always empty
My CURL request looks like
curl -X GET \
http://localhost:7802/api/v2/plans \
-H 'Content-Type: application/x-www-form-urlencoded' \
--data-urlencode "id[starts_with]=asdf"
and my endpoint looks like
fun Routing.plans() {
route("plans") {
get("") {
val params = call.receive<Parameters>()
println(params)
call.respond(HttpStatusCode.NoContent)
}
}
}
I expect the parameters to contain something, but they are always empty.
I think that you won't be able to use have a body with a GET request. With that HTTP verb, most servers do not recognize a body. If you want to send a body, I'd recommend trying to change your GET request to a POST.
I think that should get you where you need to go.

How do I get all the toots in Mastodon API to delete them?

How can I get all the toot IDs that I've tooted?
I want to delete all of my toots (status posts) at Mastodon but can't get all the toots.
It would be easier if I delete my account, though I want to keep my account alive and clean up all the mess that my NEWS-BOT did.
It seems that currently, Mastodon doesn't have the ability to delete all the toots as a standard feature.
So I tried to delete them using the Mastodon API recursively as below, but couldn't get all the Toot IDs (Status IDs) for deletion.
GET Toot IDs from /api/v1/timelines/home endpoint.
curl -X GET --header 'Authorization: Bearer <ACCESS_TOKEN>' -sS https://sample.com/api/v1/timelines/home
DELETE a toot at /api/v1/statuses endpoint with Toot IDs that I got.
curl -X DELETE --header 'Authorization: Bearer <ACCESS_TOKEN>' -sS https://sample.com/api/v1/statuses/<Toot ID>
Loop 2 then 1 until empty.
It cleaned up the home timeline. But many toots were left on the public profile page. I also tried to get the IDs from the ATOM feed but didn't help.
All I need is the list of my Statuses IDs that I'd tooted. Any ideas?
Current Conclution
As of #unarist's advice,
API endpoint
https://sample.com/api/v1/accounts/<account id>/statuses
GET /api/v1/accounts/:id/statuses
will do the fetching.
Though, there are 3 points to be noted:
By default, this API method gives you only 20 status(toot info) and max 40.
Authorized API request are limited to 300 requests / 5min (1 request/sec).
Therefore, you can delete NO more than 84,240 toots/day.
It seems that I had over requested and couldn't get the info I needed. So better be careful about the server's message! (>_<)/
Have a good Mastodon time!
Home timeline contains not only your posts but also posts from your followings, and the server only keeps recent posts (400 items by default) of each home timeline. Therefore, you cannot enumerate all your posts from it.
Use account statuses API with your account id:
https://sample.com/api/v1/accounts​/<account id>/statuses
This API is what WebUI uses on your profile page (/web/accounts/xxx).