API Design: Generic API vs Specific APIs

We are building APIs for tax forms. We are started with a single form type and now we are extending to multiple forms. Potentially 7-8 forms this year and about 30-50 forms in the future.

Given this scenario, we are analyzing between the following two options

1. Generic API for all form types

URL: v1/forms

Body:

{

   "formType" : type,

   "payload" :

   {

      "x" : x,

      "y" : y

   }

}

2. Specific APIs for each form type

URL: v1/forms/formType

Body:

{

   "x" : x,

   "y" : y

}

Some of the forms have similar fields and validations might be similar too, but we don't know yet about all the forms.

I would like to hear opinions from both api designer and api consumer point of view on which approach you guys would choose and why. Thank you!

1 1 1,552
1 REPLY 1

Not applicable

I would prefer generic api. For one organization the api standard should be there which will be followed across all apis. if you have any specific requirement then you can add custom code to that api proxy.

Shared flow is available for the common code sharing purpose.