2013-09-27 29 views
1

我正在使用Open Weather Map API。我仍然在打電話。我正在查看2個具體調用的結果。一個用於London,另一個用於South AfricaHermanus。我觀察到,並非Hermanus呼叫中返回的所有數據都在倫敦呼叫返回的數據中。從開放天氣圖API返回的數據沒有意義

這裏是我的2個呼叫:

倫敦返回的數據是:

{ 
    "coord": { 
      "lon":-0.12574, 
      "lat":51.50853 
    }, 
    "sys": { 
      "country":"GB", 
      "sunrise":1380261352, 
      "sunset":1380303998 
    }, 
    "weather": [{ 
      "id":800, 
      "main":"Clear", 
      "description":"Sky is Clear", 
      "icon":"01d" 
    }], 
    "base":"gdps stations", 
    "main": { 
      "temp":290.22, 
      "pressure":1016, 
      "humidity":63, 
      "temp_min":289.15, 
      "temp_max":291.48 
    }, 
    "wind": { 
      "speed":6.2, 
      "deg":100 
    }, 
    "clouds": { 
      "all":0 
    }, 
    "dt":1380285272, 
    "id":2643743, 
    "name":"London", 
    "cod":200 
} 

而對於赫曼努斯返回的數據是:

{ 
    "coord": { 
      "lon":19.234461, 
      "lat":-34.418701 
    }, 
    "sys": { 
      "country":"ZA", 
      "sunrise":1380255856, 
      "sunset":1380300203 
    }, 
    "weather": [{ 
      "id":804, 
      "main":"Clouds", 
      "description":"overcast clouds", 
      "icon":"04d" 
    }], 
    "base":"gdps stations", 
    "main": { 
      "temp":284.981, 
      "temp_min":284.981, 
      "temp_max":284.981, 
      "pressure":999.07, 
      "sea_level":1026.12, 
      "grnd_level":999.07, 
      "humidity":77 
    }, 
    "wind": { 
      "speed":6.71, 
      "deg":282 
    }, 
    "rain": { 
      "3h":0 
    }, 
    "clouds": { 
      "all":92 
    }, 
    "dt":1380285425, 
    "id":3366880, 
    "name":"Hermanus", 
    "cod":200 
} 

爲什麼一個包含某些數據而另一個不是?我怎樣才能找出所有可以從這樣的電話返回?我怎麼知道每個項目意味着什麼是返回?

+1

這完全取決於第三方返回什麼數據。他們可能沒有全部位置的全套數據。您可能最好從數據提供者本身請求信息。 –

+1

羅裏是對的。我與他們的API有同樣的問題,有時不會返回rain.3h數據,有時它是0.也許是時候檢查另一個API像forecast.io – Jorre

回答

1

如果你看看這個頁面,你會看到一些返回鍵實際上是可選的:

http://openweathermap.org/wiki/API/2.0/Weather_Data

即使是明顯weather關鍵是可選的! :)

+0

謝謝。是否有2.5版本的wiki?有關此API的文檔不太清楚。 –

+0

@BrendanVogt氣象數據從版本2.0開始始也沒有變化:) – silkfire

+0

@ BrendanVogt-以下是API 2.5中使用的參數總結 - http://openweathermap.org/weather-data#current –