חפש מזהה משתמש לפי שם משתמש או כתובת דוא"ל

I’m aware I can lookup users vai the JSON API, but as I’m doing this from Ruby that Discourse is running itself, wouldn’t it be more straightforward to call the function I need directly rather than mess with a call to the JSON API? Is that really the recommended way to do this? I see no use of the JSON API anywhere else in the importers I’ve looked at.