How to decide in hook_nodeapi() if it was invoked after creating/updating node via Services module? I am developing a custom module, which should do things in hook_nodeapi() only if the node is being created/edited via Services. I couldn't find any data that is available at this point for deciding if the node is via Services or not.

I am aware of a possible solution, using request_uri() and deciding based on that (https://drupal.stackexchange.com/a/8568/1930), but it seems so wrong. Hardcoding the endpoint name is plain wrong. Workaround this by providing an admin interface and depend on configuration?

So, I would rather avoid the above, but couldn't come up with anything else so far. I am curious if others have had similar problems before and if there is a better solution.

UPDATE

The accepted answer should be used, as that is the cleanest solution. Unfortunately, I had to use a different one, which might still be useful to others so I am sharing it here: https://gist.github.com/Temaruk/5884209
I think there's a point in the system not normally telling you this, since we want to avoid any kind of coupling between the systems. Based on that I guess there's no built in way to get the information you want. Strictly speaking, you should probably consider why you are doing what you are doing, as it's not good practice.

Possible methods:
You could implement a custom node resource, which hands over node creation to the regular services callback after having done

$node-&gt;creator = 'services';


or possibly:

$node_origin = &amp;drupal_static('node_creation_tracker');
$node_origin = 'services';


after which you could retrieve this data with the same method. Implementing a resource is not a complicated process, but requires quite a bit of knowledge about services.