https://api.donate.gg/api/v2. Call them from your server.
Search as the person types
GET /v2/beneficiaries?term= returns the charities and
campaigns that match, ranked together, best match first.
On a coin page, read
GET /v2/configs/{configId}/beneficiaries for weighted campaign, charity and person profiles. Charity profiles include their website and socials. A campaign includes its supported beneficiaries with weights relative to each other. When a campaign completes it remains the named recipient, and existing coins continue paying it.
What to know before you design the picker:
- The picker is empty until the person types.
termis required, so there is nothing to show before the first character. Suggestions says what you can show there if you want something. - Search returns only what can go into a new config. A result is selectable when it appears,
and returns
eligible: true. Config creation checks eligibility again. - Add up the selected results’
receiverCountvalues to check the five-recipient limit. A charity or Tiltify campaign counts once. A Donate campaign counts once per charity it pays. - To load more matches, send
nextCursoras thecursorquery parameter with the sameterm,typeandsource. A null cursor means you have reached the last page. - Types share the limit. Charities and campaigns are ranked together with no quota for
either, so a common word can fill the list with one type. If your picker has tabs, send one
request per tab with
type=charityandtype=campaign. sourcefilters campaigns.donateis a campaign created on donate.gg andtiltifyone imported from Tiltify. Sendingsourcewithouttype=campaignanswers400.- An unknown parameter is refused. A cache-busting parameter such as
?_=123answers400. - Names can repeat. Two charities or two campaigns can share a name. Read the chosen one in full to tell them apart.
issues:
Show a result
Every search result has the same fields, so one row component can show charities and campaigns.
Keep
type and id for the choice. The two together are the beneficiary you name in a config.
A charity has a page on donate.gg only once it has signed up there. One that has not is still a
result, with its own name and logo, and can be named in a config: only its url is null.
More kinds of recipient will be added, and research is the next one. A new kind shares the same
display fields. When you meet a
type you do not know, show the row from name, imageUrl and
url, with a neutral badge, and do not open a details view for it.Keep within the rate limit
Each keystroke is a request. Wait until the person pauses typing (250 ms works well), drop the answer to a request you no longer need, and send your API key from your server so searches count against your organization’s limit instead of the 20 a minute an IP address gets. See Rate limits.Suggestions before the person types
Search needs a term. To fill the list before anyone types, show the charities and campaigns that have raised the most:GET /v2/charities?sort=raised and
GET /v2/campaigns?sort=raised. An item of either list starts
with the same seven fields as a search result.
A directory of every charity
GET /v2/charities pages through every charity listed on
Donate, each in full with its totals. It is for a browse page, where the search above is for a
box someone types in.
Without
sort the order is name, or relevance when you send term. Each item is the same
object as GET /v2/charities/{charityId} returns. A charity
that is hidden, disabled or has opted out is never in the list.
Read one in full
A search result is a summary. To show more before the person confirms, read the one they chose by itstype.
- type: charity
- type: campaign
GET /v2/charities/{charityId} starts with the same seven
fields and adds the mission (description), websiteUrl, registrationNumber with its
country, location, socials, and stats, which is everything the charity has received
through Donate. The city and the registration number are what tell two charities with the same
name apart.eligible. It is true when the recipient can be named in a new config. A completed
campaign stays readable with eligible: false. Eligibility is checked again when you create the
config, so treat it as a hint for your interface, not a guarantee.
Show what a coin donates to has both responses in full and
the field to use for each part of a details view.
When the charity is not listed
If the person cannot find a charity, it may not be on Donate yet. You can look it up in an official register and ask for it to be added. See Request a charity.Next
With atype and an id for each choice, create the config:
POST /v2/configs. The coin guide and
the donate button guide show where it goes from there.