from Hacker News

Ask HN: How do I write good API client libraries?

by jnankin on 2/24/15, 6:26 PM with 0 comments

I'm writing some new API client libraries in a variety of languages (PHP, Java, Ruby, C#, JS, Python) for an API.

Is there a list of best practices or a good resource for doing this? Both in general, and language specific?

Here are somethings I'd expect to see in such a resource: - How to handle instantiation of the library (static functions with static API credentials vs new instances of the library with instance variables for API credentials) - How to pass binary files - Using required arguments for required parameters of an API operation vs a hash or dictionary - How to name function calls - How to structure code/classes in relation to the API's design - What good client libraries should return or throw as an exception ... and so on