How can we loop over drive changes upto a pageToken? - google-drive-api

I have to retrieve my file changes upto a particular time.i can see Google provide drive changes api which will give me changes after any start page token. But the requirement is to get history changes...can anyone please help me in this

Changes are always tracked relative to a start token, that's how the service works.
In other words, what you want to do is not possible.

You first need to call getStartPageToken and track changes from that moment, there is no other way around it. Otherwise there are no changes to track.
Depending on what specific information do you want to track, Revision methods might get you what you want. For each file you can get a list of historical Revisions by calling Revisions.list and for each individual revision you can get information like modified time, modifying user or links to the version of the file by calling Revisions.get.
I hope this is of any help.

Related

How to get last modified date of folder inclusive of changes to child folders/files with Google Drive API

I created a dropdown in my application that displays folders in a Google Drive based on a user's search. The dropdown shows both the name of the folder and the last modified date. However, Google does not update the last modified date of the parent folder when any of it's child folders/files are modified, it only updates in response to direct modifications to that specific folder. I've thought of two possible solutions, but I'm not really of fan of either and am looking for some other more performant/efficient solutions.
For example,
After receiving the results from the user's query I could iterate over each result (i.e. each parent folder) and fetch a list of all it's children and then iterate through the last modified date for each child to return the most recent date. However, performing this on each autocomplete query would be slow and degrade the user experience as the user would have to wait for a few seconds after typing before the results load.
I could have a separate background process outside of my application that runs every 1 minute and checks for file changes using the Changes: list resource and filters the changes that are related to the root folder where the dropdown options live. However, to do this I need to recursively travel up the parent tree to get to the root folder for each change because only the direct parent (not other ancestors) are accessible in the "parents" property of the File resource. I'd have to do this for each change just to determine if the change was related to a subfolder/file of the root folder (2-3 levels up). Which means each change would require another 2-3 api requests just to determine if it is even relevant. Keep in mind the number of changes in the change list is quite large.
Both of these solutions while viable seem pretty inefficient to me. Does anyone have a better suggestion as to how I can achieve this objective?

How to not detect opening of files and folders in google drive changes api

I am building an expressjs application using the google drive api that notifies the user whenever there is a file change in their google drive through webhooks. However, i am also receiving webhooks when i open/view a folder or a file, which is completely unnecessary. Is it possible to only receive webhooks whenever a new file is created or deleted in the drive? And if so, how do i do it?
There is no direct way unfortunately.
You will likely have to make another request once your app has been notified of a change. Its possible you may have to persist some data to compare with depending on what you need to do exactly. The watch endpoint, as you have seen, will notify you of almost every change, including views. So you'll need to find a way to filter these out.
If you are trying to get create/deleted times only then I would suggest taking the file id from the change notification and making a request to get the file metadata and seeing if the file was created in the last 5 minutes (or less) for example. You can speed this up by only getting the createdTime field for instance.
For deleted, you can either get the type of change directly from the change notification, but this will only notify you if you have deleted it permanently i.e. not in the trash. Trash events look just the same as the others. If you need trash notifications, it is going to be more complicated. There is a trashed attribute, but not a timestamp for it. If you need this then you will probably have to keep a snapshot of which files are trashed and then every time you get a request, check to see if the file that changed is now trashed.
There is an active feature request for this
Support event type filtering for Changes watch channel
Go and give it a ☆ to let Google know that you want this feature!

Forge API: Get all changed items

I need to get a list of all changed items in my project in BIM 360. Can I do this using forge-api.
Ho, regarding with the latest question [If my service is not available and I will miss some webhook events, how can I get all the changes that were made after the last webhook event received] :
If your requirement is to know which items are changed in one folder of Docs, Search API with filter can be of use. e.g. the endpoint below will return all items which are updated since a certain time.
https://developer.api.autodesk.com/data/v1/projects/{{project_id_with_b}}/folders/{{one_folder_id}}/search?filter[attributes.lastModifiedTime]-ge=2019-10-15
More filters options are described at
https://forge.autodesk.com/en/docs/data/v2/developers_guide/filtering/
While if you wanted to know all updates in one call, I do not see currently the way is available. While, Activity API is on the way, it might be helpful to know all activities during a certain dates, then you could filter out what you are interested in and locate the corresponding module>>files/resources etc.. but Activities may probably be categorized with specific scopes e.g. admin activities, project actives, issue activities etc. so it is not one call knows all updates.. And these APIs may not be exposed in the same time.

Would it be possible to scrape data from Airbnb directly into a Google Sheet?

