Write API Integrations and SDKs in an Elegant Way


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.
While we have provided tools to work with APIs from PSR-7, PSR-17, and PSR-18, we do not currently have a standardized structure for building API integrations.

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.
  • Middleware
  • Custom response decoding
  • Retries
  • SDK Connector
  • Testing helpers

Related: Write API Integrations in Laravel and PHP Projects with Saloon

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.

The post Write API Integrations and SDKs in an Elegant Way appeared first on Laravel News.
Join the Laravel Newsletter to get Laravel articles like this directly in your inbox.