Get recent files from folder box api - box-api

I need to get recent files using box API. There is a way to get recent files from a folder on box api? or get top 10 files order by modified at parameter?

Check out the User Events API. This will provide you a list of events that have occurred in a user's Box account. You can limit the query to just those events that result in changes to the account, such as file additions/updates. Further filtering must be done client-side.

Related

Get drive files stats (views/openings) | Google Drive API

I've been searching the docs but I can't find anything.
The goal is to retrieve different stats from our files. Actually, we can retrieve almost everything we need, except for the document openings and document openings per user.
So here is the question: How can I retrieve document views of a drive document (a G Sheet to be more precise) ? Can I segment it by user ?
Thank you
I understand that your goals are the following one:
You want to retrieve document views
Of a particular document (and you know it's id)
Associated to a specific user
Please correct me if I get it wrong. If those are your goals, then you can use the Admin SDK as pointed out by Rubén in the comments. Now I am going to detail how you can make such a request easily.
You could use the method activities.list() to get a list with what you want. You only have to populate these four parameters:
Parameter
Value
Description
userKey
The user's email
Determine the user
applicationName
drive
Identifies the Google service
eventName
view
Designate the type of activity
filters
doc_id=={MY DOCUMENT ID HERE}
Filters by the document
That configuration will provide you with your desired data. Leave a comment below if you need help creating that request in your own environment.

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!

Export the join date for members in a group

Is it possible to export a member's join date to a google group? When you manually export a .csv from a group it gives information on the join date. However, in google app script, I don't see the option for this in the Groups Service. This is the information that is in the .csv:
Any help or resources would be appreciated!
Short answer:
No, you cannot do that programmatically.
Long answer:
Google Groups functionality is mainly handled by Directory API, in its Groups and Members resources. That's what the Apps Script Groups Service is using behind the scenes, and you could use its methods directly by enabling the Admin SDK Directory Service in your script (the APIs —and, as a result, the advanced services— usually have greater functionalities than the Apps Script built-in classes).
If you look at the properties of any of these resources (Groups and Members), you won't find anything close to a join date property, so it doesn't seem to be part of the open API, and can only be accessed through the UI.
The same can be said of Groups Settings API, which can be used to manage group settings: no join date can be found in its resources.
Because of this, you have no way to programmatically store and retrieve the group member's join dates.
Workaround (of a sort):
If you are adding members to a group programmatically, with the API method Members: insert, you could make your application store the date in which each member was added, and retrieve it later. This is not possible, though, if members are added through the UI.
Filing a Feature Request:
Since this resource does seem to exist already (it can be accessed through the UI), I'd suggest you to file a feature request in this Issue Tracker component to make this available to the API. If you do that, please make sure that you explain the usefulness of this functionality (explain how this could help you and, potentially, other users).
Reference:
Directory API: Groups
Directory API: Members
Directory API: Manage Groups

Google Drive SDK, How to check if a file has been shared outside of the domain by using Permission feed

I am using Google Drive SDK for .NET. Everything is working as expected, except that whenever I get the permission feed for a particular document. I get the Id, kind, name, role, selflink and type fields on permission.
There is no mention of the email address of the user which is stopping me from recognizing by reading the permissions, whether a file has been shared inside the domain or outside of the domain.
I can't use Google Docs API to get the ACL on doc because I am writing an app for users over 200000 users and I will need speed which is provided by Google API Console.
What should I do?
Thanks
You can use the Documents List API to get the email addresses. I'm curious why you believe Drive is faster than Documents List, for most API calls they have a comparable response time.
https://developers.google.com/google-apps/documents-list/#retrieving_the_acl_for_a_document_file_or_collection
Thanks for the idea but can I use Document List API with the Service Accounts provided through API Console?
Why do I believe that Google Drive SDK is better? Because we don't have any control over Document List API where we can set QPS (Query per second) limits or not that I know of.
Secondly, with Document List API when you make request to servers, in the past I had to create a fault tollerent algorithm in such a way that if one request fails second should go after 2 seconds if that fails then make your next request after 5 seconds until 7 second delay.
So, I don't think that Document List API would be a good fit for processing documents over 200000 users everyday unless Google has changed the way their API used to behave?

Transfer ownership for ALL files in user's google drive - using google-api-java-client and the Drive SDK

We have a google corporate account and need to transfer ALL of a user's google drive files to another account in certain instances. We want to do what is described at the following link for "all files" but programatically via the latest Drive API http://support.google.com/a/bin/answer.py?hl=en&answer=1247799
We are currently using the following API version(s) below, coupled with domain wide authority delegation as described at https://developers.google.com/drive/delegation and are able to see a user's files, iterate over them etc.
google-api-services-drive 1.14.2-beta
google-api-client 1.14.1-beta
My question is this: it appears that the only way to change permissions is by fileId by fileId etc. Instead of having to traverse and iterate over an entire set of user's files, if we just want to transfer ALL of a user's files to another particular user: is there a way in the API to do this (ownership transfer for ALL files) rather than individual requests file/by file?
Also when transferring ownershisp, must the transferee be in the same #domain or can it be another #domain we manage? I read somewhere that you can only transfer to owners in the same domain. Does this still hold true? For instance we manage #myCompany.com and have our corporate account registered under that, however that shell account has several sub-domains within it. We would like to transfer files from users in the sub-domains to a central user in the #myCompany domain.
You need to change permissions file by file, there is no updateAll type of functionality at the moment.
You cant transfer the ownership to another domain's user. Ownership can only be transferred to another user in the same domain as the current owner.
This answer doesn't directly answer your question, but it could be helpful for both you and future visitors.
As of now, you can mass transfer files to new users with Google's new Admin console. It doesn't let you filter for specific folders, but it does allow you to transfer all of one user's Drive files to a second user.
I know you were trying to create something which uses the API to iterate through folders and files, and you probably have a very specific use-case in mind. However, in the case where you have employees leaving, or you need to transfer everything, using the following method is fast and simple.
Open the Google Admin console
Go to Google Apps > Drive
Click on "Transfer ownership"
Fill out both user fields and submit
This process will even email both users once the process is completed.
You can do this with a single call to the Data Transfer API
Exactly what is needed but only with API!
Open the Google Admin console
Go to Google Apps > Drive
Click on "Transfer ownership"
Fill out both user fields and submit
This process will even email both users once the process is completed.
If this is not possible via API calls, then there is no point deleting a user using API.