Exposing webapi to third party

351 views Asked by At

How third party client would use my api methods who has no knowledge of my DTOs (the objects web service returns or takes as parameter). Do i need to expose my DTO's somehow?

1

There are 1 answers

0
ManOVision On BEST ANSWER

Documentation is your friend here. Publish some docs showing what the DTOs should be. If you know your clients, you could create packages that contain the proper DTOs. We did this for our .NET clients. We published a portable class library to nuget so any of these clients could download the package and use them. However, we have since stopped because this may overwhelm the client app developer. I.e. Let's say you have 100 DTOs, but a simple client app really only needs 5 of them. By including the package, there are now so many options that it might be confusing to know which DTO's to actually use and this leads to the client app maybe doing more than it should. We like to keep our client apps lean by only using DTOs that it needs. Yes, there is a little DTO definition duplication.

On the flip side, if you went the package route, you could essentially build up an SDK for using your API. You'll see Microsoft do this a lot to help with complexity of areas such as Azure Storage or Azure Service Bus. All of these have backing REST APIs, but the SDK ensures it's used in the designed and possibly the most optimized way.