Jump to content

How to use Stream of current prices

Recommended Posts


How can I get real time streams from https://push.cityindex.com/ ?

I am programing in Autoit (simplified c like programming language) and I did not find any online help about it.

I can create a PUSH or GET message to https://ciapi.cityindex.com/tradingapi/ and this way I can place orders or trades, but I have no idea, how can I get streaming data.

(I am registered and having an AppKey.)

I guess, I need to start a socket connection but I do not know the parameters and the web address of server.
Unfortunatelly on http://docs.labs.gaincapital.com there is not document about, how to do that. There is only a link to lightstreamer, but no example, how to do it.

Please help !


Share this post

Link to post

Hello Cinemizer,

You'll need to download a Lightstreamer Client development kit appopriate for the programming language you are using from: https://lightstreamer.com/download/#ls70. That link is for the version of Lightstreamer we are using on our servers.

Documentation on using Lightstreamer can be found at: https://lightstreamer.com/download/#ls70. The "General Concepts" and "Hello World" tutorials in the Basics section should get you started. After that, the "Web Client Development" file should get you the rest of the way.

Note: authentication for Lightstreamer is your username that you use with the REST API, and the Session token you receive back once you have logged into the REST API. 

Kind Regards, PM


Share this post

Link to post

Thanks for your reply. I already checked this documents.

I have found out, that I must to get a sessionID to start a stream. I can do it with a POST message, I think. (I am working on Win10 PC.)

My problem (1) is:

If I write in CMD follwoing:

curl -X POST -d "LS_adapter_set=DEMO" http://push.lightstreamer.com/lightstreamer/create_session.txt

I get a response.

if I start the same in firefox,
https://push.lightstreamer.com/lightstreamer/create_session.txt?LS_protocol=TLCP-2.1.0&LS_adapter_set=WELCOME&LS_cid=mgQkwtwdysogQz2BJ4Ji kOj2Bg
it does not send any response, it is waiting to download create_session.txt and nothing happens.(I waited very long.)
If I change the LS_cid value to something wrong, i.e.: mgQkwtwdysogQz2BJ4Ji%20kOj2BgXXX   -> added "XXX" at the end
it responds immediatelly with an error message in the create_session.txt
WHY ? According the lightstreamer documents, it must also work over a web browser.

The same way, im my Autoit Program, the command $oHTTP.Send($sData) break down, and my program stop working, if I post the correct messages to the lightstream server.

It is for me not clear, how can I make a connection to the lightstreamer server, if he sends streaming data.
(Because there is working a demo, I want to test at firts this, to check if my program is working well, and after that starting streaming data from push.cityindex.com)

If I POST a request to the lightstreamer server, the connection ends, but if the server begins to send, how can I get the data? What shall I program, which can receive the streamed data?

Maybe I need to create a socket connection, but such an example program in Autoit allows only a connection to a local IP address and does not allow such
like:    push.cityindex.com/lightstreamer/create_session.txt
It seems, that a socket connection can connect only to a specific IP address over a port. So it seems to be unusable for my goal, but than what can receive the streaming data ?



Share this post

Link to post

Problem (3) is:

On GainCapital site:

http://docs.labs.gaincapital.com/#Getting Started/CIAPI Arky.htm%3FTocPath%3DGetting%20Started|_____1


http://docs.labs.gaincapital.com/#Streaming Data/Prices.htm%3FTocPath%3DCIAPI%20Reference|Streaming%20Data|_____5

there is no information about, which part of the message is "target" and what is "channel".
I could figure it out, that "target" comes to "LS_adapter_set" -> &LS_adapter_set=STREAMINGALL
but what part is "channel" ???

Every Forum answer from you, sends to Lightstream site, but I can find there only general informations, because lightstreamer was made for many usage, not only for GainCapital,
it means, on the lightstreamer site is no information about, which field will be used by Gain Capital for what and how GainCapital is using Lightstreamer.
Unfortunatelly there are no demo or examples on Gain Capital site about streaming of data.

For "REST API" there are many examples, what to POST if I want to place an order or a trade, but nothing, how to initialise and use a streaming.

Please help!


Share this post

Link to post

Hi Cinemizer,

In answer to your post from Friday.

To be clear about authentication, you first need to POST a LogOn request to the REST API (ciapi.cityindex.com) using your username and account password. Upon successful logon, you recevie back a session ID.

Now, when connecting to Lightstreamer API for streaming prices, as authentication you send you username and use as the password the session ID received from the REST API. 

Since Lightstreamer does not have a Client Development Kit for your language AutoIT, it's possible you cannot access Lightstreamer streams through AutoIT. At best, you would have to put in work to convert the .NET Client Development Kit to work with AutoIT. 

Kind Regards, PM


Share this post

Link to post

Hello Cinemizer,

In answer to your post from Saturday.

"Target" means the LightStreamer adapter to use. In all cases, this is "STREAMINGALL" as noted in the docs for each of the streams.

Similarly, "Channel" means the stream you are listening to. The channel you need is documented for each stream, for example: PRICES.PRICE.{marketIds} is used to subscribe to the price stream for the market with marketID that you enter for the placeholder {marketId}.

We only provide information on the REST API in the documentation and the forum since that is our (Gain's) API. Lightstreamer as a 3rd party API we do not directly support here.

Kind Regards, PM

Share this post

Link to post


I am sorry, but what you write is not very clear.

I sent to the server as GET message:

?LS_protocol=TLCP-2.1.0 HTTP/1.1&LS_cid=mgQkwtwdysogQz2BJ4Ji%20kOj2Bg&LS_adapter_set=STREAMINGALL&LS_data_adapter=PRICES.PRICE.154297&LS_user=USERNAME&LS_password=SESSION

USERNAME and SESSION are valid values from my account.

I get from server back only this answer:

Lightstreamer up

What does it mean ?

OK, that LS_adapter_set=STREAMINGALL, but which LS_ value must be equal to i.e. PRICES.PRICE.154297 if I want to get real time tick prices of GBP/USD ?

Could you create for me a complete valid request string to start a stream of data please ?


Share this post

Link to post


Please send to the server as a POST, not as a GET.

I would suggest you first login to Lightstreamer and esnure that it works and you are authenticated. After successful login, you can send another call to subscribe to the Prices stream for GBP/USD.

For your prices subscription call, the string would look something similar to:


Please refer to the lightstreamer documentation so you know what fields you are sending, and what mode you require etc.

Kind Regards, PM

Share this post

Link to post

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now