Terminology - Hooks or API?

Hi hi!

Would anyone be to shed some light on a nerdy question of mine… should i refer to the python scripts that use things like get_media_panel_custom_ui_actions as Python Hooks or Python API scripts?

The Flame Fish menu lists it as Python > Rescan Python Hooks. …but I thought hooks were the older style, export_hook.py, batch_hook.py, etc. I am guessing hooks might encompass the API? Or vice versa?

Just want to get my terminology correct.

Thanks in advance!

From a software developer’s perspective they were two different things. However, people may mix up the terminology frequently, so don’t count on consistency here.

And API (application programming interface) is essentially a service that exposes a set of functionality that is controlled by an external party. OpenGL is an example of an API, it provides a set of defined function and data structures that allow you to interact with the GPU. Unless an API call is made, this service will not do anything. It relies on an API client to control it.

Hooks on the other end are essentially pre-defined points where an external party can modify the behavior of an application or service that is running on it’s own. Flame is primarily controlled by the user. But at various pre-defined points, it says ‘maybe someone would like to know about this event’ or ‘maybe someone would like to modify what I’m about to do’. You can the register a callback with that hook. Every time a relevant action or event occurs that has a hook defined, the application or service will check if anyone registered. If so, it will initiate the callback, provide context, and process any answer that came back. If nobody registered, it just proceed with business as usual.

In some cases the callback called by a hook may also utilize an API at the same time. So the hook initiates a script based on an event, but then the callback may use an API to look up data or compute some things before formulating the response the hook returns at the end.

So in summary - an API controls the service in totality. Hooks are there for others to raise the hand and say I want to know or I want to modify your answer.

1 Like

Thanks for that!

So its a hook that calls the menus, but then API to interact with objects like <PyClip>. I think i get it now.

1 Like