How to smooth curves in Graph Editor by Script
Basically, you have to take care of two things: first selecting the relevant bones you want to smooth and second to switch to the graph editor context. For some reason, selecting and deselecting the respective curves did not effect the operator. I rather locked the respective curves I did not want to smooth. 

import bpy

# types = {'VIEW_3D', 'TIMELINE', 'GRAPH_EDITOR', 'DOPESHEET_EDITOR', 'NLA_EDITOR', 'IMAGE_EDITOR', 'SEQUENCE_EDITOR', 'CLIP_EDITOR', 'TEXT_EDITOR', 'NODE_EDITOR', 'LOGIC_EDITOR', 'PROPERTIES', 'OUTLINER', 'USER_PREFERENCES', 'INFO', 'FILE_BROWSER', 'CONSOLE'}

def smooth_curves(o):
    current_area = bpy.context.area.type
    layer = bpy.context.view_layer

    # select all (relevant) bones
    for b in o.data.bones:
        b.select = False
    o.data.bones[0].select = True
    layer.update()

    # change to graph editor
    bpy.context.area.type = "GRAPH_EDITOR"

    # lock or unlock the respective fcurves
    for fc in o.animation_data.action.fcurves:
        print(fc.data_path)
        if "location" in fc.data_path:
            fc.lock = False
        else:
            fc.lock = True

    layer.update()
    # smooth curves of all selected bones
    bpy.ops.graph.smooth()

    # switch back to original area
    bpy.context.area.type = current_area

    # deselect all (relevant) bones
    for b in o.data.bones:
        b.select = False
    layer.update()

# currently selected 
o = bpy.context.object
smooth_curves(o)