Developer API

FanHalo API v1

A small, predictable JSON API for the parts of FanHalo that matter for integrations: catalogue, authentication, feed, wallet and the money actions. Send Authorization: Bearer <token> and you are done — no cookies, no CSRF dance.

Units

Every amount in the JSON API is an integer number of cents. The HTML forms use dollars, the API uses cents, and the responses always name the unit so there is never a guess.

The web forms accept 12.50. The API accepts 1250.

Errors

Errors come back as JSON with an error key and a real HTTP status code.

  • 400 the request was malformed
  • 401 the token is missing or expired
  • 402 the wallet does not hold enough money
  • 409 the action was already done (duplicate key)

Endpoints

MethodPathAuthWhat it does
GET/api/v1/healthnoService status and version
GET/api/v1/plansnoCommercial plans with prices
GET/api/v1/creatorsnoCreator directory, paginated
GET/api/v1/creators/:usernamenoOne creator with their plans
GET/api/v1/posts/:idnoA post with its media and comment count
POST/api/v1/auth/registernoCreate an account, returns a token
POST/api/v1/auth/loginnoExchange credentials for a token
POST/api/v1/auth/logoutyesInvalidate the current token
GET/api/v1/meyesThe signed in user
GET/api/v1/feedyesPosts from the people you follow
GET/api/v1/walletyesBalance and recent ledger entries
POST/api/v1/wallet/deposityesTop up the wallet (cents)
GET/api/v1/notificationsyesNotifications for the signed in user
POST/api/v1/posts/:id/unlockyesUnlock a locked post
POST/api/v1/subscribeyesSubscribe to a creator plan
POST/api/v1/tipyesSend a tip to a creator

Example

curl -X POST https://fanhalo.mintsource.dev/api/v1/auth/login \
  -H 'Content-Type: application/json' \
  -d '{"email":"fiona@fanhalo.test","password":"fan12345"}'

The response carries token and user.

Money

curl -X POST https://fanhalo.mintsource.dev/api/v1/tip \
  -H "Authorization: Bearer $TOKEN" \
  -H 'Content-Type: application/json' \
  -d '{"username":"luna","amount":1500,"message":"great work"}'

1500 is $15.00, because the API speaks cents.