I'm trying to build a super simple Google Sheet dashboard comparing the prices at D+7 and D+30 in real-time of specific listings/rooms that are both on Airbnb and Booking.com.
On the Booking.com side, it was super easy : I just created a formula concatenating the URL with the check-in/check-out dates, number of guests and trip duration as parameters and using the =IMPORTXML function and the proper class, I was able to automatically retrieve the price.
It is more difficult on Airbnb, as the price is dynamic(see here: https://www.airbnb.com/rooms/25961741). When I use what I think is the proper class, I get a "N/A Error, Imported content is empty" on Google Sheet.
I also tried using the Airbnb API with REGEX functions to extract the price, but the price set in the listing info is a default price, and does not reflect reality:
"price":1160,"price_formatted":"$1160"
https://api.airbnb.com/v2/listings/25961741?client_id=d306zoyjsyarp7ifhu67rjxn52tv0t20&_format=v1_legacy_for_p3&number_of_guests=1
Do you now if there are any other possible way to access this dynamic price and have it automatically parsed into a spreadsheet? It seems that the data I'm looking for in within meta tags on the HTML code and I don't know if it's possible to scrape it into Google sheet using =IMPORT functions.
Maybe with of a script ?
Thanks a lot !
I'm curious if you were unable to yank direct with the ABNB API; what if you tried to directly pull off the site's service? Have a look at this URL:
https://www.airbnb.com/api/v2/explore_tabs?version=1.3.9&satori_version=1.0.7&_format=for_explore_search_web&experiences_per_grid=20&items_per_grid=18&guidebooks_per_grid=20&auto_ib=false&fetch_filters=true&has_zero_guest_treatment=false&is_guided_search=true&is_new_cards_experiment=true&luxury_pre_launch=false&query_understanding_enabled=true&show_groupings=true&supports_for_you_v3=true&timezone_offset=-240&client_session_id=8e7179a2-44ab-4cf3-8fb8-5cfcece2145d&metadata_only=false&is_standard_search=true&refinement_paths%5B%5D=%2Fhomes&selected_tab_id=home_tab&checkin=2018-09-15&checkout=2018-09-27&adults=1&children=0&infants=0&click_referer=t%3ASEE_ALL%7Csid%3A61218f59-cb20-41c0-80a1-55c51dc4f521%7Cst%3ALANDING_PAGE_MARQUEE&allow_override%5B%5D=&price_min=16&federated_search_session_id=5a07b98f-78b2-4cf9-a671-cd229548aab3&screen_size=medium&query=Paris%2C%20France&_intents=p1&key=d306zoyjsyarp7ifhu67rjxn52tv0t20&currency=USD&locale=en
This is a GET request to ABNB's live page search; now I don't know much about ABNB but I can see from the listings portion of the JSON feed it does have a few pricing factors that differ from the API results you provided; I'm not sure what you need to pull exactly but this may lead you in the right direction; check the 'Listings' array and see if there's something you can possibly use.
Keep in mind if you are looking to automate scraping this data you would want to generate new search sessions; but first you want to see if this is the type of data you're looking for.
Another option, Google CSE's API; I've pulled data in the page headers of sites as they appear in Google based on the Schema.org's tags; but this may be delayed data and it appears you need real-time; the best route would be reserach the above example or try to make sure of ABNB's natural API (they provide its functionality for a reason right?; there must be a way to get what you need).
Hope my answer helped lead you in the right direction!

JSON storage via API

I'm hoping to store a JSON file and access it through javascript in a Qualtrics survey. The information does not need to be password protected and I don't want to include any credentials in the Qualtrics survey.
I've been using links to anonymous gists eg. (https://gist.githubusercontent.com/anonymous/591cf9b1dd8fa70d97451cd1569f89be/raw/9984f8f22929d29d6f612189212059bce5157ca4/a_file), but every time I update a gist, that link changes. So, every time I want to change the contents of the gist, I need to copy the new link into the Qualtrics survey Javascript (unfortunately, I can't do this automatically easily in Qualtrics).
I'd like to be able to post the JSON somewhere that I can update programmatically without changing the link. Does anyone have suggests of an API I can use for this purpose? Thanks a lot!
Why not use github's api to get your gist's content by using the gists id.
So for
https://gist.githubusercontent.com/anonymous/591cf9b1dd8fa70d97451cd1569f89be/raw/9984f8f22929d29d6f612189212059bce5157ca4/a_file
the id would be 591cf9b1dd8fa70d97451cd1569f89be and then you can make get requests to https://api.github.com/gists/591cf9b1dd8fa70d97451cd1569f89be. You may need to have public gists though, not anonymous gists to be able to update a gist and use it's id to track changes.