You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository was archived by the owner on Apr 26, 2026. It is now read-only.
Repository navigation
This repository was archived by the owner on Apr 26, 2026. It is now read-only.
Yes, same here, I am getting the error of 41, I am going to try using webdriver, probably it's beeing blocked, so I will try that, but I am not giving up on this api that for sure :)
@theshadow76
I've made progress.
It was the backslashes before the inverted commas.
Now we're getting binary data
However, after the first data is received, the disconnect occurs.
data=r'42["auth",{"session":"a:4:{s:10:\"session_id\";s:32:\"c53eec05c6f8a8be2d134d4fd55266f8\";s:10:\"ip_address\";s:14:\"46.138.176.190\";s:10:\"user_agent\";s:101:\"Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/120.0.0.0 Safari/537.36\";s:13:\"last_activity\";i:1707850603;}9f383935faff5a86bc1658bbde8c61e7","isDemo":1,"uid":72038016,"platform":3}]'
@vladdd183
Hello!
Sorry to bother you again, but here:
importurllibimportwebsocketfrompocketoptionapi.constantsimportREGIONimportthreadingimportloggingimportsslclassWebSocketClient:
def__init__(self, url, pocket_api_instance=None):
self.url=urlself.pocket_api_instance=pocket_api_instanceself.logger=logging.getLogger(__name__)
self.logger.setLevel(logging.INFO)
formatter=logging.Formatter('%(asctime)s %(levelname)s %(message)s')
# Create file handler and add it to the loggerfile_handler=logging.FileHandler('pocket.log')
file_handler.setFormatter(formatter)
self.logger.addHandler(file_handler)
self.header="Origin: https://google.com"self.ws=websocket.WebSocketApp(self.url,
on_open=self.on_open,
on_message=self.on_message,
on_error=self.on_error,
on_close=self.on_close,
header=[self.header])
self.logger.info("Starting websocket client...")
defon_message(self, ws, message):
print(f"Message: {message}")
self.logger.info(f"Recieved a message!: {message}")
ifstr(message).startswith('0{"sid":'):
ws.send("40")
ifstr(message).startswith('40{"sid"'):
data=r'42["auth",{"session":"a:4:{s:10:\"session_id\";s:32:\"da7a5a82c8f6c35a87b2ee31d4f5b3b4\";s:10:\"ip_address\";s:10:\"90.36.9.15\";s:10:\"user_agent\";s:120:\"Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/119.0.0.0 Safari/537.36 OP\";s:13:\"last_activity\";i:1707667599;}3a0058a58a6df5e7b49f652f8e4f8249","isDemo":0,"uid":27658142,"platform":1}]'print(f"Sent the auth messaage!: {data}")
ws.send(data)
defon_error(self, ws, error):
print(error)
self.logger.error(f"Got a error: {error}")
defon_close(self, ws, close_status_code, close_msg):
print("### closed ###")
self.logger.warning(f"Connection closed, conections status_code: {close_status_code} and the message is: {close_msg}")
defon_open(self, ws):
print("Opened connection")
self.logger.info("Opened!")
defrun(self):
self.ws.run_forever() # Use dispatcher for automatic reconnectionws=WebSocketClient(url="wss://api-l.po.market/socket.io/?EIO=4&transport=websocket")
ws.run()
I am getting this output:
Opened connection
Message: 0{"sid":"s-DtcnSjnIgXZFuoNKB7","upgrades":[],"pingInterval":25000,"pingTimeout":20000,"maxPayload":1000000}
Message: 40{"sid":"aSAnWTMPfgSv-DKNNKCG"}
Sent the auth messaage!: 42["auth",{"session":"a:4:{s:10:\"session_id\";s:32:\"da7a5a82c8f6c35a87b2ee31d4f5b3b4\";s:10:\"ip_address\";s:10:\"90.36.9.15\";s:10:\"user_agent\";s:120:\"Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/119.0.0.0 Safari/537.36 OP\";s:13:\"last_activity\";i:1707667599;}3a0058a58a6df5e7b49f652f8e4f8249","isDemo":0,"uid":27658142,"platform":1}]
Message: 41
### closed ###
looks like I am still getting that issue even tho I've added the hedears, but can you check if the data variable is the way it should be?
Maybe it had to be formated in a diferent way.
you shoud to set origin with site you using, not google
try: https://po.trade/ (official link) or https://pocket-link19.co (mirror link)
official is prefered, use mirror only if official link banned in your country
I have a problem and I do not know how big or how to proceed.... I created a bot but when I run it I get this error. I think the pocketoptionapi modules are not well installed or not correct or the websockets issue. I need help to connect to Pocket Option
WARNING:root:WebSocket connection closed: received 1005 (no status received [internal]); then sent 1005 (no status received [internal])
ERROR:root:Error sending ping: received 1005 (no status received [internal]); then sent 1005 (no status received [internal])
I do not have pocketoptionapi so I am trying to use ssid
AttributeError: 'PocketOption' object has no attribute 'change_balance'
ERROR:root:Error sending ping: received 1005 (no status received [internal]); then sent 1005 (no status received [internal])
ERROR:root:Error sending ping: received 1005 (no status received [internal]); then sent 1005 (no status received [internal])
from pocketoptionapi import global_value
from pocketoptionapi.stable_api import PocketOption # Ensure this is correctly installed and imported
import time
import threading
import asyncio
import websockets
import ssl
Replace with your session ID
ssid = "mc4i2u7c721ajl9u0sr779jq8q" # Your valid session ID
Initialize PocketOption API with SSID
API = PocketOption(ssid)
Connect to the API
check = API.connect()
if not check:
print("Connection failed.")
exit()
THIS IS JUST THE SECTION OF THE CODE WHERE I HAD TO INPUT SSID
I have a problem and I do not know how big or how to proceed.... I created a bot but when I run it I get this error. I think the pocketoptionapi modules are not well installed or not correct or the websockets issue. I need help to connect to Pocket Option
WARNING:root:WebSocket connection closed: received 1005 (no status received [internal]); then sent 1005 (no status received [internal]) ERROR:root:Error sending ping: received 1005 (no status received [internal]); then sent 1005 (no status received [internal])
I do not have pocketoptionapi so I am trying to use ssid
AttributeError: 'PocketOption' object has no attribute 'change_balance' ERROR:root:Error sending ping: received 1005 (no status received [internal]); then sent 1005 (no status received [internal]) ERROR:root:Error sending ping: received 1005 (no status received [internal]); then sent 1005 (no status received [internal])
from pocketoptionapi import global_value from pocketoptionapi.stable_api import PocketOption # Ensure this is correctly installed and imported import time import threading import asyncio import websockets import ssl
Replace with your session ID
ssid = "mc4i2u7c721ajl9u0sr779jq8q" # Your valid session ID
Initialize PocketOption API with SSID
API = PocketOption(ssid)
Connect to the API
check = API.connect() if not check: print("Connection failed.") exit()
THIS IS JUST THE SECTION OF THE CODE WHERE I HAD TO INPUT SSID
how can i get this real time candle : " from pocketoptionapi.stable_api import PocketOption
import time
SSID: The session ID to authenticate with PocketOption
ssid = r"""42["auth",{"session":"a:4:{s:10:"session_id";s:32:"47f30c18560908460f79392abb5e2ea0";s:10:"ip_address";s:15:"103.167.208.249";s:10:"user_agent";s:111:"Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/129.0.0.0 Safari/537.36";s:13:"last_activity";i:1728768861;}52f0fbcaac716f54f471b6030a4434b9","isDemo":0,"uid":72758516,"platform":2}]"""
Initialize the PocketOption API, with demo set to True for safety
API = PocketOption(ssid, demo=True)
Connect to the API
check = API.connect()
if check:
try:
# Get the demo account balance
print(f'Demo Balance: {API.get_balance()}')
# Define the asset, candle period, and offset to retrieve candles
asset = "EURUSD"
current_time = int(time.time()) # Current time as timestamp
offset = 120 # Get candles from 120 seconds before current time
period = 60 # Candle size of 60 seconds (1 minute)
print(f"You will get the candle from: {current_time - offset} to: {current_time}")
print("------\n")
# Fetch the candle data for the specified asset and time period
candle = API.get_candles(active=asset, period=period, start_time=current_time - offset, count=6000, count_request=1)
# Output the candle data
print(candle)
# Place a Buy order (Call)
amount = 1 # Define how much you want to trade (e.g., 1 unit)
expiration = 1 # Trade expiration time in minutes (example: 1 minute)
action = 'call' # "call" for buy/up, "put" for sell/down
# Execute the buy order
buy_order = API.buy(amount=amount, active=asset, action=action, expirations=expiration)
# Output the result of the buy order
if buy_order:
print(f"Buy order placed successfully: {buy_order}")
else:
print("Failed to place the buy order.")
except Exception as e:
print(f"An error occurred: {e}")
finally:
# Disconnect from the API
API.disconnect()
else:
print("Failed to connect to PocketOption API.")
" " i am geting this error WARNING:root:Error occurred: 'isDemo'
Hi. I studied your project pocketoptionapi on githab. Tell me, did you manage to connect to pocketoption market data in real time? I have a ready-made program for automated trading on this broker. It remains only to connect directly to the broker's market data. At the moment, I use ticks from tradermade.com and I see a slight discrepancy in price movement compared to pocketoption. If you have a solution for connecting to real-time market data for pocketoption, then I will be very grateful for your help and will send you my program for automated trading. It will not be superfluous in the household. Here is a link to a video with my bot https://www.youtube.com/watch?v=wTnscfLpqjo&t=62s
Activity
theshadow76 commentedon Feb 13, 2024
Yes, same here, I am getting the error of 41, I am going to try using webdriver, probably it's beeing blocked, so I will try that, but I am not giving up on this api that for sure :)
theshadow76 commentedon Feb 13, 2024
I'll tell you what happened, and if I recomend it.
vladdd183 commentedon Feb 13, 2024
Okay, thank you very much. I'll keep trying and I'll tell you too if I find a solution :)
vladdd183 commentedon Feb 13, 2024
@theshadow76
I've made progress.
It was the backslashes before the inverted commas.
Now we're getting binary data
However, after the first data is received, the disconnect occurs.
This is what the data should look like
Also you need "origin" header with website url, in my case: https://pocket-link19.co
i am using "websockets" python library
so, to all you need:
vladdd183 commentedon Feb 13, 2024
i made a little mistake with reconnection, now it works good.
Also you need only Backslashes and Origin Header
theshadow76 commentedon Feb 14, 2024
Thank you very much!
theshadow76 commentedon Feb 14, 2024
I'll adjust the code
theshadow76 commentedon Feb 14, 2024
@vladdd183
Hello!
Sorry to bother you again, but here:
I am getting this output:
looks like I am still getting that issue even tho I've added the hedears, but can you check if the data variable is the way it should be?
Maybe it had to be formated in a diferent way.
Let me know what you think!
theshadow76 commentedon Feb 14, 2024
or if you would like to share your code, that would help alot to.
thx
vladdd183 commentedon Feb 14, 2024
you shoud to set origin with site you using, not google
try:
https://po.trade/ (official link) or https://pocket-link19.co (mirror link)
official is prefered, use mirror only if official link banned in your country
theshadow76 commentedon Feb 14, 2024
Okey, let me check and I'll let you know
vladdd183 commentedon Feb 14, 2024
I use "websockets" library and "anyio" for async, also "rich" for better print formating
pip3 install websockets anyio richthis is the code (try to use second origin, that commented):
theshadow76 commentedon Feb 14, 2024
Thank you alot, I'll finish implementing it soon!
Thanks for your help!!!
90 remaining items
thacku commentedon Jun 10, 2024
It's invalid, can you provide new link to this
theshadow76 commentedon Jun 11, 2024
https://discord.com/invite/XmQ6vzFQAT
erfangnu commentedon Jun 11, 2024
@theshadow76 Hi, how can install this python package via
pip?theshadow76 commentedon Jun 11, 2024
You need to use git, talk to us in discord https://discord.com/invite/XmQ6vzFQAT
briancg42 commentedon Jun 11, 2024
Thank you! ⚡
sumittale5654 commentedon Jul 24, 2024
can anyone tell how i resolve the pocketoptionapi module not found
WanuPhiri commentedon Sep 12, 2024
I have a problem and I do not know how big or how to proceed.... I created a bot but when I run it I get this error. I think the pocketoptionapi modules are not well installed or not correct or the websockets issue. I need help to connect to Pocket Option
WARNING:root:WebSocket connection closed: received 1005 (no status received [internal]); then sent 1005 (no status received [internal])
ERROR:root:Error sending ping: received 1005 (no status received [internal]); then sent 1005 (no status received [internal])
I do not have pocketoptionapi so I am trying to use ssid
AttributeError: 'PocketOption' object has no attribute 'change_balance'

