Getting started overview
This guide provides a focused walkthrough for developers to initiate API interactions with Typeform. It covers the essential steps from account creation and API key generation to executing a foundational API request. The Typeform API allows for programmatic management of forms, collection of responses, and integration with other systems, facilitating automated workflows for data capture and user engagement. Understanding the authentication mechanism—using Personal Access Tokens—is central to securing API calls and accessing Typeform resources.
The Typeform API follows a RESTful architecture, utilizing standard HTTP methods (GET, POST, PUT, DELETE) for resource manipulation. Responses are typically returned in JSON format. Developers can interact with forms, themes, responses, and webhooks through dedicated endpoints. For real-time data processing, Typeform supports webhooks to send notifications upon form submissions, allowing for immediate backend processing or triggering of subsequent actions.
This page focuses on the initial setup and a basic API call. For comprehensive details on all available endpoints and data models, refer to the official Typeform API reference documentation.
Quick Reference Steps
| Step | What to do | Where |
|---|---|---|
| 1. Create Account | Sign up for a Typeform account. A free plan is available for initial development. | Typeform Pricing Page |
| 2. Generate Token | Obtain a Personal Access Token from your Typeform account settings. | Typeform Developer Getting Started guide |
| 3. Install Tools | Set up your preferred development environment and a tool for making HTTP requests (e.g., cURL, Postman, a programming language's HTTP client). | Your local development environment |
| 4. Make Request | Construct an API request using your token to fetch data, such as a list of forms. | Your chosen HTTP client |
| 5. Process Response | Parse the JSON response to confirm successful communication with the API. | Your chosen programming language/tool |
Create an account and get keys
Before making any API requests, you need a Typeform account and a Personal Access Token. The free plan offers sufficient functionality for initial API exploration and development.
Account Creation
- Navigate to the Typeform website.
- Click on 'Sign up' or 'Get started for free'.
- Follow the prompts to create your account. You can use an email address, Google, or Microsoft account for registration.
- Once registered, complete any initial setup steps for your Typeform workspace.
Generating a Personal Access Token
Typeform API uses Personal Access Tokens (PATs) for authentication. These tokens are analogous to API keys and should be treated as sensitive credentials. They grant access to your Typeform account resources, so it's crucial to keep them secure and avoid exposing them in client-side code or public repositories.
- Log in to your Typeform account.
- Access your account settings. This is typically found by clicking on your profile icon in the top right corner and selecting 'Settings' or 'Account'.
- Within your settings, look for a section related to 'Personal Access Tokens' or 'Developer settings'. The exact path may vary slightly but is usually under 'My profile' or 'Integrations'. Refer to the Typeform developer getting started guide for the most up-to-date navigation.
- Click 'Generate a new token'.
- Provide a descriptive name for your token (e.g., "My Development Token").
- Ensure the token has the necessary scopes or permissions for the API operations you intend to perform. For initial testing, selecting broad read permissions is often sufficient. For production, apply the principle of least privilege.
- Copy the generated token immediately. Typeform often displays the token only once upon creation, and you might not be able to retrieve it later. If lost, you'll need to generate a new one.
This token will be included in the Authorization header of your API requests as a Bearer token, a common practice in OAuth 2.0 bearer token usage.
Your first request
With an account and a Personal Access Token, you can now make your first API call. This example demonstrates fetching a list of your existing forms using cURL, a widely available command-line tool for making HTTP requests. You can adapt this to your preferred programming language or HTTP client.
Prerequisites
- Your Personal Access Token (e.g.,
YOUR_TYPEFORM_ACCESS_TOKEN). - A Typeform account with at least one form created (you can create a simple test form within the Typeform builder).
cURLinstalled on your system.
Fetch a list of forms using cURL
The endpoint to list forms is GET https://api.typeform.com/forms.
curl -X GET \
'https://api.typeform.com/forms' \
-H 'Accept: application/json' \
-H 'Authorization: Bearer YOUR_TYPEFORM_ACCESS_TOKEN'
Replace YOUR_TYPEFORM_ACCESS_TOKEN with the actual token you generated.
Expected Response
A successful response will return a JSON object containing an array of your forms. Each form object will include details like its ID, title, and creation date. If you have no forms, the items array will be empty.
{
"items": [
{
"id": "YOUR_FORM_ID",
"title": "My First Typeform",
"last_updated_at": "2023-01-01T12:00:00Z",
"_links": {
"display": "https://youraccount.typeform.com/to/YOUR_FORM_ID",
"responses": "https://api.typeform.com/forms/YOUR_FORM_ID/responses"
}
}
],
"page_count": 1,
"total_items": 1
}
If you encounter an error, check the troubleshooting section below.
Example in JavaScript
For JavaScript developers, using fetch is a common way to interact with APIs.
const accessToken = 'YOUR_TYPEFORM_ACCESS_TOKEN';
fetch('https://api.typeform.com/forms', {
method: 'GET',
headers: {
'Accept': 'application/json',
'Authorization': `Bearer ${accessToken}`
}
})
.then(response => {
if (!response.ok) {
throw new Error(`HTTP error! Status: ${response.status}`);
}
return response.json();
})
.then(data => {
console.log('Forms retrieved:', data.items);
})
.catch(error => {
console.error('Error fetching forms:', error);
});
Example in Python
Python developers can use the requests library.
import requests
access_token = 'YOUR_TYPEFORM_ACCESS_TOKEN'
headers = {
'Accept': 'application/json',
'Authorization': f'Bearer {access_token}'
}
response = requests.get('https://api.typeform.com/forms', headers=headers)
if response.ok:
data = response.json()
print('Forms retrieved:', data.get('items'))
else:
print(f'Error fetching forms: {response.status_code} - {response.text}')
Common next steps
After successfully making your first request, consider these common next steps to further integrate with the Typeform API:
- Retrieve Form Responses: Access submissions for a specific form using the Retrieve Responses endpoint. This is crucial for collecting and processing data gathered through your Typeforms.
- Create or Update Forms: Programmatically manage your forms. The API allows you to create new forms, update existing ones, and manage form fields, offering automation for form lifecycle management.
- Implement Webhooks: Set up webhooks to receive real-time notifications whenever a form is submitted. This enables immediate processing of new data, such as triggering an email, updating a CRM, or initiating other business logic. Consult the Typeform Webhooks documentation for setup details.
- Explore SDKs: If you are working with JavaScript, explore the official Typeform JavaScript SDK to simplify API interactions and handle common tasks more efficiently.
- Error Handling: Implement robust error handling in your application to gracefully manage API rate limits, authentication failures, and other potential issues.
-
Pagination: For accounts with many forms or responses, understand how to use pagination parameters (
page_size,before,after) to retrieve data in manageable chunks, as outlined in the API reference.
Troubleshooting the first call
Encountering issues during your first API call is common. Here are some typical problems and their solutions:
-
401 Unauthorized:
- Issue: Your Personal Access Token is missing, incorrect, or expired.
- Solution: Double-check that you've included the
Authorization: Bearer YOUR_TYPEFORM_ACCESS_TOKENheader correctly. Ensure there are no typos in the token itself. If unsure, generate a new token from your Typeform account settings.
-
403 Forbidden:
- Issue: Your token does not have the necessary permissions (scopes) to access the requested resource.
- Solution: Review the permissions granted to your Personal Access Token. For listing forms, ensure it has at least read access to forms. You might need to generate a new token with broader permissions for testing, then narrow them down for production.
-
404 Not Found:
- Issue: The API endpoint URL is incorrect, or the resource you're trying to access (e.g., a specific form ID) does not exist.
- Solution: Verify the URL against the Typeform API reference. Ensure any resource IDs (like form IDs) are correct and belong to your account.
-
500 Internal Server Error:
- Issue: A problem on the Typeform API server side.
- Solution: This is usually temporary. Wait a few minutes and retry the request. If the issue persists, check the Typeform Status Page for any reported outages.
-
Incorrect JSON Parsing:
- Issue: Your code is failing to parse the JSON response.
- Solution: Ensure your HTTP client is configured to expect and parse JSON (e.g., setting
Accept: application/jsonin the request header). Verify the response body is valid JSON using a linter or online tool.
-
Rate Limiting (429 Too Many Requests):
- Issue: You've sent too many requests in a short period.
- Solution: Implement exponential backoff and retry logic in your application. Refer to the Typeform getting started documentation for specific rate limit details.