API

TechWilk edited this page Jul 7, 2016 · 5 revisions

OneBody doesn't have much of an API yet, but there are plans for building one.

It is possible to script operations within OneBody using curl or whatever (this script is an example of doing that). To make that a bit easier, we support HTTP Basic authentication, explained below.

Authentication

Every call to the API requires http basic authentication:

  • Username is the email address of a user with super admin privileges.
  • Password is their API key

You can specify basic auth with curl with the switch -u, like so:

curl -u admin@example.com:APIKEYHERE http://onebody.yoursite.com/...

Getting an API Key

To create an API key, you can use the Rails console:

onebody run rails console
me = Person.where(email: 'your-email@example.com').first
me.api_key = SecureRandom.hex(25) # 50 hex digits
me.save!
  • Other installation methods:
bundle exec rails console
me = Person.where(email: 'your-email@example.com').first
me.api_key = SecureRandom.hex(25) # 50 hex digits
me.save!

Authentication Endpoint

If you need to check someone's email+password against OneBody to sign them into a separate app, use the Authentication API.