I'd like to write a python library to wrap a REST-style API offered by a particular Web service. Does anyone know of any good learning resources for such work, preferably aimed at intermediate Python programmers?
I'd like a good article on the subject, but I'd settle for nice, clear code examples.
CLARIFICATION: What I'm looking to do is write a Python client to interact with a Web service -- something to construct HTTP requests and parse XML/JSON responses, all wrapped up in Python objects.
An API wrapper provides a way to access an API through a particular programming language or interface, which can help streamline the process of making API calls.
API wrappers are language-specific kits or packages that wrap sets of XML API calls into easy-to-use functions. The wrapper programmatically calls multiple API calls without requiring user interaction, further automating projects. Veracode provides API wrappers for these languages: C# Java.
Idiomatic consistency Put simply, this means your wrapper should smell like language in which it is written — Ruby like Ruby, Java like Java, PHP like PHP, and so on. This usually comes into play when language conventions bleed through an API in the form of method and variable names.
I can't point you to any article on how to do it, but I think there are a few libraries that can be good models on how to design your own.
PyAws for example. I didn't see the source code so I can't tell you how good it is as code example, but the features and the usage examples in their website should be a useful design model
Universal Feed Parser is not a wrapper for a webservice (it's an RSS parser library), but it's a great example of a design that prioritizes usage flexibility and hiding implementation details. I think you can get very good usage ideas for your wrapper there.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With