Getting Started

Getting Started with the Daffy Public API

This guide will walk you through the process of getting started with our API, including authentication and retrieving your user and fund information.

Getting your API key

To use the Daffy Public API, you will need to authenticate your requests using an API key. To get one you'll first need to sign up for a Daffy account at https://daffy.org/signup (opens in a new tab).

Once you have created an account, log in and follow the Authentication instructions to generate your API key.

Fetching your User Profile

Once you have obtained your API key, you can start consuming resources from the Daffy API. Let's start with getting your user information. This resource represents a Daffy user account and fund.

We'll assume your API key is daffy_production_1234, with that just send a GET request to the current user endpoint:

curl https://public.daffy.org/v1/users/me -H "X-Api-Key: daffy_production_1234"

A successful response would look something like this:

{
  "id": 1234,
  "name": "Api User",
  "avatar": "https://static.daffy.org/avatars/1234/your-avatar-url",
  "cover_image": "https://static.daffy.org/covers/1234/your-profile-cover-url",
  "slug": "api-user-one",
  "fund_name": "Api User's Fund",
  "visible": true,
  "current_fund": {
    "id": 1234,
    "name": "Api User's Fund",
    "summary": "A Fund to illustrate API usage",
    "causes": [
      {
        "id": 11,
        "name": "International",
        "color": "#FEC398",
        "logo": "https://static.daffy.org/assets/default-non-profit-avatars/Default_International.png"
      },
      {
        "id": 18,
        "name": "Sports",
        "color": "#9EDFF3",
        "logo": "https://static.daffy.org/assets/default-non-profit-avatars/Default_Sports.png"
      }
    ],
    "users": [
      {
        "id": 1234,
        "name": "Api User",
        "avatar": "https://static.daffy.org/avatars/1234/your-avatar-url",
        "slug": "api-user-one"
      },
      {
        "id": 4321,
        "name": "Api User's Spouse",
        "avatar": "https://static.daffy.org/avatars/4321/your-spouse-avatar-url",
        "slug": "api-user-spouse"
      }
    ]
  },
  "follows_user": false,
  "follows_viewer": false
}

Congratulations! You have successfully authenticated your requests and fetched your profile from the Daffy Public API.

From here, you can explore the resources available in the API Reference to integrate Daffy into your projects and build amazing applications that help make a positive impact in the world. We also have a few examples for you to kickstart with, check them out in our GitHub (opens in a new tab).

If you have any questions or feedback, please don't hesitate to contact our support team.

Happy coding!