Discussion 2.4 Companion API Changes

I have a small application/database I've written that uses the API to gather system, station, and commodity price data for offline analysis. Since the 2.4 update, I've had to modify my API calls and the way I process the data as there have been significant changes to the way the API presents the returned JSON data.

All of this is fine with me as it's mainly small changes that only take a few minutes to recode, however I notice that the module and ship price data for stations has disappeared and cannot be found on either the /profile or /market pages.

Does anyone know if this has moved to another page somewhere I'm not aware of, or just been removed altogether? If the latter, that's quite disappointing as I was building up quite a nice locator database for ships and modules.
 
Yup, that works perfectly! Thank you. :)

I've been having to piece together bits of information from all over the place to develop this application, sometimes even downloading other community tools and then capturing the traffic to see what's happening. I don't suppose there's any documentation for the API, or at least a list of the available endpoints and JSON structures anywhere that FD keeps up to date with these changes? I've seen some stuff regarding the API on patch notes in the past, but there have also been changes that aren't listed there.

On a slight side-note, it strikes me as a bit odd that FD have said in the past we should only query the cAPI once per minute to keep server load to a minimum, but then they split up the service so we now have to make 3 separate calls in quick succession just to get system, commodity and ship/module data when docked.
 
I don't know of any FDev documentation for the cAPI (only for the Journal file) and the only endpoints known to me are /profile, /market and /shipyard.

FDev only told us to not spam the cAPI but never gave any time/request limits. Any restriction is self inflicted by the different tool programmer.
 
OK. Thanks for the responses. I've re-worked it so that it uses 3 calls now instead of one to get all the data, so all is good. :)

Would have been two, but they've still not fixed the issue where the ship data is missing on the first API call for module/ship prices, even now it's moved to a different endpoint. At least now we have to make multiple calls anyway, so I can just split the requests up and do the ships last without worrying about making too many cAPI calls in quick succession.
 
Last edited:
OK. Thanks for the responses. I've re-worked it so that it uses 3 calls now instead of one to get all the data, so all is good. :)

Would have been two, but they've still not fixed the issue where the ship data is missing on the first API call for module/ship prices, even now it's moved to a different endpoint. At least now we have to make multiple calls anyway, so I can just split the requests up and do the ships last without worrying about making too many cAPI calls in quick succession.

Lol, now instead of 1-2 queries, you have to make 3-4 to get everything. Yeah, very efficient. :)
 
I only check "/market" if there is a commodity service and "/shipyard" if there is an "outfitting" or "shipyard" service at the station, like:
Code:
        # Grab the commander profile
        self.profile = getData("profile")

        # Grab the market, outfitting and shipyard data if needed
        portServices = self.profile['lastStarport'].get('services')
        if self.profile['commander']['docked'] and portServices:
            if portServices.get('commodities'):
                res = getData("market")
                if int(res["id"]) == int(self.profile["lastStarport"]["id"]):
                    self.profile["lastStarport"].update(res)
            hasShipyard = portServices.get('shipyard')
            if hasShipyard or portServices.get('outfitting'):
                # the ships for the shipyard are not always returned the first time
                for attempt in range(3):
                    # try up to 3 times
                    res = getData("shipyard")
                    if not hasShipyard or res.get('ships'):
                        break
                    if self.debug:
                        print("No shipyard in response, I'll try again in 5s")
                    time.sleep(5)
                if int(res["id"]) == int(self.profile["lastStarport"]["id"]):
                    self.profile["lastStarport"].update(res)
 
I'm doing much the same thing, but it doesn't really matter with regard to getting the ship prices. Even if there is a shipyard at the station, the cAPI never returns the ship price data on the first query for /shipyard; you have to query the endpoint twice. It's been bugged for ages now and was the same when everything was in the one endpoint. Querying the /shipyard endpoint for modules first (if the station has outfitting) and then making a second query is the workaround I'm using for the moment. The only issue is if I only want to pull ship prices and nothing else as that requires 2 cAPI calls.

I can see in your code above, you've had to make it retry the ship prices query up to 3 times to accommodate this. I was hoping to avoid doing retries to keep requests to a minimum but, like I said in a previous post, at least now I can do it without worrying that FD think I'm spamming the service.
 
Last edited:
Lol, now instead of 1-2 queries, you have to make 3-4 to get everything. Yeah, very efficient. :)

Yup. Not sure what the logic is behind this change, but I'm sure it makes sense to someone at FD ;)

They also randomly changed all the commodity names with this patch so that all the spaces have been removed from their returned cAPI names, and they've moved the proper display names to another attribute. I swear sometimes they do this stuff just so we have to recode our applications with each patch!
 
Last edited:
Looks like the ship prices issue has been addressed in today's patch: "Fixed ship prices sometimes not being returned from /shipyard" :D

Will check this out later once everything is back up.
 
Forgot to update this thread last week after I'd checked, but it works perfectly for me now. Ship price data is returned from the cAPI every time without fail :)
 
Back
Top Bottom