Jumpstart Pro can provide API access to your application with API tokens and authentication already handled for you.
Every user in Jumpstart Pro can have multiple API tokens. They can create and revoke tokens on API section of their user settings.
Tokens keep track of the time they were last used so users can verify their integrations are working correctly and keep an eye on them.
Authentication with the Jumpstart Pro API is as simple as passing in the
Authorization header. We provide an example of this header on the API token page to make it easy for users to implement
An example Authorization header would look like the following:
GET /api/v1/me.json Authorization: Bearer exampletoken
API controllers are defined in
app/controllers/api/v1/. We provide a
/api/v1/accounts.json endpoint out of the box. You can use these controllers as examples to base your API endpoints off of.
API controllers should inherit from
Api::BaseController instead of
ApplicationController. This enables API authentication. To skip authentication on an endpoint, add
skip_before_action :authenticate_api_token! to your actions.
Authentication works with Devise so you can access
current_user just like normal.
Since APIs don't have sessions, there is no
current_account equivalent like in the main app. You can use nested resources in the API to scope things under accounts if you want to separate them. For example:
API controllers are configured to return JSON by default.
We use JBuilder by default to provide simple JSON templates that most users are already familiar with. To improve JBuilder performance, we have added the OJ gem for enhanced JSON performance.
We also recommend checking out the fast_jsonapi gem from Netflix if you'd like to use an alternative.