{"_id":"569ec3804a5c8b0d00744b32","githubsync":"","slug":"overview","sync_unique":"","updates":[],"__v":5,"hidden":false,"link_url":"","order":999,"api":{"auth":"required","params":[],"results":{"codes":[]},"settings":"","url":""},"body":"## API Basics\n\nThe Watsi API gives you access to give Watsi donors credit. Once that credit reaches a certain value, those donors will then receive a Watsi gift card with their balance allowing them to experience Watsi first hand and donate to a patient's healthcare.\n\nBefore you do anything, you should [create a free Watsi account](https://watsi.org/donors/sign_up) which will allow us to give you API credentials. Once you have an account, reach out to us and we'll set you up with an `API_KEY` to use the API.\n\n## REST easy\n\nThe Watsi API strives to be [RESTful](https://en.wikipedia.org/wiki/Representational_state_transfer) and attempts to conform to [JSON API](http://jsonapi.org/) specification.\n[block:callout]\n{\n  \"type\": \"warning\",\n  \"title\": \"Accessing via AJAX\",\n  \"body\": \"Currently, our API endpoints are not set up with CORS and cannot be accessed from browser-side JavaScript. You will have to proxy the request through a server.\"\n}\n[/block]","title":"Overview","version":"569ebe312d320817003b80b8","category":"569ebf7d8f6d4b0d00f13b81","project":"53a47666447c0ba24d1a85cb","link_external":false,"type":"basic","user":"56981fe21547031700fca1b5","createdAt":"2016-01-19T23:15:12.995Z","excerpt":"General info about using the Watsi v1 API","metadata":{"title":"","description":"","image":[]},"childrenPages":[]}

Overview

General info about using the Watsi v1 API

## API Basics The Watsi API gives you access to give Watsi donors credit. Once that credit reaches a certain value, those donors will then receive a Watsi gift card with their balance allowing them to experience Watsi first hand and donate to a patient's healthcare. Before you do anything, you should [create a free Watsi account](https://watsi.org/donors/sign_up) which will allow us to give you API credentials. Once you have an account, reach out to us and we'll set you up with an `API_KEY` to use the API. ## REST easy The Watsi API strives to be [RESTful](https://en.wikipedia.org/wiki/Representational_state_transfer) and attempts to conform to [JSON API](http://jsonapi.org/) specification. [block:callout] { "type": "warning", "title": "Accessing via AJAX", "body": "Currently, our API endpoints are not set up with CORS and cannot be accessed from browser-side JavaScript. You will have to proxy the request through a server." } [/block]
## API Basics The Watsi API gives you access to give Watsi donors credit. Once that credit reaches a certain value, those donors will then receive a Watsi gift card with their balance allowing them to experience Watsi first hand and donate to a patient's healthcare. Before you do anything, you should [create a free Watsi account](https://watsi.org/donors/sign_up) which will allow us to give you API credentials. Once you have an account, reach out to us and we'll set you up with an `API_KEY` to use the API. ## REST easy The Watsi API strives to be [RESTful](https://en.wikipedia.org/wiki/Representational_state_transfer) and attempts to conform to [JSON API](http://jsonapi.org/) specification. [block:callout] { "type": "warning", "title": "Accessing via AJAX", "body": "Currently, our API endpoints are not set up with CORS and cannot be accessed from browser-side JavaScript. You will have to proxy the request through a server." } [/block]
{"_id":"569ecccfebbadc0d0079bf7b","user":"56981fe21547031700fca1b5","link_external":false,"slug":"what-are-they","sync_unique":"","__v":1,"githubsync":"","hidden":false,"body":"Watsi Donors have `Credit`s.\n\nEssentially, a `Credit` is an instance of adding to or removing money from a Watsi donor's account. As an API user, you can add or remove `Credit` from a Watsi donor by using their email.","title":"Credits","excerpt":"","link_url":"","order":999,"project":"53a47666447c0ba24d1a85cb","type":"basic","api":{"auth":"required","params":[],"results":{"codes":[{"status":200,"language":"json","code":"{}","name":""},{"code":"{}","name":"","status":400,"language":"json"}]},"settings":"","url":""},"category":"569ec97c88b5300d00c00814","createdAt":"2016-01-19T23:54:55.104Z","updates":[],"version":"569ebe312d320817003b80b8","metadata":{"title":"","description":"","image":[]},"childrenPages":[]}

