# ktor


02/06/2023, 9:29 AM
One question with regards to best practices: I'm implementing a service which performs calls against the Twitter and Mastodon API. Should I create two different clients (with different credentials configured) or just one client (where credentials are configured on each call)?


02/06/2023, 9:32 AM
I don’t know if this is a best practice, but my experience has been that when integrating with other APIs, one client per API works best. Each API tends to have its own quirks with regards to error handling, headers, serialisation, etc., and those things can often be more conveniently configured for the whole HTTP client than for an individual request.
👍 1
For example, I use Jackson, and the Jackson configuration I want for deserialising responses from Twitter might be different from what I want when talking to Mastodon. The Jackson object mapper plugs in to the HTTP client as a plugin, so two different object mapper configs means two different HTTP clients.
I have experimented with reusing an HTTP client engine between multiple HTTP clients, though, in case it helps to share the low level resources like threads and connection pools. I don’t know if it’s worth it.


02/07/2023, 11:51 AM
Thanks for the answer, this was also my gut feeling.