Sample code

  1. Download the sample code here*:* https://github.com/silverback-ventures/sample-partner-api

    **‣

  2. Update your .env file with the info we provided you: CLIENT_ID, CLIENT_SECRET and ISSUER_HOST.

  3. Start the node server by running: node index.js

  4. Visit http://localhost:8080 and sign in with your Daffy account.

API methods

Authentication

You can read more about how OpenID authentication flow works with Auth0 here.

Get current user & active fund info

You can obtain basic account information for a user by calling the me endpoint. This endpoint contains the basic profile info for the user as well as the current fund information like the causes it supports and the members that belong to it.

CURL -X GET "<https://api.daffy.org/public/api/v1/users/me>" \\
-H 'Content-Type: application/json' \\
-H "Authorization: ... ..."

Response:
{
  "id": 3,
  "name": "Alejandro Crosa",
  "avatar": "<https://static.daffy.org/avatars/3/c6c19873-ab26-456d-94f6-b9fa91b772a2>",
  "cover_image": null,
  "slug": "alejandro-crosa",
  "fund_name": "Alejandro Crosa's Fund",
  "visible": null,
  "current_fund": {
    "id": 3,
    "name": "Alejandro Crosa's Fund",
    "summary": "My own personal fund",
    "causes": [
      {
        "id": 1,
        "name": "Education",
        "color": "#C6ADF8",
        "image_url": "<https://static.daffy.org/causes/cause-education.png>",
        "image_url_dark": "<https://static.daffy.org/causes/cause-education-dark.png>"
      },
      {
        "id": 7,
        "name": "Social Advocacy",
        "color": "#FFB2E0",
        "image_url": "<https://static.daffy.org/causes/cause-social-advocacy.png>",
        "image_url_dark": "<https://static.daffy.org/causes/cause-social-advocacy-dark.png>"
      }
    ],
    "users": [
      {
        "id": 3,
        "name": "Alejandro Crosa",
        "avatar": "<https://static.daffy.org/avatars/3/c6c19873-ab26-456d-94f6-b9fa91b772a2>",
        "slug": "alejandro-crosa"
      },
      {
        "id": 6768,
        "name": "Lady",
        "avatar": "<https://static.daffy.org/avatars/avatar-placeholder.png>",
        "slug": "lady"
      }
    ]
  }
}

Get the user balance

You can obtain the user’s current realtime balance by calling this endpoint:

CURL -X GET "<https://api.daffy.org/public/api/v1/users/me/balance>"\\
  -H "Authorization: ... ..." \\
  -H 'Content-Type: application/json'

Response:
{
  "amount": 20,
  "pending_deposit_balance": 0,
  "portfolio_balance": 0,
  "available_balance": 0
}

The balance is broken down into:

amount this is the available money that can be used to make donations, usually you only care about this value. It includes pending fund that might be arriving to the fund.

pending_deposit_balance these are incoming funds into the fund that had not yet arrived

portfolio_balance this is the amount of funds that are invested and might need to be liquidated to satisfy a donation

available_balance this is the amount that’s in-flight and invested now