I'm trying to find best practices for deep integration with external APIs. The service I'm currently creating can call APIs, but when receiving data from these APIs, I find myself having to validate and sanitize the data.
I know it's not possible to use Eloquent as an ORM for API data, but do we have a solution or practice to ensure that the data received from the API is validated and sanitized?
I'm using the Shopify API and I'm integrating multiple endpoints. It would be much easier to use if I had a framework or ORM that ensured all data received was formatted.
You can even validate the data externally or via the
Illuminate\Support\Facades\Validator
facade like this:To use third-party APIs in Laravel, it is recommended to useLaravel Data. Laravel Data is a package that provides a simple and intuitive way to interact with various data sources, including APIs.
Using Laravel Data, you can easily define models that represent the data returned by your API. These models can then be used to interact with the API, making requests and handling responses in a familiar and consistent way.