PYTHON API Extraction Not Yielding Results
Hi Team,
Hoping for your help in checking the code of the client below, for some reason, they are not receiving any results when querying for MarketDepth:
Code:
def ExtractRaw(token, json_payload): try: outputfilepath = str(_outputFilePath + _outputFileName + str(os.getpid()) + '.csv.gz') if os.path.exists(outputfilepath): print(f"File {outputfilepath} already exists. Loading data from local file.") df = pd.read_csv(outputfilepath, compression='gzip') else: _extractRawURL="https://selectapi.datascope.refinitiv.com/RestApi/v1/Extractions/ExtractRaw" _header={} _header['Prefer']='respond-async' _header['Content-Type']='application/json; odata.metadata=minimal' _header['Accept-Charset']='UTF-8' _header['Authorization']='Token'+token resp=post(_extractRawURL,data=None,json=json_payload,headers=_header) if resp.status_code!=200: if resp.status_code!=202: message="Error: Status Code:"+str(resp.status_code)+" Message:"+resp.text raise Exception(message) _location=resp.headers['Location'] print("Get Status from "+str(_location)) _jobID="" while True: resp=get(_location,headers=_header) _pollstatus = int(resp.status_code) if _pollstatus==200: break else: print("Status:"+str(resp.headers['Status'])) sleep(_retryInterval) #wait for _retyInterval period and re-request the status to check if it already completed json_resp = loads(resp.text) _jobID = json_resp.get('JobId') _getResultURL = str("https://selectapi.datascope.refinitiv.com/RestApi/v1/Extractions/RawExtractionResults(/'" + _jobID + "\')/$value") print("Retrieve result from "+_getResultURL) resp=get(_getResultURL,headers=_header,stream=True) response_content = resp.content # This retrieves the response content as bytes response_size = len(response_content) # Calculate the size in bytes print(f"Size of response: {response_size} bytes")
Answers
-
Hi @SamGarcia ,
I have tried the request you're using and got the result properly
1.extraction request, got http 202 response
2.From that, retrieve the result and got http 200 response with data
Could you please try printing the response status code and text (if any) for more information.
0 -
Hi @SamGarcia ,
I've tried running the code you've posted and got the result properly with the content returned. It would be great if we can see the response you got in more detail (status code and its content)
Here's the resources related to Tick History
- Tick History page in developer portal, it includes its overview, quickstart guide, documentation, tutorials
- In the tab, you can download sample code such as LSEG Tick History Python Code Samples, LSEG Tick History REST Tutorials Postman collection, and much more
- Show the API Reference Tree provides API Reference Tree, allowing you to explore the complete functionality availability within DataScope Select including working C# code examples (with HTTP requests and responses) and comprehensive and authoritative documentation for all available REST API functionality
I hope this helps and please let me know in case you have any further questions.
0 - Tick History page in developer portal, it includes its overview, quickstart guide, documentation, tutorials
-
The _getResultURL variable should look like this:
_getResultURL = str("https://selectapi.datascope.refinitiv.com/RestApi/v1/Extractions/RawExtractionResults('" + _jobID + "')/$value")
0 -
Hello All,
is that possible that is related to my account permission? I am still not able to fetch data via python code. I have changed _getResultURL as suggested.
these are cases:
1. "Identifier": "0#LCO:", "IdentifierType": "ChainRIC", "QueryStartDate": "2025-03-13T04:30:00.000Z", my py code get data,2. "Identifier": "0#LCO:", "IdentifierType": "ChainRIC", "QueryStartDate": "2023-03-13T04:30:00.000Z", my py code cannot get data,
please let me know how to debug further? how to fix it?
0 -
When the extraction is completed and the status code is 200. The response will contain the JobId and Notes.
You need to print the Notes so we can check the extraction information. The code should be like this:
0 -
Hello, this is output. looks like permission issue? is that something you can help
Send Login requestStatus: 200{'@odata.context': 'https://selectapi.datascope.refinitiv.com/RestApi/v1/$metadata#RawExtractionResults/$entity', 'JobId': '0x0952bf3b65baf18f', 'Notes': ["Extraction Services Version 18.3.1.48082 (0d5e6bbb8e4a), Built Jan 10 2025 19:16:51\nUser ID: 9038901\nExtraction ID: 2000000884346978\nCorrelation ID: CiD/9038901/AAAAAA.0952bf3b65aaf18f/RA\nSchedule: 0x0952bf3b65baf18f (ID = 0x0000000000000000)\nInput List (1 items): (ID = 0x0952bf3b65baf18f) Created: 21-03-2025 10:11:01 Last Modified: 21-03-2025 10:11:01\nReport Template (4 fields): _OnD_0x0952bf3b65baf18f (ID = 0x0952bf3b65caf18f) Created: 21-03-2025 10:10:57 Last Modified: 21-03-2025 10:10:57\nSchedule dispatched via message queue (0x0952bf3b65baf18f)\nSchedule Time: 21-03-2025 10:10:58\nProcessing started at 21-03-2025 10:10:58\nProcessing completed successfully at 21-03-2025 10:11:02\nExtraction finished at 21-03-2025 10:11:02 UTC, with servers: xc09rbjpQ08\nInstrument <CHR,0#LCO:> expanded to 84 RIC instances: LCOF0 to LCOZ9.\nTotal instruments after instrument expansion = 84\n\n\n(CHR,0#LCO:,IEU,LCOTOT) row suppressed for lack of 'Distribution Rights - Tick History never allowed for PE 0' permission.\nYour request was truncated due to your Contract Entitlement\nReport suppressed because no instruments are permitted\n"]}Getting result from: https://selectapi.datascope.refinitiv.com/RestApi/v1/Extractions/RawExtractionResults('0x0952bf3b65baf18f')/$valueSize of response: 0 bytesError: Response content is empty.
0 -
Sorry. I can't modify the permission.
Please contact your LSEG account team or sales team directly to verify your account's permission.
0
Categories
- All Categories
- 3 Polls
- 6 AHS
- 36 Alpha
- 166 App Studio
- 6 Block Chain
- 4 Bot Platform
- 18 Connected Risk APIs
- 47 Data Fusion
- 34 Data Model Discovery
- 684 Datastream
- 1.4K DSS
- 614 Eikon COM
- 5.2K Eikon Data APIs
- 10 Electronic Trading
- Generic FIX
- 7 Local Bank Node API
- 3 Trading API
- 2.9K Elektron
- 1.4K EMA
- 248 ETA
- 552 WebSocket API
- 37 FX Venues
- 14 FX Market Data
- 1 FX Post Trade
- 1 FX Trading - Matching
- 12 FX Trading – RFQ Maker
- 5 Intelligent Tagging
- 2 Legal One
- 23 Messenger Bot
- 3 Messenger Side by Side
- 9 ONESOURCE
- 7 Indirect Tax
- 60 Open Calais
- 275 Open PermID
- 44 Entity Search
- 2 Org ID
- 1 PAM
- PAM - Logging
- 6 Product Insight
- Project Tracking
- ProView
- ProView Internal
- 22 RDMS
- 1.9K Refinitiv Data Platform
- 639 Refinitiv Data Platform Libraries
- 4 LSEG Due Diligence
- LSEG Due Diligence Portal API
- 4 Refinitiv Due Dilligence Centre
- Rose's Space
- 1.2K Screening
- 18 Qual-ID API
- 13 Screening Deployed
- 23 Screening Online
- 12 World-Check Customer Risk Screener
- 1K World-Check One
- 46 World-Check One Zero Footprint
- 45 Side by Side Integration API
- 2 Test Space
- 3 Thomson One Smart
- 10 TR Knowledge Graph
- 151 Transactions
- 143 REDI API
- 1.8K TREP APIs
- 4 CAT
- 26 DACS Station
- 121 Open DACS
- 1.1K RFA
- 104 UPA
- 191 TREP Infrastructure
- 228 TRKD
- 915 TRTH
- 5 Velocity Analytics
- 9 Wealth Management Web Services
- 91 Workspace SDK
- 11 Element Framework
- 5 Grid
- 18 World-Check Data File
- 1 Yield Book Analytics
- 46 中文论坛