Take the 2-minute tour ×
Stack Apps is a question and answer site for apps, scripts, and development with the Stack Exchange API. It's 100% free, no registration required.

Currently, there is no practical way to retrieve badge information given its ID. I would like to see title and description added at the very least.

Current method for retrieving the data:

  • call the /badges method
  • loop through every badge
  • at each iteration, check to see if the IDs match

This is inefficient to say the least.

share|improve this question
add comment

1 Answer 1

/badges returns every badge in the system, building a lookup based on id is trivial and costs a single request.

share|improve this answer
    
But fetching the data for every badge wastes bandwidth and processing time. –  Nathan Osman Jun 2 '10 at 6:00
    
@George - so, rather than return every badge's description/title once per app run you'd rather see it returned once per call to /badges/{id}? Your approach wastes much more bandwidth and processing time. –  Kevin Montrose Jun 2 '10 at 6:17
    
Uh... given one ID of a badge, it would be great if we could get the info for only that badge. –  Nathan Osman Jun 2 '10 at 6:50
    
...or add a filter parameter so that only a particular badge is returned. That'd be good too. –  Nathan Osman Jun 2 '10 at 6:51
    
Anything to avoid iterating over countless badges just to match an ID just to get the description for a badge. –  Nathan Osman Jun 2 '10 at 6:52
    
@George - just build a map from id->description. O(1) lookup time, one fixed-size request to the API; much better than an unbounded number of requests. –  Kevin Montrose Jun 2 '10 at 6:59
    
Kind of tend to agree with George on this one. It would be nice to be able to fetch the info for one particular badge. –  Franci Penov Jun 2 '10 at 7:03
    
Kevin would have a valid point here if the badges list was static, but it isn't. –  Nathan Osman Jun 2 '10 at 7:37
    
@George - the badge page is updated very rarely (order of days), and if you see an id you haven't before, fetch again! –  Kevin Montrose Jun 2 '10 at 11:35
    
Yes, I would not mind seeing the other badge routes go away. i cannot think of a compelling use case to dedicate 3 routes for such a low volume of easily discernible data –  Sky Sanders Jul 25 '10 at 17:42
add comment

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .