The TGB Public API is a RESTful API. Our API has resource-oriented URLs, it accepts JSON-encoded data and returns JSON-encoded data. We use standard HTTP response codes to communicate status of the request to the consumers and standard verbs to manipulate the resources.
The API is designed to be integrated with one of the consumer's back-end services. It won't work with browsers since our CORS policy doesn't allow this and it would require consumers to store API login and password on the browser side.
It's recommended to use Staging environment during the development to build your application. Donations made to the Staging environment use real crypto networks so you can test everything end-to-end.
Base API URL
Staging environment: https://public-api.tgb-preprod.com
Production environment: https://public-api.tgbwidget.com
Passing Access Token
API uses Bearer authentication (also called “token authentication”) therefore Access Token should be passed in a Authorization Header with a Bearer prefix, example:
Authorization: Bearer YOUR_ACCESS_TOKEN
Example:
if your Access Token is abcdef123456 then token should be passed like this
Human readable description of error. Do not use it for programmatic error handling because these messages are likely to be changed over time
errorType
Yes
Human readable description of error. Do not use it for programmatic error handling because these messages are likely to be changed over time
meta
Yes
Type of error, for example: err.authentication, err.forbidden, err.validation, etc.
meta.errorCode
No
In some cases this error code will be present in the response. This property along with errorType can be used for programmatic error handling. See Error Codes section of documentation for list of available errors
Example of Error response when validation error happened:
{"data": {"errorMessage":"Request body validation failed","errorType":"err.validation","meta": {"errorCode":"INVALID_REQUEST""validationErrorMessage": "\"login\" is required","failedAttributes": [ {"attributeName":"login","message":"\"login\" is required","path": ["login" ] } ] } },"requestId":"325a3fa0-d3b1-433c-b36a-573368cdbe2e"}
Here is another example of Error response when you pass expired Access Token
{"data": {"errorMessage":"Auth token is invalid. Please refresh tokens or log in again","errorType":"err.forbidden","meta": {"errorCode":"INVALID_JWT_TOKEN" } },"requestId":"0a2420df2-544c-47fd-a501-a69ebbdf1493"}
Endpoints documentation
Login
POSThttps://public-api.tgbwidget.com/v1/login
This endpoint should be used to obtain pair of Access and Refresh Tokens
No Access Token required
This endpoint should be used to retrieve a list of available nonprofits. This list is used to display a list of Organizations so users can choose one of them for donation.
Access Token required
Query Parameters
Name
Type
Description
sortColumn
String
Specifies a column on which to sort the organizations list.
sortOrder
String
Specifies that the values in the specified column should be sorted in ascending or descending order. Descending is the default sort order.
{"data": {"organizations": [ {"id":99,// ID of organization"name":"TGB Preproduction","logo":"https://static.tgb-preprod.com/organization_logo/04fdb90f-10e9-4fe7-a6f8-f0c6689735b1.jpeg","country":"USA","allowsAnon":true,// Are anonymous Donations allowed"nonprofitTaxID":"01-0000000","areNotesEnabled":true,// Are Donation notes allowed"isReceiptEnabled":true,// Indicates whether Donation// receipt email sending is forbidden by organization"createdAt":"2022-05-09T12:02:29.603Z","state":"AL","city":"Washington","postcode":"20036","nonprofitAddress1":"1712 N St NW","nonprofitAddress2":"Suite 101","uuid":"b3d94d59-48a5-4bc1-acee-f4e88148357d","areFiatDonationsEnabled":true,"areCryptoDonationsEnabled":true }, ] },"requestId":"some uuid"}
Both screenshots represent an embedded appearance. You need to use script the endpoint response in order to display the embedded widget. The first screen shows the old widget UI(uiVersion=2). The second screen shows the latest UI (uiVersion=2).
Example how what the trigger button looks like. depending on the passed uiVersion, a popup will contain either an old or a new UI.
receiptEmail is optional. The Giving Block won't send receipt email If organization has isReceiptEnabled as false (available in response from GetOrganizationsList method) or your API account has default setting that tells us to not send any receipt emails for transactions created through the API. In case if you need The Giving Block to send receipt emails - ask us to set up your API account accordingly and make sure you send receiptEmail in CreateDepositAddress request.
If donation is not anonymous - fields firstName, lastName, addressLine1, addressLine2, country, state, city, zipcode are required.
Returned pledgeId field is an unique identifier for the donation. It will be sent along with transactions' notifications as pledgeId to link events to donations.
Important note: If XRP is passed as pledgeCurrency, the depositTag will be returned in the response. This property should be shown to clients - if the depositTag is not specified in the address, we wouldn't be able to correctly process this transaction. The example how it should be presented can be found in Stock Donation Flow page.
Some notes on qrCode property: it is base64 encoded QR code image that represents depositAddress . That being said, when you decode that QR code, you'll get a text that is in depositAddress field. This image can be used to display on your donation page to give to the donor an easy way to enter depositAddress to make a donation.
This list is used to display a list of Transactions so users can see all transaction information. Please note that this endpoint is not accessible by default. To be able to access it, please contact The Giving Block Integrations Team
Access Token required
Request Body
Name
Type
Description
pagination.page*
number
Current page
pagination.itemsPerPage*
number
Maximum items per one page
filters.date.from
number
Timestamp in milliseconds, only transactions that were created after that point will be returned
filters.date.to
number
Timestamp in milliseconds, only transactions that were created after that point will be returned
filters.date.externalId
string
Only transactions with externalId assigned to them will be listed
{"data": {"transactions": {"data": [ {"transactionDate":"2023-03-21T08:57:33Z","currency":"SOL","amount":0.069,"grossAmount":1.49,"totalFees":0.070862672,"netAmount":1.428783328,"txId":"3yNGgzMmrxnFYUcJ2Dxo3QUn4dyiFmGXdxeZzVZuPXvtU4QFQbimDZrDq9iVUbj4neHxnZKymAEhMAXSa68PxPkM","destination":"CJYVKdU4SFCkjk3BiCrvaKX9Nvb9VUMvXbN125ASRrga","origin":null,"anon":true,"donationNotes":"Hope that will help people to survive","fundsDesignation":null,"organizationId":1189132264,"organizationName":"The Best Organization Ever","donorName":null,"donorFirstName":null,"donorLastName":null,"donorEmail":null,"donorAddress":null,"city":null,"zipcode":null,"state":null,"country":null,"id":"1754","type":"Deposit","timestampms":"1679389053444","method":"Crypto","totalFeesPercentage":4.729724554294425,"netAmountCurrency":"USD","uuid":"b4f14acb-44e2-43ac-919e-4af630ae399b","originalTransactionId":null,"externalId":"some-external-id" }, {"transactionDate":"2023-03-21T08:41:24Z","currency":"USD","amount":11.69,"grossAmount":11.69,"totalFees":0.35,"netAmount":11.33,"txId":"char_hWSlEpaeYA4FRHsJa7AigwiG","destination":"a0341cbe-bfba-49f3-85d1-b9eeaea71562","origin":null,"anon":false,"donationNotes":"","fundsDesignation":null,"organizationId":1189132264,"organizationName":"The Best Organization Ever","donorName":"Example Donor","donorFirstName":"Example","donorLastName":"Donor","donorEmail":"example-email@thegivingblock.com","donorAddress":"111 Test st","city":"Allentown","zipcode":"18109","state":"Pennsylvania","country":"United States","id":"1752","type":"Deposit","timestampms":"1679388084929","method":"Card","totalFeesPercentage":3,"netAmountCurrency":"USD","uuid":"d90f0950-c3a4-4581-bc7e-52b6dd54177e","originalTransactionId":null,"externalId":"some-external-id" }, {"transactionDate":"2023-03-21T08:49:11Z","currency":"FOUR","amount":100,"grossAmount":6694,"totalFees":0,"netAmount":6694,"txId":null,"destination":"07ccc3b6-35df-4dd6-8ac8-856b5b442aab","origin":null,"anon":false,"donationNotes":"That means a lot to me, thank you for all things you do","fundsDesignation":null,"organizationId":1189132264,"organizationName":"The Best Organization Ever","donorName":"Example Donor","donorFirstName":"Example","donorLastName":"Donor","donorEmail":"example-email@thegivingblock.com","donorAddress":"111 Test st","city":"Allentown","zipcode":"18109","state":"Pennsylvania","country":"United States","id":"1753","type":"Deposit","timestampms":"1679388551398","method":"Stock","totalFeesPercentage":0,"netAmountCurrency":"USD","uuid":"23975e28-09e6-4c75-be89-63b79cf21316","originalTransactionId":null,"externalId":null } ],"pagination": {"page":1,"itemsPerPage":3,"count":578 } } },"requestId":"2d1f73f9-1742-4298-b454-177d92073dcf"}