API Project questions

Started by Randy Stebbing on Saturday, June 18, 2011

Participants:

Related Projects:

Showing all 9 posts
6/18/2011 at 6:42 AM

1) I'd like a way to go from the url value returned from the project API and to resolve it to a browser url. Is that possible?

Sending this....
https://www.geni.com/api/project-5179

Would return this...
http://www.geni.com/projects/Portal-espa%C3%B1ol

I'd also like to be able to go in reverse I'd like to be able to pass in a full url like
http://www.geni.com/projects/Portal-espa%C3%B1ol and have it return the project id # of 5179

2) I'd like to be able to fetch project info totals without having to use the nextpage methods to tally the info myself which is time consuming for large projects.

So for https://www.geni.com/api/project-5179 I'd like it to return that there are 50 collaborators, 67 followers and 0 profiles. In this case I don't care who the collaborators, followers or profiles are I just want to know the totals.

3) I'd like to be able to know more info about project activity: Date when a project was first started, the dates for the most recent follower, most recent collaborator, most recent profile added, most recent discussion post, and most recent about section edit.

Of the list above the highest priority for me would be #1

Private User
6/18/2011 at 6:50 AM

1) project-5179 is listed 11 times on the project web page where "Graph.follow('project-5179')" probably is the easiest place to extract the value from.

2) You have the view all numbers

and so on.. - but I agree that having API instructions instead of processing the page would be nice, even if you probably just need one statement to get each value.

Private User
6/18/2011 at 6:52 AM

Sorry, - you asked about the reverse lookup, - Agree - going from project-5179 to the web page is definitely needed, but isn't it just http://www.geni.com/projects/ + project name URL encoded?

6/18/2011 at 9:47 AM

"...but isn't it just http://www.geni.com/projects/ + project name URL encoded?.."

The above is the hack that I'm currently doing to go from project number to web page but the code hack gets pretty ugly with non-asicii support, character encodings, and handling punctuation marks like " - ' & that are in the titles but not necessarily in the URL encoded version.

Private User
6/18/2011 at 10:04 AM

Do you have an example where it does not work?

The classical fault when doing your own URL encoding is to forget that the string have to be converted to an UTF-8 encoded character sequence before doing the URL escaping.

6/18/2011 at 10:27 AM

"...Do you have and example..."

Bjørn,

Hopefully these will come through as click-able links you can get to:

http://www.geni.com/projects/The-Torn-States-during-the-US-Civil-War

http://www.geni.com/projects/Mewhirter-mcwhirter-Robert-his-wife-El...

http://www.geni.com/projects/-The-House-of-Alp%C3%ADn-Kings-of-Scot...

http://www.geni.com/projects/Exilarchs-%D7%A8%D7%A9%D7%99-%D7%92%D7...

For most cases I think if I first parse the returned name value, replacing all punctuation marks with a "-" that should get the url for the majority of the cases. I'm not sure what to do with the last example.

Private User
6/18/2011 at 11:20 AM

You are right - the code got more dirty than expected.

The below C# code worked for me, but it probably does not cover all cases unless some Geni staff can tell us all the rules

string[] projectNames = {"The \"Torn\" States during the US Civil War",
"Mewhirter / mcwhirter - Robert & his wife Elizabeth Taylor",
" The House of Alpín: Kings of Scotland c. 843 - 1034",
"Exilarchs (רשי גלותא)", };

foreach (string name in projectNames)
{
StringBuilder sb = new StringBuilder();

foreach (char c in name.Where(c => !Char.IsPunctuation(c)))
{
if (Char.IsWhiteSpace(c))
{
if (sb.Length == 0 || sb[sb.Length - 1] != '-')
sb.Append('-');
}
else
sb.Append(c);
}
string geniUrl = "http://www.geni.com/projects/" + sb;

System.Diagnostics.Process.Start(geniUrl);
}

Private User
6/18/2011 at 11:23 AM

Sorry, the last statement should be

string geniUrl = "http://www.geni.com/projects/" + Uri.EscapeDataString(sb.ToString());

(but it did work without URL encoding the string, but that is not following the standard)

Private User
11/8/2012 at 5:19 AM
Showing all 9 posts

Create a free account or login to participate in this discussion