Quickstart

Register a Lunar API account, capture a bearer token, and call your first authenticated endpoint.

Quickstart

This walkthrough takes you from zero to an authenticated request. All you need is curl.

  1. Register an account

    Send a username and password to POST /auth/register. You get back a user object and an accessToken.

    curl
    curl -s -X POST https://api.lunargroup.dev/auth/register \
      -H 'Content-Type: application/json' \
      -d '{"username":"winter_fe","password":"correct horse battery staple"}'
  2. Save the access token

    The response includes accessToken with the Bearer prefix already attached. Use it verbatim as your Authorization header.

    capture the token
    TOKEN=$(curl -s -X POST https://api.lunargroup.dev/auth/register \
      -H 'Content-Type: application/json' \
      -d '{"username":"winter_fe","password":"correct horse battery staple"}' \
      | jq -r .accessToken)
  3. Call an authenticated route

    Pass the token straight through as the Authorization header. Here we fetch a random fox.

    random fox
    curl -s https://api.lunargroup.dev/images/fox/random \
      -H "Authorization: $TOKEN"
  4. Refresh your token when needed

    Logging in again rotates the token and invalidates the old one. Call POST /auth/login with the same credentials to get a fresh accessToken.

Where to next