Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

WebbieWorks's avatar

Laravel & External API

I am trying to use an API token to pull data from an outside crm.

Is there a tutorial on how I can set up laravel for this?

In a nutshell, I am trying to pull an ecommerce admin backend and use it on my laravel front end. I need to pull product data and all.

Example API from outside crm:

{
  "meta": {
    "total_count": 0
  },
  "included": [
    {}
  ],
  "data": [
    {
      "id": "string",
      "type": "string",
      "attributes": {
        "manufacturer": "string",
        "model": "string",
        "year": "string",
        "slug": "string",
        "location": "string",
        "serial_number": "string",
        "stock_number": "string",
        "condition": "string",
        "price": "string",
        "listing_type": "string",
        "private_notes": "string",
        "rank": "string",
        "extra_data": "string",
        "created_at": "2021-10-16T10:38:22.016Z",
        "updated_at": "2021-10-16T10:38:22.016Z",
        "sold_at": "2021-10-16T10:38:22.016Z",
        "deleted_at": "2021-10-16T10:38:22.016Z"
      },
      "relationships": {
        "primary_image": {
          "data": {
            "id": "string",
            "type": "string"
          }
        },
        "images": {
          "data": [
            {
              "id": "string",
              "type": "string"
            }
          ]
        },
        "videos": {
          "data": [
            {
              "id": "string",
              "type": "string"
            }
          ]
        },
        "specifications": {
          "data": [
            {
              "id": "string",
              "type": "string"
            }
          ]
        },
        "private_fields": {
          "data": [
            {
              "id": "string",
              "type": "string"
            }
          ]
        },
        "translations": {
          "data": [
            {
              "id": "string",
              "type": "string"
            }
          ]
        },
        "attachments": {
          "data": [
            {
              "id": "string",
              "type": "string"
            }
          ]
        }
      }
    }
  ]
}
0 likes
4 replies
tykus's avatar

Is there an SDK for the service; it could save you a tonne of work?

Otherwise, you can simply use the HTTP client that comes with Laravel, to fetch the data.

If you want to go even further, you can wrap the HTTP Client with your own Client class with your own specific methods for retrieving specific data; and create domain-specific classes for to represent the data. Essentially, making your own package/SDK for interacting with the API data.

Which approach is correct for you depends on what you want or need to do.

2 likes
jlrdw's avatar

To add, most api's have documentation and examples. Double check that they don't have such a page.

1 like

Please or to participate in this conversation.