We introduce Niebrzydowski algebras, algebraic structures with a ternary operation and a partially defined multiplication, with axioms motivated by the Reidemeister moves for YY-oriented trivalent spatial graphs and handlebody-links. As part of this definition, we identify generating sets of YY-oriented Reidemeister moves. We give some examples to demonstrate that the counting invariant can distinguish some YY-oriented trivalent spatial graphs and handlebody-links.