Credits


Watsi Donors have `Credit`s. Essentially, a `Credit` is an instance of adding to or removing money from a Watsi donor's account. As an API user, you can add or remove `Credit` from a Watsi donor by using their email.
Watsi Donors have `Credit`s. Essentially, a `Credit` is an instance of adding to or removing money from a Watsi donor's account. As an API user, you can add or remove `Credit` from a Watsi donor by using their email.
{"_id":"569ecfda1082520d005c6fac","api":{"url":"/credits","auth":"required","examples":{"codes":[]},"method":"post","params":[{"_id":"569ecfda1082520d005c6faf","default":"","desc":"The email of the customer you want to credit","name":"customer_email","required":true,"type":"string","in":"body"},{"default":"","desc":"The name of the customer you want to credit","name":"customer_name","required":true,"type":"string","in":"body","_id":"569ecfda1082520d005c6fae"},{"desc":"A whole number of **cents** to credit this customer. A negative value indicates a refund.","name":"donation_amount","required":true,"type":"int","in":"body","_id":"569ecfda1082520d005c6fad","default":""}],"results":{"codes":[{"status":201,"language":"json","code":"{\n  data: {\n    type: \"credit\",\n    id: \"00000000-0000-0000-0000-000000000000\",\n    attributes: {\n      created_at: \"2016-01-01T12:00:00.000-08:00\",\n      amount: \"100\"\n    }\n  }\n}","name":null},{"status":400,"language":"json","code":"{\n  errors: {\n    title: \"Invalud Attribute\",\n    detail: \"'donation_amount' must be a whole number of cents\",\n    status: \"400\"\n  }\n}","name":""},{"status":500,"language":"json","code":"{\n  errors: {\n    title: \"Internal Error\",\n    detail: \"Could not credit your customer\",\n    status: \"500\"\n  }\n}"}]},"settings":"569ebb59ebbadc0d0079bf60"},"body":"Here are some examples on how you can use the API\n[block:code]\n{\n  \"codes\": [\n    {\n      \"code\": \"curl -X POST 'https://api.watsi.org/v1/credits' \\\\\\n-H 'Authorization: Token token=\\\"my_token\\\", email=\\\"my_email\\\"' \\\\\\n--data-urlencode 'customer_email=customer@myapp.com' \\\\\\n--data-urlencode 'customer_name=name' \\\\\\n--data-urlencode 'donation_amount=1000'\",\n      \"language\": \"curl\",\n      \"name\": \"cURL\"\n    },\n    {\n      \"code\": \"require 'uri'\\nrequire 'net/http'\\nrequire 'net/https'\\n\\ncharges_url = 'https://api.watsi.org/v1/charges'\\nparams = {\\n  customer_email: 'customer@myapp.com',\\n  customer_name: 'Oscar Sanchez',\\n  donation_amount: 1000\\n}\\nheaders = {\\n  'Content-Type' => 'application/json',\\n  'Authorization' => 'Token token=\\\"my_token\\\", email=\\\"my_email\\\"'\\n}\\n\\nuri = URI.parse(charges_url)\\nhttps = Net::HTTP.new(uri.host, uri.port)\\n#https.use_ssl = true\\nreq = Net::HTTP::Post.new(uri.path, initheader = headers)\\nreq.set_form_data(params)\\n\\nresponse = https.request(req)\\nputs response.body\",\n      \"language\": \"ruby\",\n      \"name\": \"Ruby\"\n    }\n  ]\n}\n[/block]","editedParams2":true,"excerpt":"","order":999,"slug":"credits","title":"/credits","__v":0,"version":"569ebe312d320817003b80b8","type":"post","githubsync":"","link_external":false,"user":"56981fe21547031700fca1b5","category":"569ec97c88b5300d00c00814","createdAt":"2016-01-20T00:07:54.801Z","hidden":false,"link_url":"","sync_unique":"","project":"53a47666447c0ba24d1a85cb","updates":[],"editedParams":true,"metadata":{"title":"","description":"","image":[]},"childrenPages":[]}

post/credits


Body Params

