The Skill API offers a simple and convenient way to use other Skill's methods and export your own to help other Skill creators.
The Skill API uses the Mycroft Message Bus to communicate between Skills and wraps the interaction in simple Python objects making them easy to use.
A method can be tagged with the
skill_api_methoddecorator. This will handle all the basics of making the method available to other Skills over the Message Bus.
def my_exported_method(self, my_arg, my_other_arg):
"""My skill api method documentation
The decorator will generate everything needed for accessing the method over the Message Bus and extract the associated docstring.
The Skill API works over the Message Bus. This requires that the return values are json serializable. All common Python builtin types (such as List, String, None, etc.) work well, however custom classes are not currently supported.
from mycroft.skills import MycroftSkill, skill_api_method
def robber_lang(self, sentence):
"""Encode a sentence to "Rövarspråket".
Each consonant gets converted to consonant + "o" + consonant,
vowels are left as is.
Returns: (str) sentence in the robber language.
wovels = "aeiouyåäö"
tokens = 
for char in sentence.lower() and char.isalpha():
if char not in wovels:
tokens.append(char + 'o' + char)
return ' '.join(tokens)
If you want to make use of exported functionality from another Skill, you must fetch that Skill's
SkillApi. This will give you a small class with the target Skill's exported methods. These methods are nothing special and can be called like any other class's methods.
To access the
robber_lang()method we created above, we could write:
from mycroft.skills.api import SkillApi
self.robber = SkillApi.get('robber-skill.forslund')
NewRobberSkillis initialized, it will assign the API from the Skill
self.robber. We then run the exported method
robber_lang()passing the argument
NewRobberSkillwill therefore speak something like "hoh e lol lol o wow o ror lol dod".
The Mycroft CLI has an
:apicommand for exploring Skill APIs.
will show any exported method from the
robber-lang.forslundSkill. Each exported method's docstring will automatically be extracted and presented, providing information on how each method is intended to be used.