Write API Integrations and SDKs in an Elegant Way
Last updated on by Paul Redmond
Fansipan is a simple package that allows you to write your API integrations or SDKs in an elegant way:
Building API integrations can be time consuming. After you have found an API client to use, you’re faced with lots of configuration to remember and it’s hard to repeat requests without copying and pasting. You’ll often find yourself writing the same boilerplate code over and over again.
Three concepts are at the core of this package, including connectors, requests, and responses. These concepts provide an object-oriented approach to standardize how you work with APIs, including the following main features:
- Provides a simple, easy-to-learn, object-oriented syntax that standardizes how you interact with APIs.
- Abstract API integrations into classes so you can keep your tidy and centralized.
- Configuration is fast and can be shared across all your requests.
- HTTP Client agnostic.
- Great for building your next PHP SDKs or package/library
- Scalable with lots of API integrations across many team members.
- Custom response decoding
- SDK Connector
- Testing helpers
Here's the gist of how you can make a request using the package's connector interface:
$connector = new Connector();$request = new GetHeadersRequest();$response = $connector->send($request);
You can get started with this package by reading the official documentation; you can also view the source code on GitHub at phanxipang/fansipan. This package is in a beta state at the time of writing, so the final APIs and documentation might change slightly.