Skip to content

fix(div,splits): align spec with live API behaviour - #18

Open
alexpipipi wants to merge 1 commit into
mainfrom
fix/div-splits-spec-accuracy
Open

alexpipipi wants to merge 1 commit into
mainfrom
fix/div-splits-spec-accuracy

Conversation

@alexpipipi

Copy link
Copy Markdown
Member

Found while rewriting the Corporate Actions docs article. The spec for /div/{ticker} and /splits/{ticker} disagrees with the live API in four places. Everything below was re-verified with live requests against eodhd.com/api on 2026-09-16 using the demo key.

1. fmt default is csv, not json

The spec declares default: json. Omitting fmt returns CSV from both endpoints:

$ curl -s "https://eodhd.com/api/div/AAPL.US?api_token=demo&from=2025-01-01"
Date,Dividends
2025-02-10,0.25
2025-05-12,0.26
$ curl -s "https://eodhd.com/api/splits/AAPL.US?api_token=demo&from=2000-01-01"
Date,"Stock Splits"
2000-06-21,2.000000/1.000000

This is the one with real downstream cost: every generated SDK and every Redoc reader is being told the wrong default, so a client that omits fmt and parses the body as JSON breaks.

The parameter is also case-sensitive with a silent fallback — fmt=JSON, fmt=Json and even fmt=xml all return CSV. Only lowercase json returns JSON. Added to the description.

2. text/csv is now documented as a 200 representation

Consequence of the above: with the default being CSV, documenting only application/json under 200 left the spec self-contradictory. Added a text/csv schema and example alongside the existing JSON one.

This is the most opinionated part of the PR — happy to drop it if you'd rather keep the response block JSON-only.

3. 400 Invalid request parameters is never returned

Bad parameters give 200 with an empty array:

$ curl -s -w "HTTP %{http_code}" "https://eodhd.com/api/div/AAPL.US?api_token=demo&from=garbage&fmt=json"
[]HTTP 200

Removed.

4. 403 is returned and was undocumented

A ticker outside the key's subscription returns 403, not 401 or 404:

$ curl -s -w "HTTP %{http_code}" "https://eodhd.com/api/div/IBM.US?api_token=demo&fmt=json"
Forbidden. Please contact support@eodhistoricaldata.comHTTP 403

Added.

Also narrowed the 404 description: it said "not found for the specified ticker or date range", but an out-of-range date window returns 200 with an empty array (see 3), so only the ticker half is true.

Checks

npm run validate, npm run build and npm run check all pass locally. The 3 redocly warnings are pre-existing and relate to the options schemas, untouched here.

Verified against the live API on 2026-09-16.

- fmt default is csv, not json. Omitting fmt returns CSV from both
  endpoints. The parameter is also case-sensitive: fmt=JSON, fmt=Json
  and fmt=xml all silently fall back to CSV; only lowercase json
  returns JSON.
- Document text/csv as a 200 representation, since it is what the
  default now produces.
- Remove the 400 response. Invalid parameters do not produce it —
  from=garbage returns 200 with an empty array.
- Add the 403 response, which is returned and was undocumented
  (ticker outside the key's subscription).
- Narrow the 404 description: an out-of-range date window returns
  200 with an empty array, not 404.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant