# Get Data from Web Services

**URL:** <https://forum.kx.com/t/get-data-from-web-services/5745>\
**Category:** Community Support\
**Tags:** kdb-and-q\
**Created:** [August 21, 2008, 10:11pm UTC](https://forum.kx.com/t/get-data-from-web-services/5745 "2008-08-21T22:11:00Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![redreset](https://avatars.discourse-cdn.com/v4/letter/r/ac91a4/32.png) [@redreset](https://forum.kx.com/u/redreset)\
**Post date:** [August 21, 2008, 10:11pm UTC](https://forum.kx.com/t/get-data-from-web-services/5745/1 "2008-08-21T22:11:00Z")

</div>

Received: by 10.100.10.15 with SMTP id 15mr89765anj.0.1219353099060; Thu, 21  
Aug 2008 14:11:39 -0700 (PDT)  
Date: Thu, 21 Aug 2008 14:11:39 -0700 (PDT)  
X-IP: 199.89.64.176  
User-Agent: G2/1.0  
X-Google-Token: dH4yqAwAAABI1HQl4x9IdlmJ\_zyeSrg7  
X-HTTP-UserAgent: Mozilla/4.0 (compatible; MSIE 7.0; MSBrowserIE7; Windows NT  
5.1; msie6xpv1; .NET CLR 1.0.3705; .NET CLR 1.1.4322; .NET CLR 2.0.50727;  
.NET CLR 3.0.04506.30; .NET CLR 3.0.04506.648; .NET CLR 3.5.21022; MS-RTC LM  
8; MSIE6ENV21; MSIE6ENV21),gzip(gfe),gzip(gfe)  
X-HTTP-Via: 1.1 piipx1:8080 (DataReactor/4.1.0p24d2)  
Message-ID: \<19d8d5e7-abdf-4167-8a33-769a532c3c7a@k37g2000hsf.googlegroups.com\>  
Subject: Get Data from Web Services  
From: Ruslan   
To: “Kdb+ Personal Developers”   
X-Google-Approved: [simon.garland@gmail.com](mailto:simon.garland@gmail.com) via email at 2008-08-22 06:03:34  
  
What is the best way to get data via [http://server-foo/page?parm=value](http://server-foo/page?parm=value)  
curl type a query?  
Using the cookbook example, [https://code.kx.com/svn/cookbook\_code/yahoo.q](https://code.kx.com/svn/cookbook_code/yahoo.q)  
I run into timeout issues if the query/data pull takes longer than 1  
min and an interpreter issue if my url contains special characters  
such as a dash(-).  
I fixed the special char issues with type casting from string:  
“urlget: `$”:[http://server-foo:8080](http://server-foo:8080)";" before concatenating it to the  
query string, “GET /page?parm=value\r\n\r\n”, but I am still having  
issues with the request timeouts.  
  
Any suggestions?  
  
-Ruslan

---

<div class="post-metadata">

**Author:** ![ag12](https://avatars.discourse-cdn.com/v4/letter/a/ecae2f/32.png) [@ag12](https://forum.kx.com/u/ag12)\
**Post date:** [November 19, 2016, 9:10pm UTC](https://forum.kx.com/t/get-data-from-web-services/5745/2 "2016-11-19T21:10:00Z")

</div>

p.p1 {margin: 0.0px 0.0px 0.0px 0.0px; font: 14.0px Menlo; color: #000000; background-color: #ffffff}span.s1 {font-variant-ligatures: no-common-ligatures}

yahoo[1; (`ibm,`goog,`cat,`intc,`msft,`aapl)]

Is there a way to keep the socket open and run multiple requests?&nbsp;

---

<div class="post-metadata">

**Author:** ![effbiae](https://avatars.discourse-cdn.com/v4/letter/e/ecae2f/32.png) [@effbiae](https://forum.kx.com/u/effbiae)\
**Post date:** [November 20, 2016, 12:24am UTC](https://forum.kx.com/t/get-data-from-web-services/5745/3 "2016-11-20T00:24:00Z")

</div>

the yahoo function described here http://code.kx.com/wiki/Cookbook/ProgrammingExamples uses the “single shot” request:&nbsp;

&nbsp;&nbsp;`:http://ichart.finance.yahoo.com “GET /table.csv?s=”,(string stock:stocks[i]),parms," http/1.0\r\nhost:ichart.finance.yahoo.com\r\n\r\n"

the single shot request closes the connection after the result arrives (described here http://code.kx.com/wiki/Reference/hopen) .

if you wanted to heep the connection, the first step you would need to try is to keep a reference to the connection to yahoo:

q)hopen `:http://ichart.finance.yahoo.com

'type

that doesn’t work…

q)hopen `:ichart.finance.yahoo.com:80

3i

'parse

(i think kdb doesn’t like a text response sent from yahoo.com. &nbsp;kdb only expects messages in it’s IPC format)

at this point, i’d google “yahoo table.csv” - or investigate a websocket interface to yahoo..

if you’re want live data, you could look at the many CFD markets out there. &nbsp;they are happy to send you live data.

jack
