New JSON Feed of Badge Info

29 posts

Flag Post

We’ve got a new feed that will be useful for people making things like the Kongregate Firefox Sidebar and Metaward. It’s actually two different kinds of feeds – one of all badges available, and one showing the badges any individual user has.

Andrew did them as JSON, which is a simpler and more compact format than XML. There are JSON parsing libraries for most popular languages, including AS2 & AS3.

Try it out – these might not look right in your browser, but you can download them as a file and open in notepad or whatever.

http://www.kongregate.com/badges.json

This feed returns the following info:

  1. Badge description
  2. Title and URL of the game(s) the badge is on
  3. Badge name
  4. URL of badge icon
  5. Badge difficulty / points earned
  6. How many users have earned it
  7. When it was created
  8. Unique id

http://www.kongregate.com/accounts/jimgreer/badges.json

This one returns the badges earned by the given user – it’s just a list of badge ids and the date earned.

You can also have these call a javascript function directly (sometimes useful if you’re doing an AJAX web app):

http://www.kongregate.com/accounts/andrew/badges.json?callback=foo

 
Flag Post

Thanks! Didn’t see this till now. Great. I’d love to make an app. Is there anyway to get the name of an individual through the use of a method that requires only prompting once? (for mass distibuting, so you can just make one app)

 
Flag Post

Um, you could ask the user to input their username. Am I missing something?

 
Flag Post

The sites do not work for me. :/

 
Flag Post
Originally posted by jimgreer:

Um, you could ask the user to input their username. Am I missing something?

Well, I don’t want to distribute an app that each time you need to type in your username, nor do I want to make 500 different apps for the different users that might want a personalized app.

 
Flag Post

uhh, that’s why you store it on the user’s computer/browser profile

 
Flag Post
Originally posted by jonathanasdf:

uhh, that’s why you store it on the user’s computer/browser profile

But when you distribute the flash player app won’t its directory change as it might be uploaded to multiple different websites?

 
Flag Post

Oh so you want to use a flash player app …

Then of course they will need to log in every time if they access it from a different computer/browser…. otherwise there’s a lot of room for security issues. Of course, they can still look at the list of all the badges (thus knowing when new ones come out) without logging in.

For sites like facebook if you put on a specialized version you can probably pull the username stuff from the facebook API and thus use it that way (i’m not sure). Of course, if you’re using FP10 you can always use ExternalInterface to access the browser (through javascript), and store the data that way. It can then be pulled across all the different versions of your app. However, whether that info is stored for a single session or forever is up to you, depending on whether it’d be violating any security policies if it’s stored forever…

 
Flag Post

The API is now being used for updating kong users on metaward. Yay!

Thank you very much for building it. It should save us both a ton of bandwidth and headaches.

How about a full dump of user’s badges, and a daily dump of changes in badges, so I don’t have to recrawl? ;)

Anyways, thanks again.

 
This post has been removed by an administrator or moderator
 
Flag Post

would be interesting if you were to duplicate this for the games page (http://www.kongregate.com/games) which i expect the json file already exists, since http://www.kongregate.com/games.js and http://www.kongregate.com/games are the same exact page but http://www.kongregate.com/games.json returns a supposed 404 (you do this on other pages that do in fact exist (obvious from your calls to the pages from the holodeck and returning a value, to the ajax script), but the client doesn’t have proper permissions)

 
Flag Post

Well there is 2 options then. You could do they incorrect thing and “hack” to get that. Or you could say please and you might receive it. I advise the second only and will personally ignore anyone who ever decides to hack.

 
Flag Post

unknown, some things you can’t “hack,” not in the sense you mean anyway. there is no outside way to get to the badges.json; it’s all internal. other thing (your muted users, /accounts/#{user}/muted_users.json, however, is locked, but not blocked)

 
Flag Post

Cool. I ported the script I use to generate my profile stats, to this API. It’s nice.

$ ./kong.py jimgreer

Acquiring badges.json… OK!

Acquiring jimgreer.json… OK!

Acquiring jimgreer’s badges.json… OK!

- copy below this line -

November 19, 2009

- Acquired Badges: 228 of 851 (26.79% complete)

- Impossibles: 0 of 37 (0.00% complete)

- Average Points per Badge: 11.45

- Average Badges per Day: 0.20

- Estimated date of completion: June 21, 2018

- end of stats -

EDIT: http://github.com/MostAwesomeDude/madsnippets/blob/master/kong.py if you like. ~ C.

 
Flag Post

Feed is now at api.kongregate.com for those who want to integrate it. That site has a non-restrictive crossdomain.xml.

 
Flag Post

UG, why did you not announce your new app in this thread?

 
Flag Post
Originally posted by jonathanasdf:

UG, why did you not announce your new app in this thread?

Because my goal was not to show it off. :P

 
Flag Post

since the badge IDs are not zero indexed, and some badges have been removed. could index 0 be, instead of badge #1, the number of badges removed? or could the spaces that used to have badges be filled with an empty object/null?

 
Flag Post
Originally posted by skyboy:

since the badge IDs are not zero indexed, and some badges have been removed. could index 0 be, instead of badge #1, the number of badges removed? or could the spaces that used to have badges be filled with an empty object/null?

Why do you need them to go from 0 to X with no blanks? Its a json feed. You could just parse them in the order you get them, which is numerically.

 
Flag Post

Thank you for posting this!

 
Flag Post
Originally posted by UnknownGuardian:
Originally posted by skyboy:

since the badge IDs are not zero indexed, and some badges have been removed. could index 0 be, instead of badge #1, the number of badges removed? or could the spaces that used to have badges be filled with an empty object/null?

Why do you need them to go from 0 to X with no blanks? Its a json feed. You could just parse them in the order you get them, which is numerically.

badges[userBadges[x].id - 1].icon_url
is not accurate, because of the blank spaces, so i had to hack around it using a while loop, currently maxed at 100; if i had the number of badges removed, i could make sure the app will work no matter how many badges are removed; or if the ones that were removed are left as nulls in the array, then the indexes are more properly aligned
 
Flag Post

PPROGRAMMING SUCKS…..

 
Flag Post
Originally posted by johnsolo97:

PPROGRAMMING SUCKS…..

Actually it’s fun xD

 
Flag Post

JSON file with mobile badges… Someone?

 
Flag Post
Originally posted by resterman:

JSON file with mobile badges… Someone?

Looked around for one and didn’t see it a while back.