ThoughtFarmer REST API
The ThoughtFarmer API is RESTful, so that the API is entirely HTTP-based. This means that methods that retrieve data from the ThoughtFarmer API require a GET request. Methods that submit, change, or destroy data require a POST, PATCH, PUT or DELETE.
API Methods that require a particular HTTP method will return an error if you do not make your request with the correct method. HTTP Response Codes are meaningful. Each API method lists the HTTP Response codes that indicate an error. A response code of 200 (OK) means success.
Making API calls
Custom Cards and browser based integrations
If you are building custom cards, or other browser based scripts within ThoughtFarmer itself then you do not need to use an API token or any special authentication code. For example, https://community.thoughtfarmer.com/api/users/current (add your own root URL to the /api/users/current to test). The API calls made via code will carry along with it the credentials for the currently logged in user automatically.
Authentication
Any request to the API requires an authentication token to be passed along with it. To retrieve your API token go to the Admin panel > Integrations section > API Tokens page. Each user should be using their own token for access under the REST API Authentication Tokens section.
The token then must be used in a special authorization header.
Authorization header
The token must be present in the header using the key "Authorization". For example,
$R = Invoke-WebRequest -Uri https://community.thoughtfarmer.com/api/users/current -Method GET -Headers @{"Authorization"="{APIToken}" }
$R.Content
Clear-Variable RResponses JSON
XML is no longer supported as a response type by the API for any ThoughtFarmer 9+ instance. All responses regardless of content-type header will be returned as JSON.
Documentation
We are using Swagger tools to help us auto-generate our API documentation. These generated documents are available from the admin panel. Just go to the Admin Panel > Integrations section > Api Tokens page. The REST API documentation link can be found as shown below:
Some more advanced endpoints have documentation available in this section.
ThoughtFarmer Developer Tools
We have a set of tools for building custom cards and working with our Public and FormFlow APIs, all with samples. This makes working with the APIs and building cards a breeze. See https://github.com/thoughtfarmer/thoughtfarmer-dev-tools for details.
Comments
0 comments
Please sign in to leave a comment.