2

I'm doing research to a problem occurred in our company. We have a front-end web portal which communicates by API with a back-end in a same syntax, for example: "www.123.com/api/v1/getCustomers".

Now we have a new clients who uses another companies back-end/API but our front-end. This means the front-end has to be custom made for this client in order to call the other companies API which for example has the syntax: "www.123.com/api/v1/getClients".

I'm trying to figure out a way how to program this in .NET to make these 2 API syntaxes the same so that the front-end can always stay the same and does not have to be made custom for every new client with a different back-end/API.

Image for illustration:

enter image description here

I hope someone can help me with this problem, I can't think about a solution for this.

Thanks in advance.

  • 3
    Do the APIs just have different URLs, or do they actually expect and provide data in different formats? – Jacob Raihle Mar 12 at 13:45
  • 1
    Yes, the API's have different URL's and are only GET methods(no parameters). The response structure of the JSON is different compared to the JSON structure of my companies API. – NielsStenden Mar 12 at 14:15
2

I see three immediate options. They may or may not apply depending on the specifics of your situation.

Front-end service layer

Separate all communication with the back-end into "services". Each API should have its own set of services, but they should provide the same functions to the rest of the front-end. You might have UserService_API1, UploadService_API1, UserService_API2, UploadService_API2, etc.. UserService_API1 and UserService_API2 both implement IUserService, though they interact with different APIs behind the scenes. The necessary services are then started up by some part of the application that is aware of which API you are running against, and then handed over to the parts of the application that actually need them.

Back-end service proxy

Build a proxy API that looks like "yours", but interacts with "theirs" behind the scenes. The front-end should be unaware of the difference, except for a different base URL.

Separate clients built on common library

A more flexible option (but also more expensive) would be to extract a library of "dumb" (not connected with a back-end) components from your client application, and build separate clients for each of the APIs. Each client would then have a common library to build on, but would be wholly responsible for doing the actual interactions with the back-end API and shovelling the data to/from components.

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.