tags:

views:

71

answers:

3

If I type in a browser (see http://stackapps.com/questions/2/getting-started-with-the-api) :

http://api.stackoverflow.com/1.0/stats

it returns

{
  "statistics": [
    {
      "total_questions": 800830,
      "total_unanswered": 131356,
      "total_accepted": 500653,
      "total_answers": 2158752,
      "total_comments": 3125048,
      "total_votes": 7601765,
      "total_badges": 798091,
      "total_users": 289282,
      "questions_per_minute": 1.50,
      "answers_per_minute": 3.12,
      "badges_per_minute": 1.20,
      "views_per_day": 455215.44,
      "api_version": {
        "version": "1.0",
        "revision": "2010.7.17.1"
      },
      "site": {
        "name": "Stack Overflow",
        "logo_url": "http://sstatic.net/stackoverflow/img/logo.png",
        "api_endpoint": "http://api.stackoverflow.com",
        "site_url": "http://stackoverflow.com",
        "description": "Q&A for professional and enthusiast programmers",
        "icon_url": "http://sstatic.net/stackoverflow/apple-touch-icon.png",
        "state": "normal",
        "styling": {
          "link_color": "#0077CC",
          "tag_foreground_color": "#3E6D8E",
          "tag_background_color": "#E0EAF1"
        }
      }
    }
  ]
}

If I type this in rebol console:

read http://api.stackoverflow.com/1.0/stats

It returns some weird binary chars.

+1  A: 

REBOL is ignoring the Content-Encoding: gzip response header, which stackoverflow seems adamant to use, regardless of what you put in your Accept-Encoding: header. On Unix, wget and curl have the same problem, but I can do this to see the intended content:

curl http://api.stackoverflow.com/1.0/stats | zcat

Does REBOL have a way to uncompress gzip content?

Marcelo Cantos
I found a lib here http://www.rebol.org/view-script.r?script=gunzip.r so I'll try thanks.
Rebol Tutorial
+1  A: 

Based on http://www.mail-archive.com/[email protected]/msg03531.html

>> do http://www.rebol.org/download-a-script.r?script-name=gunzip.r
connecting to: www.rebol.org
Script: "gunzip" (30-Dec-2004)
>> print to-string gunzip read http://api.stackoverflow.com/1.0/stats
connecting to: api.stackoverflow.com
{
  "statistics": [
    {
      "total_questions": 801316,
      "total_unanswered": 131450,
      "total_accept���������������������accept������E531450,
      "tocomment312672�vote7605283badge7984187946531450,
  tal_unans_per_minutet.0531450,
....

almost works :) so the core code is all there, just not exposed properly... it's a pity indeed...

but stackoverflow is not nice either not being complaint to the http specs and ignoring the accept-encoding header...

onetom
I'll report to api but since I'm not specialist how should I formulate that precisely ?
Rebol Tutorial
"The API server is returning gzipped content regardless of the presence and value of the Accept-Encoding HTTP header. Please honor it , to avoid confusion and allow easier experimentations." -- something like that
onetom
+2  A: 
probe load to-string gunzip to-string read/binary http://api.stackoverflow.com/1.0/stats
connecting to: api.stackoverflow.com
{
  "statistics": [
    {
      "total_questions": 801559,
      "total_unanswered": 131473,
      "total_accepted": 501129,
      "total_answers": 2160171,
      "total_comments": 3127759,
      "total_votes": 7607247,
      "total_badges": 798608,
      "total_users": 289555,
      "questions_per_minute": 0.93,
      "answers_per_minute": 1.83,
      "badges_per_minute": 0.73,
      "views_per_day": 455579.60,
      "api_version": {
        "version": "1.0",
        "revision": "2010.7.17.2"
      },
      "site": {
        "name": "Stack Overflow",
        "logo_url": "http://sstatic.net/stackoverflow/img/logo.png",
        "api_endpoint": "http://api.stackoverflow.com",
        "site_url": "http://stackoverflow.com",
        "description": "Q&A for professional and enthusiast programmers",
        "icon_url": "http://sstatic.net/stackoverflow/apple-touch-icon.png",
        "state": "normal",
        "styling": {
          "link_color": "#0077CC",
          "tag_foreground_color": "#3E6D8E",
          "tag_background_color": "#E0EAF1"
        }
      }
    }
  ]
}
Graham Chiu
Wow you're a genious :)
Rebol Tutorial