API for the site?

in Userscripts.org discussion
Subscribe to API for the site? 23 posts, 8 voices



Seb User

I have a utility that makes it easy for users to add scripts to sites, and I'd like to integrate userscripts' listings within my utility; is there some sort of API where we can pull this list of scripts off the site?

 
Henrik N Admin

We have a partial API, but it's more or less what you get out of the box with Rails, so it's not as good as it should be yet, and it's still subject to change (i.e. your code might break if you use the API and we later change something).

That said, try adding .xml or ?format=xml at the end of an URL. Should work in most places. For URLs like http://userscripts.org/users/452;scripts, you'd add .xml before the semicolon (but ?format=xml would still go at the very end).

To simplify some code I wrote against the API, I've added some magic so that http://userscripts.org/users/me (and similarly for /me;scripts) will be HTTP redirected to /452 or whatever your user id is. That assumes that the request is made in a logged-in session, obviously. me.xml or me.xml;scripts works, too.

You can poke around in my Greasemonkey bundle for TextMate for some Ruby code (using curl) that uploads a script to this site automatically.

Hope that helps.

 
Seb User

Does the site have (will have?) anything like categories or similar for the scripts?

 
Henrik N Admin

Seb: Yes, we certainly want something like that. Not sure if that'll be tags or some sort of site categories or both or something else. It'd be interesting to hear opinions on this, though it should probably be in a new thread.

 
znerp Scriptwright

Someone recently posted a comment on one of my scripts telling me that it doesn't work any more since http://userscripts.org/users/me no longer works. Can I ask why this feature's been removed and if there's any plans to bring it back? (ie. should I work around this permanently, or will it sort itself out?)

 
Jesse Andrews Admin

I have no clue that people still used me - I'll re-add that

 
znerp Scriptwright

Excellent, thanks Jesse. I remember thinking it was pretty nifty when Henrik made the above post, so I put it in my favourites script. It seemed to be the easiest way of adding a link in my favourites script rather than adding extra code to find out an actual link for the user page.

 
Mindeye Scriptwright

Jesse, any news on that promised US.o API? ;-)

 
Jesse Andrews Admin

The first stab has started... http://userscripts.org/api - which documents a single call for Steve (of greasefire).

Let me know what needs added....

 
Marti Scriptwright

Kewl!!! Nice job Jesse... will examine it further after I get back from a gig. :)


Just a quick note before I'm off... you are inserting a \n in multiple places where they shouldn't be... and could you explain your Date/Time stamp please. 2005-06-19T23:33:49Z Thanks

 
Jesse Andrews Admin

The enters are odd - it will be fixed in tomorrows release.

Regarding the times, it is XML Schema Date/Time

{Date}T{Time}-{UTC offset}

 
Mindeye Scriptwright

Ok, I would like it to get a list of scripts (with basic script data) by author id and to get script data (extended data: name, description, reviews, fans, comments, installs, etc...) by script id.

Thanks for your work on the site :-)

 
Marti Scriptwright

Mindeye wrote:
Ok, I would like it to get a list of scripts (with basic script data) by author id and to get script data (extended data: name, description, reviews, fans, comments, installs, etc...) by script id.
You could go vote for it at http://userscripts.uservoice.com/pages/general/suggestions/144246 and add any additional information you think should be returned by the meta.js routine.

And confirm that your vote(s) got counted... a friend of mine told me it's not always incrementing the vote count.

 
Marti Scriptwright

Jesse Andrews wrote:
The enters are odd - it will be fixed in tomorrows release.
Looks great! :) and thanks for the reminder on the TZ... I deal with so many different languages... sometimes things get lost in recall.


Might want to put a note on the http://userscripts.org/api page that unlisted scripts don't show up (which is good of course)
And how about publishing your spec of meta.js too ;) It's here and here too but would be helpful to have it here on uso in your styling. Thanks.

 
Jesse Andrews Admin

I updated the scripts API to allow: filtering by user_id and including unlisted scripts as well.

 
JoeSimmons Scriptwright

total="26808"
Wow... a lot of scripts on this site ey :p

 
sizzlemctwizzle Scriptwright

@Jesse
Wouldn't a JSON API be much more useful for scripts than the current xml format?

 
Jesse Andrews Admin

Yep.. I'm doing it one step at a time. It is v0 for a reason :)

 
Marti Scriptwright

sizzlemctwizzle wrote:
Wouldn't a JSON API be much more useful for scripts than the current xml format?
That is a matter of preference in my book... I prefer to use XML over JSON. So maybe Jesse could put a query parameter on which type to return and a default to one or the other. ;) *GRIN*

 
Jesse Andrews Admin

change .xml to .js and you should get back json. There is a cursor object and scripts object.

Please don't hit this automatically from userscripts yet as there isn't any caching in place.

 
sizzlemctwizzle Scriptwright

Jesse Andrews wrote:
change .xml to .js and you should get back json. There is a cursor object and scripts object.

ooo thanks!
Jesse Andrews wrote:
Please don't hit this automatically from userscripts yet as there isn't any caching in place.

Okay, I'll restrain myself for the time being.
Marti wrote:
That is a matter of preference in my book... I prefer to use XML over JSON.

I hate using the DOMParser. I'm fine using XML in other languages though, but JSON is just so much cleaner.

 
Marti Scriptwright

sizzlemctwizzle wrote:
I hate using the DOMParser. I'm fine using XML in other languages though, but JSON is just so much cleaner.
LOL They are about equal on construction and cleanliness although appears the uso file sizes are larger with JSON. If you don't like DOMParser, I'm sure you won't be liking the JSON parser either ;)

Anywhoo.. nice job, yet again, Jesse. :)

 
Jesse Andrews Admin

I'm probably asking for it to be abused before I have protections in place, but if you do scripts.js?callback=foo it will return a JSON-P: foo({object})

Cross
Presentational HTML allowed.
Use <code> for inline code and <pre> for code blocks. Use &lt; and &gt; for literal < and >.
We help break paragraphs and link your links.
or cancel