customer_email:
required
string
The email of the customer you want to credit
customer_name:
required
string
The name of the customer you want to credit
donation_amount:
required
integer
A whole number of **cents** to credit this customer. A negative value indicates a refund.
Here are some examples on how you can use the API [block:code] { "codes": [ { "code": "curl -X POST 'https://api.watsi.org/v1/credits' \\\n-H 'Authorization: Token token=\"my_token\", email=\"my_email\"' \\\n--data-urlencode 'customer_email=customer@myapp.com' \\\n--data-urlencode 'customer_name=name' \\\n--data-urlencode 'donation_amount=1000'", "language": "curl", "name": "cURL" }, { "code": "require 'uri'\nrequire 'net/http'\nrequire 'net/https'\n\ncharges_url = 'https://api.watsi.org/v1/charges'\nparams = {\n customer_email: 'customer@myapp.com',\n customer_name: 'Oscar Sanchez',\n donation_amount: 1000\n}\nheaders = {\n 'Content-Type' => 'application/json',\n 'Authorization' => 'Token token=\"my_token\", email=\"my_email\"'\n}\n\nuri = URI.parse(charges_url)\nhttps = Net::HTTP.new(uri.host, uri.port)\n#https.use_ssl = true\nreq = Net::HTTP::Post.new(uri.path, initheader = headers)\nreq.set_form_data(params)\n\nresponse = https.request(req)\nputs response.body", "language": "ruby", "name": "Ruby" } ] } [/block]

User Information

Try It Out

post
{{ tryResults.results }}
Method{{ tryResults.method }}
Request Headers
{{ tryResults.requestHeaders }}
URL{{ tryResults.url }}
Request Data
{{ tryResults.data }}
Status
Response Headers
{{ tryResults.responseHeaders }}

Definition

{{ api_url }}{{ page_api_url }}

Result Format



Here are some examples on how you can use the API [block:code] { "codes": [ { "code": "curl -X POST 'https://api.watsi.org/v1/credits' \\\n-H 'Authorization: Token token=\"my_token\", email=\"my_email\"' \\\n--data-urlencode 'customer_email=customer@myapp.com' \\\n--data-urlencode 'customer_name=name' \\\n--data-urlencode 'donation_amount=1000'", "language": "curl", "name": "cURL" }, { "code": "require 'uri'\nrequire 'net/http'\nrequire 'net/https'\n\ncharges_url = 'https://api.watsi.org/v1/charges'\nparams = {\n customer_email: 'customer@myapp.com',\n customer_name: 'Oscar Sanchez',\n donation_amount: 1000\n}\nheaders = {\n 'Content-Type' => 'application/json',\n 'Authorization' => 'Token token=\"my_token\", email=\"my_email\"'\n}\n\nuri = URI.parse(charges_url)\nhttps = Net::HTTP.new(uri.host, uri.port)\n#https.use_ssl = true\nreq = Net::HTTP::Post.new(uri.path, initheader = headers)\nreq.set_form_data(params)\n\nresponse = https.request(req)\nputs response.body", "language": "ruby", "name": "Ruby" } ] } [/block]
{"_id":"569ebe332d320817003b80bc","version":"569ebe312d320817003b80b8","updates":[],"api":{"results":{"codes":[{"language":"json","name":"Success","code":"{}"},{"name":"Failure","code":"{}","language":"json"}]},"auth":"never","params":[],"url":""},"slug":"next-steps","project":"53a47666447c0ba24d1a85cb","createdAt":"2014-09-26T05:37:31.326Z","sync_unique":"","hidden":false,"body":"Our API is currently really simple, but we are curious what kind of API would be useful. If you are interested in building something on top of Watsi, we'd love to talk more. Get in touch at [connect@watsi.org](mailto:connect@watsi.org)!","excerpt":"","category":"569ebe322d320817003b80bb","link_url":"","githubsync":"","title":"Next Steps","user":"5250b3ad5ac09b3564000005","link_external":false,"order":4,"type":"basic","__v":0,"metadata":{"title":"","description":"","image":[]},"childrenPages":[]}

Next Steps


Our API is currently really simple, but we are curious what kind of API would be useful. If you are interested in building something on top of Watsi, we'd love to talk more. Get in touch at [connect@watsi.org](mailto:connect@watsi.org)!
Our API is currently really simple, but we are curious what kind of API would be useful. If you are interested in building something on top of Watsi, we'd love to talk more. Get in touch at [connect@watsi.org](mailto:connect@watsi.org)!