0

I am writing a webapp that aggregates a multitude of different APIs to gather data related to astronomy, and then returns the aggregated data in a single API endpoint. There are 7 API's being used, two of which I built myself. In the most general sense, there are two types of APIs. One group's responses are combined and analysed to return a data that is dependent on all the APIs, and one group is independent, the response to the front end user only depending on one API.

This logic is all in a python file which I will be hosting on GCP, as I want to minimize the complexity of the React Front End, so that it just needs to make a call and display the result, and not have much logic dependent on the responses - all data processing being done here in the BE.

Dependent Group:

  • DarkSky API
  • Light Pollution (custom)
  • Google Maps Elevation API
  • Sunset time

The responses of these are processed/analyzed and used to determine a single result.

Independent Group:

  • Weather Station Data (custom)
  • Google Maps Directions API
  • ISS Current Location

The responses of these are each independent.

I originally had this all in one file, and all returned in a single API endpoint to the Front End. I have since moved the two custom-built APIs to their own files, but still returning to the same single endpoint.

Now I am considering how I can further optimize. My current ideas:

  • Improve the Organization of files/functions. For Example: I was thinking to put each non-custom API call in a file apis.py or similar, and have the main file call that. Does it make much sense to have a seperate file for all your external API calls? I was thinking it kinda fit "seperation of concern"

  • Having the Dependent Group return with one end point, and the independent group each return their own, giving a total of four API calls from the front end instead of the current one. This may reduce latency in waiting for API calls to wait for one another. It would increase complexity of the FE, but as long as the BE puts in in the right format first, it should be able to just display the response from each API with minimal processing.

Are these good moves? Is there something I should keep in mind when doing this, or do something totally different? Any pointers on how to improve the readability, maintainability, and functionality of a program that combines many APIs into one would be great.

I can share the code upon request, but don't really expect anyone to take their time to do a code review for me, and would generally prefer to keep this at a high level.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.