Serverside API requests

Dear forum,

I have a general question.
Im building a site based on Ghost where I want to make API calls from a Shopware instance. Shopware offers an API where the client has to authenticate via username and key. The API access allows reading and writing which is why running the API requests client-side is not an option.
What would be the best way to get content of these requests inside ghost?

While doing research I already found articles like this. While this may work in terms of not making the API-credentials publically available this would mean additional steps everytime when updating ghost.
I have read here about an alternative (officially supported?) way of registering helpers via Ghost-Apps. I don’t find any official documentation about this an I am wondering, if this is still something supported?

I appreciate any help and suggestions for my use-case!

Thank in advance and best regards

Just a kind question: what does one have to do to get any answer on a thread? I posted two threads (with for me reasonable questions) in the past days and none of them were answerend in any way. The Ghost-team in general seems to be active in the forum in terms of other (I’d say “less technical”) topics.

Best regards

Adding server side code to Ghost comes up frequently and unfortunately there is not a good solution. Until there is some sort of plugin system (yes the same plugin functionality which makes Wordpress such a big headache sometimes) is added to core, it’s only going to be hacking.

I’ve added custom code to Ghost core for many reasons, including SSO and registering all custom helpers from a directory ),and they work reasonably well. But the caveat is, changes to core may/will be overwritten with upgrades.

Also there seems to be a feature to add custom apps, but last time I checked, Ghost only loads apps from a trusted folder within the core. So the ‘content/apps’ folder seems to be useless at this point. But don’t take my word on that, it’s been a while…

This statement in your post is a bit conflicting with the theme of your post: “I want to make API calls from a Shopware instance.” I think you meant from Ghost to Shopware. If not, making calls to Ghost using the API is not such a bad deal and there is a good deal of REST end point that can be utilized

Hi Mark,

thanks for the reply!
Since writing the post I made similar findings as you described for myself. For now I was able to add custom helpers within core. The main goal with this solution would be for sure to only make changes to the core in as little directories as possible. So in case of a ghost update it’s just a matter of pasting the custom .js files in one directory and not to many different places.
With one of these custom helpers I was then able to make API calls from ghost to shopware (thanks for pointing out!).

I guess a directory such as “content/apps” could be a good solution to mount custom helpers into the appropriate core folder. This would solve the problem of custom helpers being overwritten in the course of updates. I hope that is something on the roadmap of the Ghost team.

Yes, a good habit would be to keep any of your custom code outside of core folders (versions). ‘content’ would be a good place as my understanding is that it does not get overwritten by upgrades

For updating a core file, I try to limit that to one line only and then require a file,etc. outside and work from there. I create an install and uninstall script(can do one script with param) which runs a basic search and replace on the core file I am updating