From 1b11519ee7ebb7b47e3ba0bba36badd85933cd0a Mon Sep 17 00:00:00 2001 From: Athanasius Date: Thu, 4 Nov 2021 11:03:51 +0000 Subject: [PATCH] schemas: READMEs: Centralise "detecting CAPI lag" advice --- schemas/README-EDDN-schemas.md | 20 +++++++++++++++++--- schemas/commodity-README.md | 10 +++------- schemas/outfitting-README.md | 7 ++++--- schemas/shipyard-README.md | 7 ++++--- 4 files changed, 28 insertions(+), 16 deletions(-) diff --git a/schemas/README-EDDN-schemas.md b/schemas/README-EDDN-schemas.md index e4c8c6a..a7461d8 100644 --- a/schemas/README-EDDN-schemas.md +++ b/schemas/README-EDDN-schemas.md @@ -62,13 +62,27 @@ the available endpoints and how they work. There is some [third-party documentation](https://github.com/Athanasius/fd-api/blob/main/docs/README.md) by Athanasius. +It is *not* recommended to use CAPI data as the source as it's fraught with +additional issues. EDMarketConnector does so in order to facilitate +obtaining data without the player needing to open the commodities screen. + +#### Detecting CAPI data lag + When using the Companion API please be aware that the server that supplies this data sometimes lags behind the game - usually by a few seconds, sometimes by minutes. You MUST check in the data from the CAPI that the Cmdr is -docked (`["commander"]["docked"]` is `True`) and that the station and -system (`["lastStarport"]["name"]` and `["lastSystem"]["name"]`) match those +docked, and that the station and system names match those reported from the Journal before using the data for the commodity, outfitting -and shipyard schemas. +and shipyard schemas: + +1. Retrieve the commander data from the `/profile` CAPI endpoint. +2. Check that `commander['docked']` is true. If not, abort. +3. Retrieve the data from the `/market` and `/shipyard` CAPI endpoints. +4. Compare the system and station name from the CAPI market data, + `["lastStarport"]["name"]` and `["lastSystem"]["name"]`, + to that from the last `Docked` or `Location` journal event. If either does + not match then you MUST **abort**. This likely indicates that the CAPI + data is lagging behind the game client state and thus should not be used. --- diff --git a/schemas/commodity-README.md b/schemas/commodity-README.md index 7abbedf..c2a4516 100644 --- a/schemas/commodity-README.md +++ b/schemas/commodity-README.md @@ -65,13 +65,9 @@ It is *not* recommended to use CAPI data as the source as it's fraught with additional issues. EDMarketConnector does so in order to facilitate obtaining data without the player needing to open the commodities screen. -1. Retrieve the commander data from the `/profile` CAPI endpoint. -2. Check that `commander['docked']` is true. If not, abort. -3. Retrieve the data from the `/market` and `/shipyard` CAPI endpoints. -4. Compare the system and station name from the CAPI market data to that - from the last `Docked` or `Location` journal event. If either does not - match then you MUST **abort**. This likely indicates that the CAPI data is - lagging behind the game client state and thus should not be used. +Please read +[the guidance on checking for CAPI lag](README-EDDN-schemas.md#detecting-capi-data-lag) +before utilising CAPI data for EDDN messages. Note that CAPI `/market` data will sometimes have the `StatusFlasg` per item, which are defined as optional in this schema (because they're not in diff --git a/schemas/outfitting-README.md b/schemas/outfitting-README.md index f3e4370..090fc61 100644 --- a/schemas/outfitting-README.md +++ b/schemas/outfitting-README.md @@ -11,9 +11,10 @@ documentation for a schema such as this. The primary data source for this schema is the ED Journal event `Outfitting`. -You MAY also source this data from the CAPI `/shipyard` endpoint. See -[commodity-README.md#using-capi-data](commodity-README.md#using-capi-data) -for guidance on this. +You MAY also source this data from the CAPI `/shipyard` endpoint. +Please read +[the guidance on checking for CAPI lag](README-EDDN-schemas.md#detecting-capi-data-lag) +before utilising CAPI data for EDDN messages. You only need the `name` key's value for each member of the `modules` array. diff --git a/schemas/shipyard-README.md b/schemas/shipyard-README.md index 295ff5a..33016a4 100644 --- a/schemas/shipyard-README.md +++ b/schemas/shipyard-README.md @@ -11,9 +11,10 @@ documentation for a schema such as this. The primary data source for this schema is the ED Journal event `Shipyard`. -You MAY also source this data from the CAPI `/shipyard` endpoint. See -[commodity-README.md#using-capi-data](commodity-README.md#using-capi-data) -for guidance on this. +You MAY also source this data from the CAPI `/shipyard` endpoint. +Please read +[the guidance on checking for CAPI lag](README-EDDN-schemas.md#detecting-capi-data-lag) +before utilising CAPI data for EDDN messages. You only need the `name` key's value for each member of the `PriceList` array (if using Journal, it will be from the `ships` array if using CAPI