Data API /data does not work

hi P123 staff,
I’m trying to use /data api to download some price data. I can use the generated token to download rank data using /rank API well. Sometimes i only need to download a particular ticker’s price data, for example i need to download IBM’s open(0) given a date, my request body is:

{

“precision”: 2,
“currency”: “USD”,

“tickers”: [
“IBM”
],
“pitMethod”:“Prelim”,

“formulas”: [
“open(0)”
],
“startDt”: “2023-09-08”,
“endDt”: “2023-09-08”,
“frequency”: “Every Week”,
“includeNames”: true,
“region”: “North America”,
“ignoreErrors”: true
}
But it does not work and returned with error message " TypeError: Failed to fetch" in swagger ui page:
https://api.portfolio123.com/docs/index.html#/Data/_data

Let me know if anything wrong here or just because i don’t have a data license?
thanks

Taofen

Keep in mind that the Data endpoint will only work for tickers IBM, INTC and MSFT without a vendor data license.

I was able to run this simple example in Swagger:

{
  "tickers": ["IBM"],
  "formulas": ["open(0)"],
  "startDt": "2023-09-07"
}

Note that using todays date will return an invalid period error since it doesn’t have 9/8 data yet.

My opinion is that Swagger is only useful to do a quick initial experiment with a given endpoint. I would not use it for any actual work because I find it to be unstable. It could be user errors on my part, but I randomly get ‘invalid request body’ errors when I tried to add more parameters from your example. I have no issue like that when using an IDE like PyCharm.

Thanks Dan for your quick reply. I was using java to call the data API and was not able to make it work, so tried to use swagger ui for a simple test.

I tried again in swagger with the token just generated, but still getting same error. see below error screenshot from swagger ui:

It looks like your using an old link to Swagger. Try https://api.portfolio123.com/docs/index.html

Just now tried the curl command, seems it’s working. Then Java should also work. I’ll check my java code.
But the swagger ui still does not work for me even for the simplest sample request.
Thanks Dan.

Taofen

Tried the new link. It’s working now. Perfect, thank you.

Taofen

hi Dan,
I found out the reason why my java code does not work. It’s because my java code needs to get some older data i.e. before 2010. P123 will return http code 406 with message “Not acceptable”. If i use some date after 2018-09-08, Java code also works, seems there is a 5 year limitation for all data including price data.

I tried the new swagger ui link again, getting same issue if I put an older date.
My request body:
{
“tickers”:[“IBM”],
“formulas”:[“open(0)”],
“startDt”:“2008-01-05”,
“endDt”:“2008-01-12”
}

Error message from new swagger ui:

The Data endpoint does have a 5 year limit if you dont have a vendor data license. It is mentioned on the Swagger page - “You can try it without a license with IBM, MSFT & INTC and 5Y history.”

Uhm… Data endpoint should allow technical data w/o a license. I think we never got around to fixing it.

I remember you or other p123 staff mentioned this - price data does not need data license. Now i have to work around to get the price using more credits in /rank api. Hope p123 can resolve this soon.