/
How to make an API adapter

How to make an API adapter

You’re better off if you know the concepts behind building an API adapter of your own rather than using a pre-written one you don’t understand.

These are the questions you should be asking:

  • What is an API adapter? Why is it helpful?

    • Many modern applications have APIs which are expressed as web APIs. An API adapter in the context of Iguana X is a library written in Lua which makes it easier to use the API than if one was writing the code without any structure.

  • How does an API adapter make it easier?

    • It comes down to solving some of the ‘boilerplate’ things one would need to do in order to access an API.

  • What are the ‘low lying’ boilerplate things an adapter can implement to make the API easier to use?

    • Think about these problems:

      • How do I authenticate against the API?

      • How do I know what calls exist for the API?

      • For each call how can I make it easier to remember what parameters the API accepts and then use the data which comes back?

      • If I make a bad call against the API can my adapter handle the error messages that come back?

The answers to all these questions are slightly different for every API since each vendor and application does them slightly differently. But if you ask these questions one by one and methodically answer them then it becomes possible to build good adapters to each API. Which leads to one final question…

Is it better to use an opaque adapter for an API that I don’t understand?

Or, is it better than I understand the core principles of how an adapter is written so that if need it do something different, that I can adapt it to meet my needs?

 

Related content

The 80-20 rule
The 80-20 rule
Read with this
How can I connect Iguana to a web application with JSON
How can I connect Iguana to a web application with JSON
More like this
Integrating a sales customer relationship system (CRM) with an accounting system.
Integrating a sales customer relationship system (CRM) with an accounting system.
Read with this
Shell Adapter
More like this
How can one map IDs from two systems if one or both don't have the ability to specify the other ID?
How can one map IDs from two systems if one or both don't have the ability to specify the other ID?
Read with this
Build Adapters to really push the product
Build Adapters to really push the product
More like this