Jump to content

External API - Best Practice


joey102030
 Share

Recommended Posts

What is the best way of interacting with an external API within ProcessWire:

(in this case it's FoxyCart but it could apply to any external API)

1. Store API data (eg customers, transactions) as pages in ProcessWire.

Pros:

- Can take advantage of PW's admin interface and upcoming Lister module

- Better performance/user experience

Cons:

- Setup time.

- Duplication of data (will need to have processes to keep local/remote data in sync)

2. Just pull in the data to the site through the external API as and when it's needed. 

Pros:

- Quick setup

- Data stored in one central location

Cons:

- Cannot use much of the in-built ProcessWire functionality for viewing/managing data.

- Potential performance degradation

Any thoughts are welcome  :)

Link to comment
Share on other sites

It would depend on a few things, but I think the main things to consider are:

  1. How often the data needs to be updated.
  2. If you want to query on it.
  3. If you want to display it on different pages.
  4. How unique the data is.

One or more of those things may be important and could sway the decision one way or another. For the specific example of customers and transactions, I would probably lean towards storing the information in ProcessWire pages, and using hooks to update it if needed.

Another thing to think about is potentially using MarkupCache to cache calls to the API. I use this on one site that uses a service for post code to location conversion.

Another website we manage (in PyroCMS) is a front-end to a much larger information system, and the data required for that website is just pulled out and updated daily. It uses some SQL to achieve that, and it'd be easier to do it in ProcessWire, but just another example :)

  • Like 2
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...