'JSON'에 해당되는 글 2건

  1. 2015.10.01 Python - JSON을 이용한 지진검색
  2. 2015.06.03 Stock APIs - Bloomberg, NASDAQ and E*TRADE
Programming2015. 10. 1. 08:53


-------------------

*USGS Json data structure

http://earthquake.usgs.gov/earthquakes/feed/v1.0/geojson_detail.php


*Past Day M2.5+ Earthquakes

http://earthquake.usgs.gov/earthquakes/feed/v1.0/summary/2.5_day.geojson


-------------------


# 

import urllib2
import json

def printResults(data):
  # Use the json module to load the string data into a dictionary
  theJSON = json.loads(data)
  
  # now we can access the contents of the JSON like any other Python object
  if "title" in theJSON["metadata"]:
    print theJSON["metadata"]["title"]
  
  # output the number of events, plus the magnitude and each event name  
  count = theJSON["metadata"]["count"];
  print "Yesterday Total " + str(count) + " events recorded"
  
  # for each event, print the place where it occurred
#  for i in theJSON["features"]:
#    print i["properties"]["place"]

  # print the events that only have a magnitude greater than 4
  print"\n"
  print "Magnitude greater than 4:\n"
  for i in theJSON["features"]:
    if i["properties"]["mag"] >= 4.0:
      print "%2.1f" % i["properties"]["mag"], i["properties"]["place"]

  # print only the events where at least 1 person reported feeling something
  print "\n"
  print "Events that were felt:\n"
  for i in theJSON["features"]:
    feltReports = i["properties"]["felt"]
    placeOccur = i["properties"]["place"]
    if (feltReports != None) & (feltReports > 0):
        if (i["properties"]["place"].find("California") > 0 or i["properties"]["place"].find("Mexico") > 0) :
		    print "*****************************************"
        print "%2.1f" % i["properties"]["mag"], i["properties"]["place"], " reported " + str(feltReports) + " times"
 
  
def main():
  # define a variable to hold the source URL
  # In this case we'll use the free data feed from the USGS
  # This feed lists all earthquakes for the last day larger than Mag 2.5
  #Fred: http://earthquake.usgs.gov/earthquakes/feed/v1.0/geojson.php
  urlData = "http://earthquake.usgs.gov/earthquakes/feed/v1.0/summary/2.5_day.geojson"
  
  # Open the URL and read the data
  webUrl = urllib2.urlopen(urlData)
  print ("USGS is alive, response=%d" % webUrl.getcode())
  if (webUrl.getcode() == 200):
    data = webUrl.read()
    # print out our customized results
    printResults(data)
  else:
    print "Received an error from server, cannot retrieve results " + str(webUrl.getcode())

if __name__ == "__main__":
  main()

-------------------

sample file


jsondata_finished.py



'Programming' 카테고리의 다른 글

Drupal Web Application Packages  (0) 2015.10.02
Drupal Shell - Drush  (0) 2015.10.02
VM Virtualbox에 Ubuntu설치후  (0) 2015.10.01
Python - String, File, Regular Expression  (0) 2015.09.30
Python - Stock Price Quote  (0) 2015.09.30
Posted by 쁘레드
Programming2015. 6. 3. 06:17

공개된 Stock API이 많은것 같습니다. 한국에서는 대우증권에서 2000년대 초반에 API를 공개해서 자동으로 trade하고자 하는 저의 꿈에 한발짝 다가갈수 있게해줬었는데, 그 이후 막히고 점점 퇴보하는것 같았습니다. open해주면 아무래도 보안에 문제가 있을거란 걱정을 윗대가리들은 하겠지요. 오픈이 가끔 보안문제를 야기시키지만 사회를 투명하게 하고는데 도움이 됩니다. 뭘 오픈할지도 생각하지 않고 안된다고만 하는것은 안되겠지요.


시간을 내서 재밌는거 하나 만들어봐야겠네요. 매번 반복적으로 하는거 자동화하게요.

----------------

http://www.programmableweb.com/news/96-stocks-apis-bloomberg-nasdaq-and-etrade/2013/05/22

Our API directory now includes 96 stocks APIs. The newest is theEurex VALUES API. The most popular, in terms of directory page views, is the Bloomberg API. Below you'll find some more stats from the directory, including the entire list of stocks APIs.



In terms of the technical details, REST and XML lead the way. There are 55 stocks REST APIsand 42 stocks SOAP APIs. Our directory lists 64 stocks XML APIs and 18 stocks JSON APIs


  Bloomberg API: Financial markets data service

  E*TRADE API: Access to E*Trade services for applications

  NASDAQ Data-On-Demand API: NASDAQ historical stock quote data servcie


----------------------

http://www.programmableweb.com/api/bloomberg

Financial
StatisticsStocks
Unspecified
No
C, C++, .NET, Java, Perl Node.js
open-tech@bloomberg.net
Unspecified, IP authentication, Bloomberg Terminal authentication






















--------------------

ETrade

Financial
Stocks
XMLJSONREST
Yes
OAuth



















--------------------

Nasdaq

Financial
Stocks
XMLRESTSOAP
ASP, C#, Java, PHP, Perl, .NET, VB, XSLT


Posted by 쁘레드