Is it possible to include custom api scripts in a published module ? And will these scripts be playable by anybody who purchased the module, even with only a basic free account ?
You can certainly include a handout with links to API scripts, but only Pro Subscribers will be able to make any use of them. The API's state object won't be part of the game either, so you'll need to store any configuration data via another means. I suggest Base64 encoding it and putting it in a handout of a known name. You shouldn't rely on the Token IDs or Character IDs staying the same either.
Thanks for your quick answer ! Is it something common for still published modules, or would it be better to avoid using API because it restricts these features to pro subscribers ?
If I were doing a module, I would provide 100% of the functionality without the API, then look at ways to enhance things with the API. For example, I might have a pit trap in a room. I might have the room look normal, but have an image on the GM layer that represents the open pit. When players move onto the space, you can move to the GM layer and then push it down to the Maps layer. Then I might provide an API script that detects when a player moves into that area (or through it) and prompts the GM to "Open pit?" with a whispered API command button which would then move the player token back to the spot where it entered (or maybe the center of the pit) and move the graphic from the GM layer to the Map layer. So the non-pro users isn't missing out on any content, but the Pro subscriber has some quality of life improovements.
Great exemple, good advice, i will try to follow it ! :)