FaH api for retrieving donor's ID from JSON

This forum contains information about 3rd party applications which may be of use to those who run the FAH client and one place where you might be able to get help when using one of those apps.

Moderator: Site Moderators

Post Reply
Kana-chan
Posts: 16
Joined: Wed Nov 15, 2017 9:17 am

FaH api for retrieving donor's ID from JSON

Post 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.
------------------
Regards, Kana-chan.
ImageImage
Joe_H
Site Admin
Posts: 7936
Joined: Tue Apr 21, 2009 4:41 pm
Hardware configuration: Mac Pro 2.8 quad 12 GB smp4
MacBook Pro 2.9 i7 8 GB smp2
Location: W. MA

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

Post 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.
Image

iMac 2.8 i7 12 GB smp8, Mac Pro 2.8 quad 12 GB smp6
MacBook Pro 2.9 i7 8 GB smp3
Kana-chan
Posts: 16
Joined: Wed Nov 15, 2017 9:17 am

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

Post 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.
------------------
Regards, Kana-chan.
ImageImage
bruce
Posts: 20824
Joined: Thu Nov 29, 2007 10:13 pm
Location: So. Cal.

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

Post 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.
Kana-chan
Posts: 16
Joined: Wed Nov 15, 2017 9:17 am

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

Post 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.
------------------
Regards, Kana-chan.
ImageImage
aetch
Posts: 436
Joined: Thu Jun 25, 2020 3:04 pm
Location: Between chair and keyboard

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

Post 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
Folding Rigs - None (25-Jun-2022)

ImageImage
Kana-chan
Posts: 16
Joined: Wed Nov 15, 2017 9:17 am

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

Post 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.
------------------
Regards, Kana-chan.
ImageImage
aetch
Posts: 436
Joined: Thu Jun 25, 2020 3:04 pm
Location: Between chair and keyboard

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

Post 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.
Folding Rigs - None (25-Jun-2022)

ImageImage
Post Reply