ERROR:root:Error sending ping: received 1005 (no status received [internal]); then sent 1005 (no status received [internal])
ERROR:root:Error sending ping: received 1005 (no status received [internal]); then sent 1005 (no status received [internal])
from pocketoptionapi import global_value
from pocketoptionapi.stable_api import PocketOption # Ensure this is correctly installed and imported
import time
import threading
import asyncio
import websockets
import ssl
Replace with your session ID
ssid = "mc4i2u7c721ajl9u0sr779jq8q" # Your valid session ID
Initialize PocketOption API with SSID
API = PocketOption(ssid)
Connect to the API
check = API.connect()
if not check:
print("Connection failed.")
exit()
THIS IS JUST THE SECTION OF THE CODE WHERE I HAD TO INPUT SSID
PLEASE HELP - THANK YOU
theshadow76 commentedon Sep 12, 2024
Hello! Please download the latest version here: https://github.com/theshadow76/PocketOptionAPI/releases/tag/v1.0.0
and if you still have issues, please enter to our discord server: https://discord.gg/H8er9mbF4V
theshadow76 commentedon Sep 12, 2024
Please talk to us here: https://discord.gg/H8er9mbF4V
WanuPhiri commentedon Sep 22, 2024
AttributeError: 'PocketOption' object has no attribute 'get_current_price'
how can i resolve this error I am stuck. please help
Mdbaizidtanvir commentedon Oct 13, 2024
how can i get this real time candle : " from pocketoptionapi.stable_api import PocketOption
import time
SSID: The session ID to authenticate with PocketOption
ssid = r"""42["auth",{"session":"a:4:{s:10:"session_id";s:32:"47f30c18560908460f79392abb5e2ea0";s:10:"ip_address";s:15:"103.167.208.249";s:10:"user_agent";s:111:"Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/129.0.0.0 Safari/537.36";s:13:"last_activity";i:1728768861;}52f0fbcaac716f54f471b6030a4434b9","isDemo":0,"uid":72758516,"platform":2}]"""
Initialize the PocketOption API, with demo set to True for safety
API = PocketOption(ssid, demo=True)
Connect to the API
check = API.connect()
if check:
try:
# Get the demo account balance
print(f'Demo Balance: {API.get_balance()}')
else:
print("Failed to connect to PocketOption API.")
" " i am geting this error WARNING:root:Error occurred: 'isDemo'
ALEXKODERODESSA commentedon Dec 15, 2024
Hi. I studied your project pocketoptionapi on githab. Tell me, did you manage to connect to pocketoption market data in real time? I have a ready-made program for automated trading on this broker. It remains only to connect directly to the broker's market data. At the moment, I use ticks from tradermade.com and I see a slight discrepancy in price movement compared to pocketoption. If you have a solution for connecting to real-time market data for pocketoption, then I will be very grateful for your help and will send you my program for automated trading. It will not be superfluous in the household. Here is a link to a video with my bot https://www.youtube.com/watch?v=wTnscfLpqjo&t=62s