Page 1 of 1

FaH api for retrieving donor's ID from JSON

Posted: Sat Apr 10, 2021 2:33 pm
by Kana-chan
Hello,

I am facing a problem with the API on api2.foldingathome.org (and on api.foldingathome.org too).
The url for having the JSON of a donor is:

Code: Select all

https://api2.foldingathome.org/donor/donor_name
But when I use jQuery in my javascript with the followinf code:

Code: Select all

$.getJSON('https://api2.foldingathome.org/donor/donor_name', function(data) { alert(JSON.parse(data)); });
This does not work.
I have an "Access-Control-Allow-Origin is missing" error.
Can you tell me how I can fetch the JSON of my user ?

Thanks in advance.

Re: FaH api for retrieving donor's ID from JSON

Posted: Sat Apr 10, 2021 4:14 pm
by Joe_H
Parts of that API have been disabled, and the API is now deprecated from the latest information I have, so you are seeing the effect of that. The link to the API that used to be on the stats page was removed many months ago.

Re: FaH api for retrieving donor's ID from JSON

Posted: Sat Apr 10, 2021 4:48 pm
by Kana-chan
Hello,

This is strange because it is the one used in the new statistics web interface. So I do not understand how it can be deprecated.

Can you tell me what is the new API used then ?

Thank you in advance.

Re: FaH api for retrieving donor's ID from JSON

Posted: Sat Apr 10, 2021 5:30 pm
by bruce
I have no facts to support my hunch, but it seems quite likely that a new client is in development and part of that process requires some significant changes to the API. The API and the files are in transition. A systematic garbage collection process has not happened in deference to a push to finish the development of the new client.

I'd be happy to be wrong.

An enhancement request in github might get looked at.

Re: FaH api for retrieving donor's ID from JSON

Posted: Tue Mar 22, 2022 10:34 pm
by Kana-chan
Hello,

I am coming back to you about the problem.
I used the new API with the following url:

Code: Select all

https://api2.foldingathome.org/user/find?name=<name>
I have this error:

Code: Select all

XHR GET https://api2.foldingathome.org/user/find?name=<name>
CORS Missing Allow Origin
Cross-Origin Request Blocked: The Same Origin Policy disallows reading the remote resource at https://api2.foldingathome.org/user/find?name=<name>. (Reason: CORS header ‘Access-Control-Allow-Origin’ missing).
So It is a problem server-side, the Access-Control-Allow-Origin on the server is too strict or missing.

I would like to know if there is a way to catch this JSON from my get request or I should use a curl on my more than 20000 users to have their id ?

Thanks in advance.

Re: FaH api for retrieving donor's ID from JSON

Posted: Wed Mar 23, 2022 3:55 am
by aetch
Daft question - if you're updating for 20000+ users why not simply download the stats flat files and extract the team/user data from those?
It's got to be quicker and simpler than trying to DDoS the stats server.
https://foldingathome.org/statistics/?lng=en

Re: FaH api for retrieving donor's ID from JSON

Posted: Sun Mar 27, 2022 10:15 pm
by Kana-chan
The flat files do not have the ids, I already download the flat files.
And now, there is no more flat files ... I can only have the 1000 first users of my team ... :(

And I won't DDoS the server, it is to create the link to go to the user page on FAH stats only if the link is clicked.

Re: FaH api for retrieving donor's ID from JSON

Posted: Mon Mar 28, 2022 4:19 am
by aetch
Kana-chan wrote:And now, there is no more flat files
What do you mean? I'm having no problem getting them, there's simply something going on which is preventing them from being updated.

The teams flat file gives you the team ID number.

You should then be able to filter/search the user/donor flat file for everyone contributing to the above team ID.

You should now have a list of every donor/user that has contributed to the above team.

You should now be able to use the folding @ home programming api (api.foldingathome.org) to run queries to get your user/donor IDs.
Start with the "GET /team/:team/members" query to get as many IDs a you can.
Use either the "GET /user" or the "GET /search/user" queries to return the ID of the rest of the users.
On subsequent updates you should only need to do the queries for new users/donors.

EDIT: A couple of extras.
I suggest maybe doing it in small batches of, say, 1000.
Some usernames may not return anything as some of the characters in the username may invalidate the web query.