5 ms·
I don't really understand why developers use SDKs/libraries at all when the RESTful APIs are easy enough to consume directly.
by pbreit 6y ago
I don't really understand why developers use SDKs/libraries at all when the RESTful APIs are easy enough to consume directly.
- echelon 6y agoHandroll marshalling for every payload, handle the auth sequence, check arguments, endpoint semantics, sort out sparse versus full entity patching mismatch, build in retry that matches status codes, and do this for every endpoint. If you're moving fast, you don't have time for this. Especially if it isn't your core competency / core product.
- TedDoesntTalk 6y ago> sort out sparse versus full entity patching mismatch I thought we are talking about Shopify... where people browse and search products, buy products, make a transaction, and review past orders/invoices/transactions. Where does PATCH fit?
- arcturus17 6y agoCustomers do all that, but admins also upload and edit products, orders, and other entities typical of an eCommerce model. I’m assuming it’s that?
- throwaway53453 6y agoShopping cart is an obvious one.
- pbreit 6y agoMost APIs there's usually only a handful of endpoints. There's never an auth sequence, just a simple API key. Patching is exceedingly rare. I don't want an SDK to auto-retry. Interacting with an API actually usually is or needs to be a core competency. I still think the major promise of RESTful APIs is avoided by the prevalence of SDKs.
- nullsense 6y agoDepends to be honest. Where they expose OpenAPI docs it's dead simple to generate the models from that. In .NET I use those plus Refit and boom. Now I have full control and it took barely any time.
- martinald 6y agoI like this approach too, but a non trivial amount of time the models come out wrong. I assume this is because of bad openapi docs, but maybe I'm wrong. What do you use to consume the openapi docs and generate models with?
- nullsense 6y agoHaha yes we got bitten by that on a recent project but it resulted in a minor bug we patched pretty quick. I don't mind taking that downside. Can't remember the exact name of it but it's one of the open API generators that supports all the major languages. Unfortunately the csharp and dotnet core generator generates clients with RestSharp which doesn't use the almighty HttpClient, so I consider them unusable, but it generates the models faithfully. If it so happens the open API spec is wrong that's unfortunate. Though usually if they have an SDK I just use the models directly from the SDK! That's the absolute sweet spot for me. Especially if their SDK is generated off open API it probably stays perfectly or acceptably accurate with incentives to correct any inaccuracies.
- cies 6y agoOne word answer: Types. If you dont use a language with strong type safety the benefits are less. For instance the OpenAPI3 (Swagger-NG) standard. It allows the typing/schema'ing of the JSON bodies. It also provides a bunch of generators[1] that can be used to generate client libs. And when the languages of the client libs permit it, those libs come with lots of type safety and greatly reduce boilerplate. 1: https://openapi-generator.tech/docs/generators/ https://openapi-generator.tech/docs/generators/
- pbreit 6y agoOne of the reason I don't like types. There really shouldn't be much boilerplate to passing JSON around back and forth.